MA PRO USER MANUAL

1. Overview

ZZ Div + ST is a multi-component overlay indicator for TradingView that combines three distinct analytical tools in a single script: a fully parametric ZigZag, a manual divergence detector, and a dual SuperTrend. Each component can be operated independently — the ZigZag runs continuously on every bar, the divergence engine is user-driven and event-based, and the two SuperTrend plots each have their own enable toggle.

The indicator is designed for traders who want objective structure identification (ZigZag), a precise, self-managed divergence workflow (Divergence Detector), and a clean ATR-based trend filter (SuperTrend) — all visible on the same price chart without switching between indicators.

 

1.1  The Three Components

ZigZag Automatically detects swing highs and swing lows based on a minimum percentage deviation threshold and a pivot-leg depth setting. Draws connecting lines between confirmed pivots and annotates each with cumulative volume, reversal price, or price-change data.
Divergence Detector A manual, click-to-select divergence tool. The user nominates up to three pivot highs and three pivot lows directly on the chart by clicking during settings. The indicator then checks every pair of nominated pivots for regular and hidden divergence against both a user-configurable external source and an RSI computed on the high/low series.
SuperTrend An ATR-based trend-following band rendered as a broken line on the price chart. Two independent SuperTrend instances are available: a primary one computed on the chart’s native timeframe, and a secondary one fetched from a user-selected higher timeframe.

 

1.2  What ZZ Div + ST Is Not

ZZ Div + ST does not fire alerts automatically. The divergence detector is fully manual — it does not scan history for divergences autonomously; it only evaluates the pivots you explicitly nominate. The ZigZag does not predict future pivots. The SuperTrend is a reactive indicator based on past ATR values; it does not forecast trend duration.

 

1.3  Compatibility

Platform TradingView (any plan that supports Pine Script indicators)
Pine Script Version v6
Overlay Yes — renders directly on the price chart
Asset Classes All — Stocks, ETFs, Forex, Crypto, Futures, Indices, Commodities
Chart Types All standard chart types
max_bars_back 5000 — required for the ZigZag to access deep history

 

 

 

2. Installation

2.1  Adding ZZ Div + ST to Your Chart

  • Open TradingView and navigate to any chart.
  • Click the Indicators button at the top of the chart (or press /).
  • In the search box, type “ZZ Div” and press Enter.
  • Locate ZZ Div + ST in the results and click it. The indicator loads immediately as an overlay.
  • A Pivot Point Confirmation dialog will appear — this is TradingView prompting you to set the six divergence pivot timestamps. You can click OK to dismiss it and configure pivots later, or set them immediately by clicking on the chart at each pivot bar. See Section 5.2 for the full pivot-selection workflow.
  • Click OK to confirm. The ZigZag and SuperTrend are active immediately. The divergence component activates once at least one pivot is selected.

 

2.2  Accessing Settings After Installation

  • Hover over the ZZ Div + ST label in the chart’s indicator list.
  • Click the gear icon (⚙) that appears to the right of the label.
  • Alternatively, double-click any ZigZag line or SuperTrend line on the chart.

 

2.3  Resetting to Defaults

Open Settings, click the three-dot menu (⋯) in the top-right corner of the Settings panel, and select “Reset settings to default.” This restores all settings to their factory values, clears all six pivot timestamps, and removes all divergence lines.

⚠️  Pivot Confirmation on First Load

When ZZ Div + ST is first added to a chart, TradingView will display a Pivot Point Confirmation screen for the six divergence time inputs (Pivot High 1–3 and Pivot Low 1–3). These inputs use TradingView’s confirm = true mechanism.

You can click directly on pivot bars on the chart to set each timestamp, or simply click OK to skip all six and set them later via the Settings panel.

Until at least one pivot timestamp is set, the divergence component produces no output — only the ZigZag and SuperTrend are active.

 

 

 

3. Settings Reference

ZZ Div + ST organises its settings into three sections in the Settings panel: the ZigZag section (no group label — appears at the top), the Divergence Check group, and the SuperTrend group.

 

3.1  ZigZag Settings

These settings appear at the top of the Settings panel without a group heading. Some are marked as Data Window only, meaning they do not appear in the visual settings panel but are accessible via TradingView’s data window sidebar (right-click the chart → Data Window).

Setting Default Options / Range Description
Price Deviation Threshold for Pivots (%) 3.0 0.1 – 50.0, step 0.25 The minimum percentage move required between a confirmed pivot and the next candidate pivot for a new ZigZag leg to be registered. A lower value produces more frequent, shorter legs. A higher value filters out smaller swings and produces fewer, longer legs. This is the most impactful ZigZag setting.
Pivot legs 1 Integer ≥ 1 Controls the pivot look-left/look-right depth used to confirm a swing point. The value entered is halved and floored internally, with a minimum of 2. In practice, the default of 1 results in an internal depth of 2. See Section 4.2 for a full explanation of how this value translates to detection behaviour.
Line color #2962FF at 50% opacity Any color (Data Window only) The colour and opacity of the ZigZag lines drawn between confirmed pivots. Only accessible via the Data Window. The default is a semi-transparent blue.
Extend To Last Bar On On / Off (Data Window only) When On, a provisional line is drawn from the last confirmed pivot to the current bar’s high or low (whichever is in the anticipated direction of the next pivot). This line updates in real time and is removed if a new confirmed pivot is found. When Off, the chart only shows lines between confirmed pivots.
Display Cumulative Volume On On / Off (Data Window only) When On, a label at each pivot endpoint shows the total volume accumulated across all bars within that ZigZag leg. The volume is formatted with TradingView’s volume number formatting (e.g. 1.2M, 450K).
Display Pivot Price Off On / Off (Data Window only) When On, the pivot endpoint label additionally shows the exact price of the pivot in mintick format.
Display Pivot Price Change In: Off On / Off (Data Window only) When On, the pivot endpoint label additionally shows the price change from the start to the end of the leg. The format (Absolute or Percent) is set by the adjacent selector.
(Price Change Format) Percent Absolute, Percent (Data Window only) Active only when Display Pivot Price Change is On. “Absolute” shows the raw price difference in mintick format (e.g. +1.45). “Percent” shows the change as a percentage (e.g. +3.2%).

 

3.2  Divergence Check Settings

Setting Default Options / Range Description
Enable Divergence Detector On On / Off Master toggle for the entire divergence component. When Off, all divergence lines and pivot marker shapes are removed from the chart, and all six pivot timestamp inputs are ignored. The pivot data stored in memory is cleared but the timestamps are not reset.
RSI Period 6 Integer ≥ 1 The lookback period for the RSI calculation used as the oscillator in divergence checks. RSI is computed on the high series for bearish divergence detection and on the low series for bullish divergence detection — not on the close. A shorter period (e.g. 6) makes the RSI more sensitive; a longer period (e.g. 14) makes it smoother.
External Source (Highs) high Any source The external source series used as an additional oscillator for bearish (high-pivot) divergence checking. Defaults to the chart’s high series, but can be set to any indicator output via TradingView’s source picker — for example, a volume indicator, MACD line, or custom oscillator. Divergence triggers if either this source OR the RSI diverges.
External Source (Lows) low Any source The external source series used for bullish (low-pivot) divergence checking. Mirrors the above — defaults to low, can be any external source.
Pivot High 1 0 (unset) Time — confirmed on chart The timestamp of the first user-selected pivot high. Set by clicking on a bar during the confirm dialog, or by editing the time value in Settings. Once set, the bar’s high price, external source value, and RSI value are captured and stored.
Pivot High 2 0 (unset) Time — confirmed on chart The timestamp of the second user-selected pivot high.
Pivot High 3 0 (unset) Time — confirmed on chart The timestamp of the third user-selected pivot high.
Pivot Low 1 0 (unset) Time — confirmed on chart The timestamp of the first user-selected pivot low. Captured values: bar’s low price, external source, and RSI on that bar.
Pivot Low 2 0 (unset) Time — confirmed on chart The timestamp of the second user-selected pivot low.
Pivot Low 3 0 (unset) Time — confirmed on chart The timestamp of the third user-selected pivot low.

 

3.3  SuperTrend Settings

Setting Default Options / Range Description
Enable SuperTrend for Current TimeFrame On On / Off Enables the primary SuperTrend, computed on the chart’s own timeframe using ta.supertrend(). When Off, no SuperTrend line is drawn and no calculations are performed for the primary instance.
ATR Length (primary) 6 Integer ≥ 1 The ATR lookback period used by the primary SuperTrend. Shorter values produce a more reactive ATR and a tighter SuperTrend band; longer values produce a smoother, wider band.
Factor (primary) 1.0 ≥ 0.1, step 0.1 The ATR multiplier applied to compute the SuperTrend band offset from the midpoint. A lower factor (e.g. 1.0) places the band closer to price, producing more frequent trend flips. A higher factor (e.g. 3.0) places the band further away, producing fewer flips.
Enable SuperTrend for Higher Timeframe Off On / Off Enables the secondary SuperTrend, fetched from a user-specified higher timeframe via request.security.
Higher Timeframe 60 Any TradingView timeframe string The timeframe from which the secondary SuperTrend is fetched. Defaults to 60 (1-hour). Accepts any valid TradingView timeframe string (e.g. “D”, “240”, “W”).
ATR Length (secondary) 6 Integer ≥ 1 The ATR lookback period for the secondary SuperTrend, applied within the higher timeframe context.
Factor (secondary) 1.0 ≥ 0.1, step 0.1 The ATR multiplier for the secondary SuperTrend.

 

 

 

4. ZigZag Component — In Depth

The ZigZag component continuously scans every bar for swing highs and swing lows that satisfy two conditions: they must qualify as a local extremum over a look-left/look-right window (determined by the Pivot legs setting), and the move from the prior confirmed pivot to the new candidate must meet or exceed the configured percentage deviation threshold.

 

4.1  Pivot Detection Algorithm

On each bar, the ZigZag checks for both a pivot high (using the high series) and a pivot low (using the low series). A pivot high at bar N is confirmed if:

  • high[N] is strictly greater than every bar in the range [N−depth, N−1] (the look-left window), AND
  • high[N] is greater than or equal to every bar in the range [N+1, N+depth] (the look-right window).

The asymmetric comparison (strict on the left, non-strict on the right) means that if two adjacent bars share an identical high, the leftmost one is treated as the pivot. An equivalent check applies for pivot lows, reversed.

Once a candidate pivot is found, the percentage deviation from the previous confirmed pivot is computed:

deviation = 100 × (candidate_price − last_pivot_price) / |last_pivot_price|

The new pivot is accepted only if this deviation meets or exceeds the configured threshold in the appropriate direction (positive for highs after lows; negative for lows after highs).

 

4.2  The Pivot Legs Setting and Internal Depth

The Pivot legs input does not directly map 1-to-1 to the look-left/look-right window. Internally, the value is transformed:

internal_depth = max(2, floor(pivot_legs / 2))

This means the relationship between the input value and the actual detection window is as follows:

Pivot Legs Input Internal Depth (bars each side)
1 (default) 2  (floor(0.5) = 0 → max(2,0) = 2)
2 2  (floor(1) = 1 → max(2,1) = 2)
3 2  (floor(1.5) = 1 → max(2,1) = 2)
4 2  (floor(2) = 2 → max(2,2) = 2)
6 3  (floor(3) = 3 → max(2,3) = 3)
8 4  (floor(4) = 4 → max(2,4) = 4)
10 5  (floor(5) = 5 → max(2,5) = 5)

 

💡  Practical Implication

Values of 1–4 all produce the same internal depth of 2 bars. Meaningful increases in detection stringency begin at Pivot legs = 6 (internal depth 3) and increase by 1 step for every additional 2 units of input. For most use cases, the default of 1 provides a reasonable balance between sensitivity and noise.

 

4.3  Same-Bar High and Low Pivots

The ZigZag allows both a pivot high and a pivot low to be confirmed on the same bar. This is controlled by the internal allowZigZagOnOneBar flag, which is hardcoded to true. In volatile markets — particularly on lower timeframes — a single bar can represent both a local high and a local low if the deviation threshold is met in both directions from the prior pivot. Both pivots will be registered and both lines will be drawn.

 

4.4  The Extend-to-Last-Bar Line

When Extend To Last Bar is enabled, a provisional ZigZag segment is drawn from the most recent confirmed pivot to the current bar’s live price. This line anticipates the direction of the next pivot:

  • If the last confirmed pivot was a low, the extension points toward the current bar’s high (anticipating the next pivot high).
  • If the last confirmed pivot was a high, the extension points toward the current bar’s low (anticipating the next pivot low).

The extension line is redrawn on every bar update. If a new confirmed pivot is detected (somethingChanged = true), the old extension is deleted and a fresh one is created from the new pivot. This extension is purely visual — it does not affect pivot storage, cumulative volume calculation, or divergence detection.

 

4.5  Cumulative Volume

When Display Cumulative Volume is enabled, each ZigZag pivot label shows the total volume accumulated across all bars within that leg — from the prior pivot bar to the current pivot bar. Volume is accumulated bar-by-bar into a running sumVol variable, which is reset to zero each time a new pivot is confirmed. The remaining bars between the last confirmed pivot and the current bar (remVol) are added to the extension line’s label in real time.

⚠️  Volume Data Requirement

Cumulative volume labels require the chart instrument to have volume data. On instruments without volume (some forex pairs and indices), the labels will display 0 or n/a. Disable Display Cumulative Volume on such instruments to avoid misleading labels.

 

4.6  Pivot Endpoint Labels

ZigZag pivot labels appear above pivot highs and below pivot lows, using TradingView’s label.style_none (transparent background, white text at 50% opacity). Labels are positioned at the pivot endpoint and can show any combination of three data points based on the settings:

  • Pivot price — the exact price of the swing high or low in mintick format.
  • Price change — the move from the start to the end of the leg, shown as either an absolute value or a percentage (prefixed with + or −).
  • Cumulative volume — the total volume for the leg on a new line below the other data.

If none of the three display options are enabled, no label is created at all for that pivot — only the ZigZag line is drawn.

 

 

 

5. Divergence Detector — In Depth

The Divergence Detector is a manually-driven tool. It does not autonomously scan historical data for divergences. Instead, the user nominates specific pivot bars of interest, and the indicator evaluates every pair of nominated pivots for all four divergence types simultaneously.

 

5.1  Workflow Overview

The typical workflow for using the Divergence Detector is:

  • Identify a pivot high or pivot low of interest on the chart — typically a swing point that corresponds to a ZigZag node.
  • Open the indicator’s Settings panel.
  • In the Divergence Check group, click the clock icon next to one of the Pivot High or Pivot Low inputs. TradingView activates point-selection mode — click the bar on the chart you want to register as that pivot.
  • Repeat for up to three highs and three lows. You do not need to use all six slots.
  • Click OK. The indicator immediately evaluates all nominated pivots plus the current live bar for divergence. Lines are drawn on the chart connecting any pairs where divergence conditions are met.
  • As new bars form, the live bar is automatically re-evaluated against all nominated pivots. Divergence lines are redrawn on each realtime bar update.

💡  When Are Divergences Evaluated?

Divergence detection runs only on the last confirmed history bar (barstate.islastconfirmedhistory) and on each realtime bar (barstate.isrealtime). It does not run on every historical bar. This is intentional — it ensures that all lines are redrawn from scratch on each update, preventing line accumulation, and that the live bar comparison is always current.

As a result, divergence lines do not appear while replaying historical data — they will appear correctly when the chart returns to live mode.

 

5.2  Selecting Pivots on the Chart

Each of the six pivot inputs (Pivot High 1–3 and Pivot Low 1–3) stores a Unix timestamp corresponding to a specific bar’s open time. There are two ways to set each timestamp:

 

Method 1 — Click on Chart (Recommended):

  • Open Settings. In the Divergence Check group, click the clock icon or crosshair button next to a Pivot input.
  • The Settings panel temporarily minimises and a crosshair appears on the chart.
  • Click the bar you want to register as that pivot. The indicator captures the bar’s open time as the timestamp, and also immediately stores the bar’s high or low price, external source value, and RSI value at that bar.

 

Method 2 — Direct Time Entry:

  • Open Settings and manually type a Unix timestamp (in milliseconds) into a Pivot input field.
  • Data is captured on the next full chart recalculation. This method is less convenient but useful for programmatically setting pivots or copying timestamps from other sources.

 

⚠️  Pivot Data Capture Timing

Pivot values (price, RSI, external source) are captured at the bar where time == pivot_timestamp. This means the data captured is always the actual OHLCV data of the selected bar — not any interpolated or projected value. Changing the RSI period or external source after pivots are set does not retroactively update the stored values. To refresh captured values, re-open Settings and re-click each pivot on the chart.

 

5.3  The Four Divergence Types

The detector evaluates every ordered pair of nominated pivots (A before B in time) for four distinct divergence conditions. The same logic applies across all pairs simultaneously — a single set of nominated pivots can produce multiple divergence lines of different types.

Type Price Action Oscillator Line Style Signal Implication
Regular Bearish B high > A high (higher high) B osc < A osc (lower reading) Solid red line Momentum weakening at higher price — potential reversal downward.
Hidden Bearish B high < A high (lower high) B osc > A osc (higher reading) Dashed red line Oscillator strength during a lower high — downtrend continuation signal.
Regular Bullish B low < A low (lower low) B osc > A osc (higher reading) Solid green line Momentum strengthening at lower price — potential reversal upward.
Hidden Bullish B low > A low (higher low) B osc < A osc (lower reading) Dashed green line Oscillator weakness during a higher low — uptrend continuation signal.

 

5.4  The Oscillator: RSI vs External Source (OR Logic)

For each pair of pivots, the divergence condition is tested against two oscillators simultaneously:

RSI computed on the high series (for highs) or low series (for lows) at the period configured in RSI Period.

External Source specified in the External Source (Highs/Lows) input — defaulting to the chart’s high or low series but replaceable with any indicator output.

The divergence condition uses OR logic: a divergence is flagged if either the external source diverges OR the RSI diverges (or both). This means the detector is relatively permissive — it will draw a line as soon as one of the two oscillators shows divergence, even if the other does not.

💡  Using External Sources Effectively

The default external sources (high for highs, low for lows) mean the divergence check effectively tests: does the RSI of the high/low series diverge with the high/low price? With both external source and RSI derived from the same base series, both checks are meaningful but somewhat correlated.

A more powerful configuration is to assign a volume-based indicator (e.g. OBV, CMF) or a momentum indicator (e.g. MACD histogram) as the external source. This makes the OR condition materially more informative — price diverges with volume momentum OR price diverges with RSI.

 

5.5  Live Bar Validation

The current (live) bar is always appended to the pivot lists so that divergence against the live price can be evaluated in real time. However, to prevent false positive signals — where the live bar appears to diverge simply because it temporarily exceeds a pivot, not because it is a genuine structural extreme — the indicator applies a validation check when the live bar is the second pivot (B):

  • Regular bearish: the live bar’s high must be strictly greater than the highest of all nominated Pivot High timestamps. If the live bar’s high merely equals or is below the maximum nominated high, no regular bearish line is drawn against the live bar.
  • Hidden bearish: the live bar’s high must be strictly less than the lowest nominated Pivot High. If it sits above the minimum, no hidden bearish line is drawn.
  • Regular bullish: the live bar’s low must be strictly lower than the lowest nominated Pivot Low.
  • Hidden bullish: the live bar’s low must be strictly higher than the highest nominated Pivot Low.

 

These checks ensure that a live-bar divergence line is only drawn when the current price has genuinely broken outside the range of all nominated historical pivots, which is the situation in which a live divergence signal has the most structural meaning.

 

5.6  Pivot Marker Shapes

In addition to the divergence lines, small marker shapes are plotted on the chart to identify which bars have been nominated as pivots:

red downward-pointing triangle (▼) appears above the bar.

green upward-pointing triangle (▲) appears below the bar.

These shapes appear regardless of whether divergence is detected — they mark the selected pivot bars, not the divergence outcome. They are only visible when the Divergence Detector is enabled.

 

 

 

6. SuperTrend Component — In Depth

The SuperTrend is an ATR-based trailing stop indicator that plots as a broken line on the price chart. It switches between an uptrend state (line below price) and a downtrend state (line above price) based on whether price closes above or below the current band. ZZ Div + ST provides two independent SuperTrend instances — a primary one and a secondary multi-timeframe one — both rendered in the same gold colour (#FFD400).

 

6.1  How the SuperTrend Algorithm Works

The SuperTrend band is calculated as follows on each bar:

(high + low) / 2.

midpoint + Factor × ATR(Length).

midpoint − Factor × ATR(Length).

  • The active band (the plotted SuperTrend line) is determined by the current trend direction and a ratchet mechanism: once the trend is up, the lower band can only move up (never down); once the trend is down, the upper band can only move down (never up). This prevents the band from widening against the trend.
  • A trend reversal occurs when price closes on the opposite side of the active band.

 

6.2  SuperTrend Direction and Colour

TradingView’s ta.supertrend() function returns a direction value of −1 during an uptrend and +1 during a downtrend. ZZ Div + ST interprets these as:

direction < 0  (= −1) Uptrend — the SuperTrend line plots below price (as the active support band). Labelled “Up Trend” in the plot series.
direction ≥ 0  (= +1) Downtrend — the SuperTrend line plots above price (as the active resistance band). Labelled “Down Trend” in the plot series.

 

Both the Up Trend and Down Trend series are rendered in the same gold colour (#FFD400 at 50% opacity) using plot.style_linebr. The break-line style means no line is drawn at the candle where a trend reversal occurs — preventing a misleading diagonal connection between the old band level and the new one.

 

6.3  First Bar Suppression

The primary SuperTrend value is set to na on the very first bar of the chart (barstate.isfirst). This prevents a spurious data point at bar 0, where ATR has insufficient history to produce a meaningful value. The secondary SuperTrend does not apply this suppression, as it fetches pre-computed data from the higher timeframe.

 

6.4  Secondary SuperTrend — Multi-Timeframe

The secondary SuperTrend is computed inside request.security using the higher timeframe specified in the TF field. The computation is performed entirely within the higher timeframe context — ta.supertrend(st2Factor, st2Length) runs on the higher-timeframe bars, and the result is resampled back onto the chart’s bars.

The fetch uses lookahead = barmerge.lookahead_off, which means the higher-timeframe value only updates when that timeframe’s bar closes. During the current higher-timeframe bar, the previous bar’s SuperTrend value is displayed. This is the correct non-repainting behaviour.

The secondary SuperTrend defaults to the 60-minute timeframe. If the chart is already on a 60-minute or higher timeframe, the secondary SuperTrend will display the same value as the primary (since a higher TF fetch on the same TF as the chart is equivalent to the chart-TF value).

💡  Distinguishing Primary from Secondary SuperTrend Visually

Both SuperTrend instances use the same gold colour, which means they are visually identical in colour. On most charts, the two will be at different price levels since they use different ATR inputs (chart-TF ATR vs higher-TF ATR). If you need to visually distinguish them, consider using TradingView’s plot style editor (right-click the plot in the legend) to override the secondary SuperTrend’s colour.

 

6.5  ATR Length and Factor — Tuning Guidance

Low ATR Length + Low Factor Tight, reactive band. Frequent trend flips. Best for scalping or very fast instruments. Risk of excessive whipsaw.
Low ATR Length + High Factor Wide but reactive band. Fewer flips than above, but the band level can jump sharply on volatile bars.
High ATR Length + Low Factor Smooth band, closer to price. Balanced for swing trading. The default (Length 6, Factor 1.0) falls here.
High ATR Length + High Factor Wide, slow-moving band. Very few trend flips. Best for position trading or as a macro trend filter only.

 

 

 

7. Recommended Setups & Workflows

7.1  Structure + Momentum Baseline Setup

Goal: Use the ZigZag to identify swing structure, the SuperTrend as a trend filter, and the Divergence Detector to flag exhaustion at key structural pivots.

  • ZigZag: Deviation 3.0%, Pivot legs 1. Show Cumulative Volume.
  • SuperTrend (primary): ATR 6, Factor 1.0.
  • SuperTrend (secondary): Disabled initially; enable with a daily TF (“D”) to see the macro trend.
  • Divergence: Enable, RSI Period 6. Leave external sources as high/low defaults.
  • Workflow: Identify the most recent three ZigZag pivot highs and three pivot lows. Register them in the Pivot High/Low inputs. Monitor for divergence lines as new bars form.

 

7.2  Tight Intraday Scalp Setup

Goal: React quickly to short-term structure breaks on 1-minute to 5-minute charts.

  • ZigZag: Deviation 0.5–1.0%, Pivot legs 1.
  • Disable Cumulative Volume (labels create clutter on fast charts).
  • SuperTrend (primary): ATR 4, Factor 0.5 — tight, reactive band.
  • SuperTrend (secondary): Enable with a 15-minute TF (“15”) for context.
  • Divergence: RSI Period 3–6 for sensitivity. Register pivots at intraday swing extremes.

 

7.3  Swing Trade with Volume Divergence

Goal: Detect exhaustion at swing extremes using volume flow as the divergence oscillator rather than RSI.

  • Add a separate OBV or Chaikin Money Flow indicator to the chart.
  • In ZZ Div + ST Settings → Divergence Check, change the External Source (Highs) and External Source (Lows) inputs to point to the OBV or CMF indicator’s output.
  • ZigZag: Deviation 2.0–3.0%, Pivot legs 1–3. Enable Cumulative Volume to cross-reference.
  • Divergence: RSI Period 6 as a secondary filter. Now a divergence line fires if volume flow diverges OR RSI diverges — either alone is sufficient.

 

7.4  Multi-Timeframe SuperTrend Confluence

Goal: Only consider long trades when both the chart-timeframe and higher-timeframe SuperTrends are in uptrend; only shorts when both are in downtrend.

  • Enable both SuperTrend instances.
  • Primary: ATR 6, Factor 1.0 on the chart TF.
  • Secondary: ATR 10, Factor 2.0 on a TF 4–6× higher (e.g. if chart is 15m, use “60”; if chart is 1H, use “D”).
  • Long bias only when price is above both SuperTrend lines simultaneously. Short bias only when price is below both.
  • Use the ZigZag divergence to time entries within the bias direction — e.g. a bullish divergence forming while both SuperTrends are in uptrend is a high-conviction long entry candidate.

 

7.5  Post-Event Pivot Analysis

Goal: After a major news event or price spike, mark the key pre-event and post-event pivots and check whether the subsequent recovery shows divergence (a sign the move may be unsustainable).

  • ZigZag: Deviation 3.0%, showing the major swings around the event.
  • Register the pre-event high and the post-spike high as Pivot High 1 and Pivot High 2.
  • Register the pre-event low and the post-spike low as Pivot Low 1 and Pivot Low 2.
  • If price made a new high but RSI did not — a regular bearish divergence line appears immediately.
  • If price is recovering to a lower high but RSI is stronger — a hidden bearish divergence line appears, signalling potential continuation of the post-spike downtrend.

 

 

 

8. Frequently Asked Questions

Why are there no divergence lines on the chart after I add the indicator?

No pivot timestamps have been set. The divergence detector requires at least two nominated pivots (either two highs or two lows) to produce output. Open Settings and click at least two pivot bars on the chart. Alternatively, if the timestamps were set but the indicator was just added, wait for the next realtime bar — divergence lines only draw on the last confirmed history bar and on realtime bars.

 

Why do divergence lines disappear and reappear?

This is expected behaviour. All divergence lines are deleted and completely redrawn on every realtime bar update. This ensures the chart always reflects the current state of all pivot pairs and the live bar comparison. The lines are not persistent drawings — they are regenerated on each bar.

 

I set a pivot but no triangle marker appeared. Why?

Triangle markers appear only when the Divergence Detector is enabled (Enable Divergence Detector = On) and only on the exact bar whose timestamp matches the pivot input. If you set the timestamp but the bar is not visible in the current chart view, scroll to find it. If the timestamp was entered manually and does not correspond to an actual bar’s open time on this instrument and timeframe, no match will occur and no marker will appear.

 

Why does the ZigZag not react to small intraday swings?

The default 3.0% deviation threshold filters out swings smaller than 3% from the prior pivot. For intraday work on lower volatility instruments, reduce the deviation threshold to 0.5–1.5%. For crypto or high-volatility instruments, 3% may still be appropriate on lower timeframes.

 

Why do the ZigZag lines not update until a new confirmed pivot?

ZigZag lines between confirmed pivots are fixed — they do not change after the pivot is confirmed. Only the Extend To Last Bar provisional line updates in real time. The confirmed pivot lines represent completed structure and are intentionally stable.

 

What does the Pivot legs setting actually change?

The Pivot legs input controls how many bars on each side of a candidate pivot must be examined to confirm it as a local high or low. Due to internal halving and flooring, values of 1 through 4 all produce the same internal depth of 2 bars. Values of 6, 8, 10… produce internal depths of 3, 4, 5… respectively. Higher values require more extreme pivots (fewer, more significant swings) at the cost of additional confirmation lag.

 

Why can I see both a red and a green divergence line between the same two pivots?

This is not possible between the same pivot pair. The four divergence types (regular bearish, hidden bearish, regular bullish, hidden bullish) are mutually exclusive for any single pair — the price conditions (higher high vs lower high, or lower low vs higher low) are mutually exclusive by definition. If you see both colours, they are connecting different pairs of nominated pivots.

 

The divergence detector uses OR logic for RSI and external source. Can I make it AND logic?

Not via a setting — the OR logic is hardcoded. If you prefer AND logic (both oscillators must diverge), the approach is to set the external source to a second indicator that closely tracks RSI (e.g. another RSI with a different period), which effectively increases the requirement since both must agree. Alternatively, treat lines from the dashed (hidden) style as requiring additional confirmation before acting.

 

Why does the primary SuperTrend show na on the first bars of the chart?

The primary SuperTrend explicitly sets its value to na on the very first bar (barstate.isfirst). This prevents a meaningless data point where ATR has no prior bars to average over. The line begins plotting as soon as sufficient ATR history is available. This suppression applies only to the primary SuperTrend — the secondary fetches data from a higher timeframe and does not apply this override.

 

Both SuperTrend lines are gold. How do I tell them apart?

On most charts, they will be at different price levels — the higher-timeframe SuperTrend is typically further from price (wider ATR). If both are at similar levels, right-click the plot label in TradingView’s indicator legend and change the line colour for one of the series to visually distinguish them.

 

Can I use the divergence detector with confirmed history (not live bars)?

The detector runs on barstate.islastconfirmedhistory as well as on each realtime bar. This means if you add the indicator to a chart with historical data, the divergence state as of the last confirmed historical bar is shown. However, divergences are not computed for each individual historical bar — they are only evaluated at the current end of the chart and updated on each new realtime bar.

 

Why does cumulative volume show 0 on some instruments?

Some instruments on TradingView do not have volume data — this includes certain forex pairs and some indices. When volume is unavailable, all volume values are 0 and the cumulative volume labels will display 0. Disable Display Cumulative Volume on such instruments.

 

 

 

9. Appendix: Quick Reference

9.1  Default Values by Component

Setting Default Options / Range Description
ZigZag: Deviation 3.0% 0.1 – 50.0% Primary sensitivity control
ZigZag: Pivot legs 1 Integer ≥ 1 Effective internal depth = 2
ZigZag: Line color #2962FF (50% opacity) Any color Data Window only
ZigZag: Extend To Last Bar On On / Off Data Window only
ZigZag: Display Cumulative Volume On On / Off Data Window only
ZigZag: Display Pivot Price Off On / Off Data Window only
ZigZag: Display Price Change Off On / Off Data Window only
ZigZag: Price Change Format Percent Absolute / Percent Data Window only
Divergence: Enable On On / Off  
Divergence: RSI Period 6 Integer ≥ 1 Applied to high/low series
Divergence: External Source (Highs) high Any source  
Divergence: External Source (Lows) low Any source  
Divergence: Pivot High 1 / 2 / 3 0 (unset) Timestamp Set by chart click
Divergence: Pivot Low 1 / 2 / 3 0 (unset) Timestamp Set by chart click
SuperTrend (primary): Enable On On / Off  
SuperTrend (primary): ATR Length 6 Integer ≥ 1  
SuperTrend (primary): Factor 1.0 ≥ 0.1, step 0.1  
SuperTrend (secondary): Enable Off On / Off  
SuperTrend (secondary): Timeframe 60 Any TF string 1-hour default
SuperTrend (secondary): ATR Length 6 Integer ≥ 1  
SuperTrend (secondary): Factor 1.0 ≥ 0.1, step 0.1  

 

9.2  Divergence Line Visual Reference

───── Regular Bearish: solid red line. Higher high in price, lower oscillator reading.
– – – – Hidden Bearish: dashed red line. Lower high in price, higher oscillator reading.
───── Regular Bullish: solid green line. Lower low in price, higher oscillator reading.
– – – – Hidden Bullish: dashed green line. Higher low in price, lower oscillator reading.

 

9.3  Pivot Leg to Internal Depth Conversion

1 – 4 Internal depth = 2 (minimum)
5 – 6 Internal depth = 2 – 3
7 – 8 Internal depth = 3 – 4
9 – 10 Internal depth = 4 – 5
N Internal depth = max(2, floor(N / 2))