1. About This Manual
This manual describes ZZ Div + ST — a TradingView PineScript v6 indicator that overlays three integrated tools on the main chart: a ZigZag pivot detector with optional volume and price annotations, an oscillator-based divergence detector that draws lines between same-type pivots, and one or two SuperTrend trailing lines (one for the chart’s timeframe, one optionally for a higher timeframe).
Functionally similar to the ATAS indicator Fluctus from the same author, ZZ Div + ST runs natively in TradingView with PineScript-specific advantages: chart overlay (drawing directly on the price chart rather than in a separate pane), multi-timeframe SuperTrend, and an External oscillator option that lets the user plug any series into the divergence detector.
The manual is organized in the order most users will need information:
- Sections 2–3 explain what the indicator shows and the underlying concepts (pivots, divergence definitions, SuperTrend mechanics).
- Section 4 walks through setup and reading the output.
- Section 5 is the complete settings reference, organized by the UI’s grouping.
- Section 6 covers the four divergence types in detail.
- Sections 7–9 cover practical workflows, troubleshooting, and design notes.
Quick Start
- Apply ZZ Div + ST to any TradingView chart. The indicator overlays directly on the price chart — no separate pane required.
- Default settings produce a usable picture immediately: ZigZag lines at a 3% deviation threshold, divergence detection enabled with RSI (split H/L) at length 6, and a primary SuperTrend with ATR Length 6 and Factor 1.0. The higher-timeframe SuperTrend defaults to off.
- Observe the four visual layers: a blue ZigZag line connecting confirmed pivots, optional volume labels at each pivot, divergence lines between same-type pivots when divergence is detected, and a yellow SuperTrend trailing line.
- Each divergence line is solid (regular) or dashed (hidden), colored red for bearish or green for bullish.
- Once you understand the default output, tune the deviation threshold, oscillator choice, length, and SuperTrend parameters to your timeframe and style. The higher-timeframe SuperTrend is the optional second layer that adds trend context from a longer chart period.
2. What ZZ Div + ST Shows
Three independent layers share the chart overlay. Each layer can be enabled or disabled separately.
ZigZag with Annotations
The ZigZag layer identifies confirmed swing highs and lows and connects them with diagonal lines. New pivots commit when price reverses by at least the Price Deviation Threshold against the current swing. The most recent pivot — “semi-confirmed” in the source’s terminology — may slide forward in bar and price during the live bar as price extends or retraces. Once price reverses by the threshold, the pivot finalizes and the next swing begins.
Each pivot can carry up to three text annotations as labels:
- Cumulative Volume — total volume traded between the previous pivot and this one. Displayed in the label at each pivot.
- Pivot Price — the exact price at the pivot. Useful for precise reference.
- Pivot Price Change — the percent or absolute price difference between consecutive pivots. Lets the reader see leg-size at a glance.
All three annotations are independently toggleable. With all three on, each pivot label has three lines of text; with all three off, pivots are pure unlabeled points on the ZigZag line.
The most recent confirmed pivot can optionally extend to the live bar — a horizontal line projecting forward from the pivot. Useful as a visual price reference for the active swing’s anchor.
Divergence Detection
For each newly-confirmed pivot, the indicator examines the recent same-type pivots (highs against highs, lows against lows) and draws a line between any pair where price-versus-oscillator relationship matches one of four divergence definitions. Up to 3 same-type pivots are considered for each direction — every pair among the last 3 highs and every pair among the last 3 lows is checked.
Lines carry two visual properties:
- Line color encodes direction. Bearish divergences (regular and hidden) draw in red; bullish divergences draw in green.
- Line style encodes type. Regular divergences (reversal signals) draw solid; hidden divergences (continuation signals) draw dashed.
Three oscillator options drive the detector. RSI (split H/L) uses RSI of highs for high pivots and RSI of lows for low pivots — the split captures the right extreme of each pivot type rather than the bar’s close. Stochastic (split H/L) does the same with Stochastic %K. External lets the user feed any TradingView series — any indicator’s output — for both pivot types separately. The External option is the most flexible: it makes ZZ Div + ST work with any oscillator the user prefers, not just the two built-in choices.
SuperTrend (Current Timeframe)
A standard hl2 ± factor×ATR trailing-band line that flips direction when price crosses through it. The line is drawn in yellow with breaks at every direction flip — the segment ending at the flip is not connected to the segment starting after.
SuperTrend (Higher Timeframe)
An optional second SuperTrend computed on a different (typically higher) timeframe via request.security. Off by default; enable it to layer a longer-horizon trend context on top of the current-timeframe SuperTrend. Both lines draw the same color (yellow) but their position and behavior differ — the higher-timeframe line moves more slowly and flips less frequently.
Reading two SuperTrends simultaneously: when both are below price (uptrend on both timeframes), strong uptrend with consensus. When both are above price (downtrend on both), strong downtrend. When they disagree (one above, one below), the timeframes are out of sync and the trade thesis depends on which one the trader weights.
3. Concepts You Need
This section covers the foundational concepts. Skip if you already know what ZigZag pivots, divergence types, and SuperTrend are.
Pivots and the ZigZag Algorithm
A pivot is a confirmed swing high or low — a price level where the trend changed direction by enough to be considered a meaningful turning point. The ZigZag algorithm formalizes this with a deviation threshold: a new pivot only confirms after price reverses by at least N% against the previous swing.
ZZ Div + ST’s deviation threshold defaults to 3%. Smaller values capture finer pivots and more noise; larger values capture only major turning points. Tuning depends heavily on timeframe and instrument volatility — 3% might be aggressive on a 5-minute chart of a stable forex pair, conservative on a 5-minute chart of a volatile crypto token.
Internally, the ZigZag uses a depth parameter of 1 — a minimum 2-bar local-extreme sanity check. All meaningful filtering is done by the deviation threshold rather than by requiring a long pivot-leg confirmation period. This produces more responsive pivots than the textbook ZigZag definition.
The Tip and Sliding
The most recent pivot is special — it’s “semi-confirmed” rather than fully locked. As the current swing develops, the tip can slide:
- If price keeps extending in the same direction, the tip moves to the new extreme.
- If price reverses by the deviation threshold, the tip locks in and becomes a confirmed pivot. The next swing begins.
The visible consequence: the most recent ZigZag segment and any divergence lines involving the tip can move as the live bar develops. This is intentional — pinning the tip to closed bars would leave the detector working on stale data while the chart’s most relevant action is the still-developing leg.
RSI and Stochastic, Split by Pivot Type
Both built-in oscillators use a split approach: a high pivot is compared against the oscillator computed from highs, and a low pivot is compared against the oscillator computed from lows.
- RSI (split H/L): standard Wilder’s RSI is computed twice — once on the candle highs (sampled at high pivots) and once on the candle lows (sampled at low pivots).
- Stochastic (split H/L): standard Stochastic %K is computed with high as the source for high pivots and with low as the source for low pivots — both still using the candle’s actual high/low for the range calculation.
The split captures the right edge of the bar for the pivot type being evaluated. At a high pivot, the relevant momentum is the magnitude of the upward push — best measured by comparing the new high against prior highs, not by the bar’s close. Same logic for low pivots.
The External Oscillator
Beyond the two built-in split oscillators, the indicator supports an “External” mode where the user plugs any TradingView series into the divergence detector — one series for high-pivot comparisons, one for low-pivot comparisons.
Common uses:
- CVD (Cumulative Volume Delta) — feed an externally-computed CVD series. Detects divergences between price and net aggression.
- Custom momentum or oscillator indicators — any indicator the user has built or imported can be plugged in.
- Volume-based series, OBV, MFI, etc. — any series that should diverge from price at meaningful turning points.
Set both External Source fields to the same series if your indicator has only one output (most do); use different series only when you have separate high-specific and low-specific oscillator series.
The Four Types of Divergence
Divergence describes a mismatch between price action and oscillator action at two same-type pivots:
- Bearish Regular: higher price high, lower oscillator high. Weakening upward momentum — often precedes reversal from up to down.
- Bullish Regular: lower price low, higher oscillator low. Weakening downward momentum — often precedes reversal from down to up.
- Bearish Hidden: lower price high, higher oscillator high. Continuation of an existing downtrend — the bounce is exhausted.
- Bullish Hidden: higher price low, lower oscillator low. Continuation of an existing uptrend — the pullback is exhausted.
Regular divergences are reversal signals; hidden divergences are continuation signals. Section 6 covers each in detail.
SuperTrend Mechanics
SuperTrend is a trailing-stop-style indicator following price at a distance proportional to ATR (Average True Range). When price trades above the trailing band, the line stays below price and moves up as price moves up; when price trades below the band, the line stays above and moves down. A direction flip occurs when price crosses through the line.
The trailing band sits at hl2 ± (factor × ATR). Lower factor = tighter band = more frequent flips. Higher factor = looser band = rarer, more significant flips. The default factor of 1.0 is aggressive; many traditional uses of SuperTrend use factor 2 or 3 for slower behavior.
Multi-Timeframe SuperTrend
PineScript’s request.security function lets the indicator pull data from a different timeframe than the chart’s. ZZ Div + ST uses this to compute an optional second SuperTrend at a user-chosen higher timeframe — the line plots on the current chart, but its underlying ATR and direction calculation use the higher-timeframe data.
Reading a higher-timeframe SuperTrend on a lower-timeframe chart: the line updates only when the higher timeframe’s bars close, so it changes less frequently than the current-timeframe line. This gives a slow, stable trend context that doesn’t flicker with intraday noise.
4. Setup and Reading the Output
Installation
ZZ Div + ST is a TradingView PineScript v6 indicator. Install via TradingView’s standard indicator-management workflow — copy the source into the Pine Editor and click “Add to Chart”.
Chart Compatibility
Works on any TradingView chart and any timeframe. The indicator reads standard candle data (high, low, close, volume) plus computes its own oscillators. No special chart type or data feed required.
Overlay vs Pane
ZZ Div + ST is an overlay indicator — all its elements draw directly on the price chart. ZigZag lines, pivot labels, divergence lines, and SuperTrend bands all sit on top of price bars, not in a separate pane below. This is different from divergence indicators that draw an oscillator pane and project divergences onto it.
Visual consequence: the chart can get busy when many features are enabled. Divergence lines drawn between pivot prices on the main chart cut across the price action. Use the toggles in the settings to enable only what you need at any moment.
Reading the ZigZag
Diagonal blue lines connecting confirmed pivots, with the most recent segment potentially sliding as the live bar develops. Labels at each pivot show whatever annotations are enabled (volume, price, price change). The deviation threshold determines how zig-zaggy the line is — at 1% it captures many minor swings; at 5-10% it captures only major turning points.
Reading Divergence Lines
Red solid line = bearish regular divergence (reversal hint, downward). Red dashed = bearish hidden (continuation, downward). Green solid = bullish regular. Green dashed = bullish hidden.
Each line connects two pivots — its endpoints are exactly at those pivot prices. The line goes diagonally across the price chart from one pivot to another. Multiple lines can appear simultaneously when several pivot pairs satisfy divergence conditions.
Lines persist as long as their endpoint pivots remain in the recent-pivot window (the most recent 3 highs and 3 lows). When a new pivot pushes older pivots out of that window, divergences involving the displaced pivots disappear.
Reading SuperTrend
Yellow trailing line. Below price during uptrends, above price during downtrends. Direction flips visible as gaps in the line — the indicator uses style_linebr (line break) plotting so the segment ending at a flip is not visually connected to the segment after. Easy to spot flip points at a glance.
When the higher-timeframe SuperTrend is enabled, two yellow lines appear simultaneously. The current-timeframe one moves with every chart bar; the higher-timeframe one updates only when the higher TF’s bars close — so it appears as a step-function relative to the current TF’s bars.
5. Settings Reference
Settings are organized into three groups in TradingView’s settings panel: an ungrouped ZigZag section at the top, the Divergence Check group, and the SuperTrend group. The reference below covers each group in the order it appears.
ZigZag (Ungrouped)
Top-level settings for the pivot detector and its annotations. These settings sit at the top of the panel without a group header.
Price Deviation Threshold for Pivots (%) Default: 3.0
Minimum percent move against the current swing required to confirm a new pivot. A new pivot commits when price has moved at least this percentage in the opposite direction from the current tip.
Smaller values produce more pivots and more responsive divergence detection at the cost of more noise. Larger values produce sparser, more significant pivots at the cost of missing smaller swings.
Tuning depends heavily on timeframe and instrument volatility. On a daily chart of a stable index, 2-5 might be appropriate. On a 5-minute chart of a volatile asset, 0.5-1.5 might be more appropriate. Range 0.1 to 50.
Line color Default: Blue (semi-transparent)
Color of the ZigZag connecting lines and the pivot labels. Set to match your chart theme.
Extend To Last Bar Default: On
When on, the most recent confirmed pivot extends a horizontal line forward to the live bar.
Useful as a visual reference for the active swing’s anchor — see where the last confirmed pivot sits relative to the current price.
Display Cumulative Volume Default: On
When on, each pivot label shows the cumulative volume traded between the previous pivot and this one.
Provides volume context per swing — see whether the leg into a pivot was driven by heavy or light participation.
Display Pivot Price Default: Off
When on, each pivot label shows the exact price at the pivot. Useful for precise reference; off keeps labels minimal.
Display Pivot Price Change In Default: Off
When on, each pivot label shows the price change from the previous pivot. The Percent/Absolute dropdown below controls the format.
Lets you read leg sizes at a glance.
Absolute / Percent (inline with Display Pivot Price Change) Default: Percent
When Display Pivot Price Change is on, this dropdown controls the format.
Percent: price change shown as a percentage of the prior pivot’s price.
Absolute: price change shown as raw price units (e.g., $1234 for a stock priced in dollars).
Only relevant when Display Pivot Price Change is on; ignored otherwise.
Divergence Check
Controls the divergence detection pipeline.
Enable Divergence Detector Default: On
Master toggle. Off disables divergence detection and removes all divergence lines from the chart. The ZigZag and SuperTrend layers continue to work normally.
Oscillator Default: RSI (split H/L)
Which oscillator drives the divergence detector. Three choices:
RSI (split H/L): standard Wilder’s RSI computed separately on highs (for high pivots) and lows (for low pivots).
Stochastic (split H/L): standard Stochastic %K computed with the same split.
External: two user-supplied series — one for high pivots, one for low pivots. Activates the External Source fields below.
Switching this dropdown does not require a chart reload — all oscillator flavors are computed every bar regardless of which is active, so the switch is instant.
Period Default: 6
Length used for the RSI or Stochastic oscillator. Ignored when Oscillator is External (the user-supplied series has its own internal periods).
Smaller periods produce more responsive but noisier oscillators. The default 6 is more responsive than the classic 14, calibrated for divergence detection where pivot-level responsiveness matters.
Range: minimum 1.
External Source (Highs / Lows) Default: close / close
When Oscillator is External, these two source dropdowns feed any TradingView series into the divergence detector — one for high-pivot comparisons, one for low-pivot comparisons.
Both default to close, which makes External mode functionally equivalent to comparing price against itself (no divergence will ever fire). The point is to override both with actual oscillator series.
Set both to the same series if your indicator has only one output (most oscillators do). Use different series only when you have separate high-specific and low-specific oscillator series.
Common uses: feed a CVD series, OBV, MFI, or any custom indicator’s output.
SuperTrend
Controls both SuperTrend instances — the current-timeframe primary and the optional higher-timeframe secondary.
Enable SuperTrend for Current TimeFrame Default: On
Toggle for the primary SuperTrend computed on the chart’s current timeframe. Off hides the line entirely and skips its computation.
ATR Length / Factor (primary) Default: 6 / 1.0
Two inline parameters for the primary SuperTrend.
ATR Length: period for the ATR calculation that drives the trailing band’s distance from price. Smaller values produce a tighter, more responsive band; larger values produce a looser, less reactive band. Default 6 is shorter than the textbook 14, calibrated for responsiveness on intraday timeframes.
Factor: multiplier applied to the ATR before adding/subtracting from hl2. The band sits at hl2 ± (factor × ATR). Smaller factors keep the band closer to price (frequent flips); larger factors push it further away (rarer flips). Default 1.0 is aggressive.
Enable SuperTrend for Higher Timeframe Default: Off
Toggle for the secondary SuperTrend computed on a user-chosen higher timeframe via request.security.
Off by default — the primary alone is sufficient for many use cases. Enable when you want trend context from a longer-horizon timeframe simultaneously displayed on the current chart.
Higher Timeframe Default: 60 (1 hour)
TradingView-format timeframe string for the secondary SuperTrend. “60” = 1 hour, “240” = 4 hours, “D” = daily, “W” = weekly, and so on.
Should be higher than the chart’s timeframe for the multi-timeframe analysis to be meaningful. Setting it equal to or lower than the chart’s timeframe doesn’t error, but defeats the purpose.
Only active when Enable SuperTrend for Higher Timeframe is on.
ATR Length / Factor (secondary) Default: 6 / 1.0
Same as the primary’s ATR Length / Factor but applied to the secondary’s calculation on the higher timeframe.
Can be tuned independently from the primary. A common pattern: primary is aggressive (low factor, short length) for responsive timing; secondary is slower (higher factor, longer length) for stable trend context.
Only active when Enable SuperTrend for Higher Timeframe is on.
6. Divergence Definitions in Detail
Four types of divergence lines, each carrying a different signal. Reading the chart effectively requires recognizing which type you’re looking at and what it implies.
Bearish Regular Divergence
Definition: between two high pivots, price made a higher high but the oscillator made a lower high.
Visual: solid red line connecting the two high pivots.
Interpretation: the second push to new price highs wasn’t backed by equivalent oscillator strength. The trend is showing signs of weakening at the top. Often precedes reversal from up to down. A frequent setup is the second high failing to hold and price rotating down through the lower high’s price level.
Bullish Regular Divergence
Definition: between two low pivots, price made a lower low but the oscillator made a higher low.
Visual: solid green line connecting the two low pivots.
Interpretation: the second push to new price lows wasn’t backed by equivalent oscillator weakness. The trend is showing signs of weakening at the bottom. Often precedes reversal from down to up. A frequent setup is the second low failing to hold and price rotating up through the higher low’s price level.
Bearish Hidden Divergence
Definition: between two high pivots, price made a lower high but the oscillator made a higher high.
Visual: dashed red line connecting the two high pivots.
Interpretation: in a downtrend, a corrective bounce produced a lower price high than the previous bounce, but the oscillator showed more thrust on the second bounce than on the first. The bounces are weakening relative to the underlying conditions — the downtrend is intact and likely to continue. Used as continuation confirmation.
Bullish Hidden Divergence
Definition: between two low pivots, price made a higher low but the oscillator made a lower low.
Visual: dashed green line connecting the two low pivots.
Interpretation: in an uptrend, a corrective pullback produced a higher price low than the previous pullback, but the oscillator showed deeper retracement on the second pullback than on the first. The pullbacks are getting absorbed into the broader uptrend — the uptrend is intact and likely to continue.
Pair Coverage
The detector evaluates every pair among the last three same-type pivots. With 3 highs and 3 lows in the recent window, that’s up to 6 high-high pairs and 6 low-low pairs being checked simultaneously. Multiple lines can appear at the same time if multiple pairs satisfy their respective divergence definitions.
As new pivots form and the window shifts, older pivots drop out and their associated divergences disappear from the chart. This keeps the visual focused on currently-relevant signals rather than accumulating historical lines indefinitely.
7. Practical Workflow
First Session With a New Instrument
Leave settings at default and observe the output through a meaningful range — ideally at least one full session of typical price action. Defaults are calibrated to produce a readable picture on most instruments.
After observing, evaluate by these criteria:
- ZigZag pivots are too dense, capturing every wiggle — raise Price Deviation Threshold (try 5 or 8 depending on instrument).
- ZigZag pivots are too sparse, missing meaningful swings — lower threshold (try 1.5 or 1.0).
- Divergence lines feel arbitrary or random — increase the oscillator Period. Try 12 or 14 for smoother divergence detection at the cost of fewer signals.
- SuperTrend flips too frequently — increase ATR Factor (try 2 or 3) or ATR Length (try 10 or 14).
- SuperTrend is unresponsive to clear trend changes — decrease ATR Factor (try 0.8 or 0.6) or ATR Length (try 4 or 5).
Using the External Oscillator
If you have a preferred custom oscillator — CVD, OBV, a custom indicator — feed it into the External oscillator option:
- Apply your custom indicator to the chart so its plot output is available.
- In ZZ Div + ST settings, change Oscillator to External.
- Set both External Source fields to your custom indicator’s plot output (use the same series for both unless you specifically have separate high/low variants).
- Divergence detection now uses your custom oscillator instead of RSI or Stochastic. Tuning the Period setting has no effect in External mode — the custom indicator’s own periods apply.
Layering the SuperTrends
Two SuperTrends simultaneously give multi-timeframe trend context on a single chart.
- Set the primary SuperTrend to aggressive settings (length 6, factor 1) for responsive flips on the current timeframe.
- Set the secondary to slower settings (length 10, factor 2) on a higher timeframe (e.g., chart on 15m, secondary on 1H or 4H).
- Read both lines together. When both lines are below price → strong uptrend across timeframes. When both above → strong downtrend. When they disagree → timeframe conflict, more cautious posture.
Combining With Other Tools
ZZ Div + ST identifies turning points, divergence between price and oscillator action, and trend direction across timeframes. It doesn’t generate explicit buy/sell signals or identify horizontal support/resistance levels. Practical use typically combines it with:
- Horizontal-level analysis — volume profile, prior-day extremes, key session levels — to identify where pivots fall relative to important price levels.
- Higher-timeframe market structure — swing highs/lows, trendlines — for directional bias confirmation.
- Volume or order-flow analysis — separate indicators that quantify participation behind pivots and trends.
This indicator excels at telling the trader “this turning point is weakening” or “this trend is intact through this pullback.” Combined with where price actually sits in the broader chart structure, it becomes a high-resolution timing tool.
8. Troubleshooting and FAQ
No divergence lines appear
Possible causes: the deviation threshold is so high that fewer than 2 same-type pivots exist in the recent window; divergence detection is disabled; the chart has too few bars loaded. Lower Price Deviation Threshold, check that Enable Divergence Detector is on, and ensure the chart has at least several hundred bars loaded.
External oscillator mode shows no divergences
Both External Source fields default to close. When Oscillator is set to External but the sources are left as close, the detector is comparing price against close — they’re effectively the same series and no divergence can exist. Change both External Source fields to actual oscillator series.
The most recent ZigZag segment keeps moving
Expected behavior. The tip (most recent pivot) is semi-confirmed until price reverses by the deviation threshold. During the live bar, the tip slides if price extends in the current direction. Once a reversal of sufficient magnitude confirms the tip, it stops moving and a new swing begins.
Divergence lines disappear as new pivots form
Expected. The detector considers only the most recent 3 same-type pivots. When a new pivot pushes an older one out of that window, divergences involving the displaced pivot are removed from the chart. This keeps the chart focused on currently-relevant signals.
Higher-timeframe SuperTrend updates infrequently
Expected. The higher-timeframe SuperTrend only updates when its underlying bars close — so on a 5-minute chart with a 1-hour higher TF, the secondary SuperTrend only changes every 12 chart bars. This is by design — it provides slow, stable trend context that doesn’t flicker with intraday noise.
SuperTrend line breaks in the middle
Expected. SuperTrend direction flips produce visible breaks in the line — the segment ending at a flip is not connected to the segment starting after. The style_linebr plotting style does this intentionally, making flip points easy to identify.
The chart is busy / overcrowded
ZZ Div + ST overlays everything on the price chart. With all features enabled simultaneously — ZigZag with all three label annotations, divergence detection drawing lines between many pivots, both SuperTrends active — the chart can get visually dense. Disable unused features. Common minimalist configurations: ZigZag + primary SuperTrend only; divergence + primary SuperTrend only; ZigZag with pivot price labels only.
Performance is sluggish on a deep chart history
PineScript indicators run on every bar. With max_bars_back set to 5000 in the source, the indicator processes a substantial history on load. If performance is a concern, modify the indicator() declaration to reduce max_bars_back, or accept that the initial load takes a moment. Subsequent live updates are fast.
9. Limitations and Design Notes
What This Indicator Does Not Do
- It does not generate buy or sell signals. Divergences and SuperTrend flips are interpretation suggestions, not commands.
- It does not predict price targets. The detector tells you the current swing or trend may be weakening or continuing; where price actually goes is an open question.
- It does not identify horizontal support/resistance levels. Pivots are temporal turning points, not horizontal level definitions. Use a separate level-detection indicator for level-based analysis.
- It does not weight divergences by strength. Every detected divergence displays with equal visual weight — the trader determines significance from context.
The Three-Pivot Window
Divergence detection considers only the most recent 3 same-type pivots. This is a deliberate constraint that keeps the chart focused on currently-relevant signals. Older pivots fall out of the window naturally as new ones form.
Tip Sliding
The most recent pivot can slide forward in both bar and price during the live bar as price extends or retraces. The current ZigZag segment and any divergence lines involving the tip are visually mobile until the tip finalizes by a confirming reversal. The behavior is intentional — pinning the tip to closed bars would leave the detector working on stale data.
Why RSI and Stochastic Are Split
The conventional RSI uses bar closes; the conventional Stochastic uses close relative to high/low range. Both built-in oscillators here are split — RSI of highs for high pivots, RSI of lows for low pivots; stochastic with high source for high pivots, stochastic with low source for low pivots.
The rationale: at a high pivot, the relevant momentum is the magnitude of the upward push, best captured by comparing the new high against prior highs. At a low pivot, the relevant momentum is the magnitude of the downward push. The split samples the right edge of the bar for the pivot type being evaluated, matching how price actually moves into pivots.
The External Oscillator Option
Adding External as a third oscillator option makes ZZ Div + ST flexible beyond the two built-in choices. The user can plug any TradingView series into the divergence detector — making this indicator usable with custom oscillators, CVD series, OBV, MFI, or any other indicator’s output. This goes beyond what most divergence indicators offer.
The cost: External mode requires the user to set both External Source fields explicitly. Forgetting to set them leaves the detector comparing close to close, producing no divergences. A first-time user might assume something is broken when really the source needs to be set.
Why Two SuperTrends
PineScript’s request.security function makes it possible to overlay a higher-timeframe indicator on a lower-timeframe chart. The secondary SuperTrend uses this — same SuperTrend logic, different timeframe, drawn on the same chart.
Two SuperTrends on one chart provides multi-timeframe trend context without leaving the current chart. The lower-timeframe primary captures immediate trend; the higher-timeframe secondary captures broader trend. Agreement between them is strong directional context; disagreement is timeframe conflict — both useful information for the trader.
Closing Note
ZZ Div + ST gives the trader visibility into the rhythm of price action on the chart itself — where turns happen, when they’re losing or gaining underlying support, and which direction the prevailing trend (or trends, with the multi-timeframe option) is following. It does not say what to trade or when. Used well, it adds a layer of timing precision to chart reading that complements the broader analytical framework — pivot-based timing combined with level-based positioning is a stronger framework than either alone.