PROTECTED SOURCE SCRIPT

Ks MACD Divergence Visualizer

17
MACD Divergence Visualizer (v6) Documentation

This indicator is a powerful technical analysis tool designed for TradingView (Pine Script v6). It automatically detects and visualizes Divergence—a discrepancy between price action and the MACD (Moving Average Convergence Divergence) oscillator—to identify potential trend reversals or continuations.

1. Core Functionality

4 Types of Detected Divergence

The script identifies and distinguishes between four specific market patterns:

Type

Name

Condition

Market Sentiment

Regular Bullish

Regular Bull

Price makes a lower low, but MACD makes a higher low.

Potential Reversal (Bullish)

Regular Bearish

Regular Bear

Price makes a higher high, but MACD makes a lower high.

Potential Reversal (Bearish)

Hidden Bullish

Hidden Bull

Price makes a higher low, but MACD makes a lower low.

Trend Continuation (Buy Dip)

Hidden Bearish

Hidden Bear

Price makes a lower high, but MACD makes a higher high.

Trend Continuation (Sell Rally)

2. How the Logic Works

Pivot Point Detection

The indicator uses ta.pivothigh and ta.pivotlow to identify significant peaks and troughs in the MACD line.

Left Lookback: Number of bars to the left required to confirm a local peak/trough (Default: 5).

Right Lookback: Number of bars to the right required to confirm the point (Default: 3).

Note: Signals will appear with a delay equal to the "Right Lookback" value to ensure the pivot point is historically valid.

Visual Encoding

Solid Line: Represents Regular Divergence (Reversal). Marked with an "R" label.

Dashed Line: Represents Hidden Divergence (Continuation). Marked with an "H" label.

Color Coding: Green/Teal for Bullish signals, Red/Orange for Bearish signals.

3. Configuration (Input Parameters)

MACD Settings

Fast / Slow / Signal Length: Standard settings are 12, 26, 9. Shorten these for faster response in scalping or lengthen them for swing trading.

Divergence Settings

Pivot Lookback Right: Increasing this improves signal reliability but increases the display delay.

Show Regular / Hidden: Toggle specific types of divergence on/off to declutter your chart.

4. Trading Strategy Tips

Regular (R) = Warning: If a Regular Bearish (R) divergence appears at the end of an uptrend, it suggests the momentum is fading—consider tightening stop losses or taking profits.

Hidden (H) = Confluence: Hidden Bullish (H) divergence during an established uptrend is a strong signal that the trend is healthy and the current dip is a buying opportunity.

Multi-Timeframe Confirmation: Divergences are most effective when confirmed by higher timeframe trends or key Support/Resistance levels.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.