ZigZag Confluence [Probalist Essentials]ZigZag Confluence draws swing structure with a clear line between what is settled and what is still moving. A confirmed leg is solid and does not redraw once it forms; the developing leg is dashed and labelled, so you can tell the fixed structure from the live edge at a glance. It is non-repainting where it counts: the part that genuinely cannot be final yet is shown as provisional, not dressed up as done. Every confirmed pivot carries a two-line balloon (the signed %-change of the leg and the pivot price) plus a weighted dot sized by how big the completing leg was relative to history. An optional marker shows the bar each pivot actually confirmed, so the confirmation lag — the cost of not repainting — is there to see rather than hidden.
And it keeps score. Over a fixed window after each confirmed pivot it records three things per direction: the favorable run (MFE — how far the move travelled your way), the adverse heat (MAE — how far it went against you first), and the net return at the end of the window. The run and heat percentiles project forward from the live pivot as stop/target rails — the favorable target in the leg's colour, the stop in the opposite — and the favorable-run distribution is drawn as a bell to the right of the chart. The edge verdict is judged separately, on the net follow-through: was it reliably positive on this chart's own history, with a Wilson-bounded win rate? Description, not prediction — and the code is open, so you can count it yourself.
🟡 WHY THIS VERSION
Most ZigZag indicators redraw their last leg silently — they look perfectly timed in hindsight because they were. This one doesn't: confirmed pivots are frozen the moment they form and never move, the developing leg is dashed with the lag spelled out, and an optional ✓ marker shows the exact bar each pivot became actionable. The other thing worth having is that it keeps score where it matters for a swing tool. Instead of a static pivot count, it measures — over a real holding window — how far past legs ran in your favour, how much heat they took first, and whether the net follow-through actually held. You get stop/target rails sized from that history and an honest edge read: a range and a verdict, not a guarantee. And the confirmation timeframes and the HTF overlay derive from your chart, so the multi-timeframe confluence means something on a 5-minute chart as much as on a daily.
🟡 HOW IT WORKS
The pivot detection uses a scale-free ATR threshold: price must reverse from a running extreme by at least k × ATR(14) before the extreme is frozen as a confirmed pivot. A fixed-percentage threshold breaks on low-priced assets and behaves differently in high-volatility regimes; the ATR multiple adjusts naturally. A minimum 'depth' in bars adds a secondary filter so very brief wicks don't confirm pivots on noisy markets.
Once a pivot is confirmed, a solid coloured leg is drawn from the previous pivot (gold for up-legs, blue for down-legs), a two-line balloon labels it, and a weighted dot marks the confirmation bar. The developing leg — from the most recent confirmed pivot to the current running extreme — is drawn dashed and updated every bar. It may extend or be replaced; this is explicitly the confirmation trade-off made visible, not a repaint. The classic ZigZag's flaw is that it draws this same provisional leg as if it were final and then silently redraws it — which is exactly why it looks flawless on historical bars; separating confirmed (solid, frozen) from developing (dashed, labelled) is the honest fix.
It then keeps score over a fixed horizon after each confirmed pivot. For every signal it tracks the running favorable excursion (MFE) and adverse excursion (MAE) from the entry anchor, and the net return once the horizon completes — recorded only on closed bars, non-repainting by construction. A single ZigZag leg is monotonic, so the heat within one leg is near zero; the fixed window is what captures real adverse movement, including pivots that fail and reverse. The run and heat percentiles size the projected stop/target rails — the stop sits at the 90th-percentile heat, because the median heat is ~0 (most entries take no drawdown below them) and the real risk lives in the tail. The edge verdict is judged on the net return: the Wilson-score lower bound of the share of positive-net pivots, with the recent window catching regime shifts faster than the full history. The favorable-run distribution is drawn as a kernel-smoothed bell to the right of the chart. Two anchor modes: Confirmation (the realistic entry, with real heat) and Pivot extreme (the idealized ceiling — anchored at the exact swing, so net is positive by construction and the edge read is suppressed as not meaningful there).
🟡 KEY FEATURES
Honest two-tone rendering: confirmed legs solid and permanent, the developing leg dashed and labelled — the distinction is explicit, not hidden. An optional marker shows the exact bar each pivot confirmed (the lag = the price of not repainting).
ATR-scaled reversal threshold: scale-free across assets, adjusts to volatility regimes automatically. A depth-in-bars filter rejects brief wicks.
Per-pivot two-line balloon labels: signed %-change on top, pivot price below, leg duration in the hover tooltip.
Weighted signal dots sized by leg-size percentile (self-calibrating 60th/90th tiers), carrying an evidence glyph: ● recent net-backed · ◐ has stats but not backed · ○ gathering. A ◈ prefix marks pivots that land at a prior confirmed pivot level — a fixed, tight invalidation (geometry, not extra probability).
Excursion read per direction: over a fixed horizon after each pivot it measures the favorable run (MFE) and the adverse heat (MAE), projected forward from the live pivot as stop/target rails — favorable target in the leg's colour, the stop (90th-percentile heat) in the opposite. The favorable-run distribution is drawn as a kernel-smoothed bell with the live leg's percentile marked.
Honest net-edge verdict: judged on the net return at the horizon (not the trivially-positive run), with a Wilson-score lower bound, a recent-vs-long-run read and a dual edge-clock. Suppressed under the pivot-extreme anchor, where net is positive by construction and labelled the idealized ceiling, not an edge.
Evidence-gated alerts: standard and net-history-backed variants of bull/bear pivot confirmations, plus BOS/CHoCH and pivot-at-prior-level — all non-repainting (bar-close vs pre-fixed levels).
MTF ✓-badges with auto-derived rungs: the confirmation timeframes come from your chart (the next steps up the ladder 1·5·15·60·240·D·W·M, so a 5m chart checks 15m/1h/4h, not D/W; change the chart TF and the rungs follow). When a higher TF later confirms the same swing, the balloon is stamped (e.g. ✓4h) — confluence shown when it actually exists, never before, since a higher timeframe confirms later by construction.
Ghost pivots: faint ● dots in the accent colours (gold = a would-be swing high, blue = a would-be swing low) at superseded extremes that stood at least the confirmation depth before price pushed through — every spot where a repainting ZigZag would have printed a pivot and silently erased it. The honest counterpart of never repainting.
Market structure layer: every balloon tagged HH/HL/LH/LL, with BOS and CHoCH flagged when a bar closes beyond the last confirmed swing level — the level is fixed before the break, so the call is non-repainting by construction.
Optional HTF ZigZag overlay with the same auto-derived ladder (two rungs up the chart): a thin dotted higher-timeframe structure for context. Display only — it never filters or alters signals.
🟡 HOW TO USE
Use confirmed (solid) legs as your structure reference: they define swing highs and lows that won't move. A sequence of higher lows on solid lines is an uptrend; lower highs is a downtrend.
Treat the dashed developing leg as provisional — its endpoint updates every bar. The 'confirms X' trigger level shows the close that would confirm it; the optional confirmation-bar marker shows, after the fact, how many bars the confirmation lagged the extreme. That lag is the honest cost of non-repainting structure.
Read the stop/target rails on the active developing leg: the favorable target is the median (and 75th-percentile) run past legs made in this direction; the stop rail sits at the 90th-percentile heat — beyond where the normal adverse move stayed on ~90% of past legs. The reward:risk on the label is descriptive of this chart, not a promise.
Use the net-edge read as context, not an entry trigger. A 'net follow-through reliably positive' verdict means past pivots here held up on a Wilson-bounded majority — weigh it against fees, spread and your holding period before acting.
Check the developing leg's percentile in the favorable-run distribution: a leg already at the 85th percentile is well-extended by historical standards and may be closer to a pivot than a fresh one at the 20th.
Costs honesty: pivot signals on low timeframes can show a tiny median net (e.g. +0.10–0.30% over the horizon). On most venues that does not survive round-trip costs — use the read for directional bias and higher-timeframe confluence, not as a standalone scalp entry.
Size alerts around the evidence tier: the 'history-backed' alert variants fire only when the recent net clears the Wilson threshold; standard alerts fire on every confirmation. Use the backed variant for stronger-filter setups.
Anchor choice: keep Confirmation (default) for the tradeable read — the entry you could actually take, with its real heat. Switch to Pivot extreme only to see the idealized ceiling (full run, ~zero heat); the edge verdict is intentionally suppressed there because net is positive by construction.
Enable Show HTF ZigZag for the higher-timeframe structure as a thin dotted overlay (the timeframe auto-derives from your chart). Chart-timeframe pivots that align with an HTF leg in the same direction carry more structural weight — and the MTF ✓-badges quantify exactly that. Display only; it never filters or alters signals.
🟡 PAIRS WELL WITH
ZigZag structure tells you where the swings are but not what drives them. A momentum oscillator like RSI or MACD adds a read on whether momentum is confirming the swing — a swing low into an OS zone with divergence is a more complete setup than a pivot alone. A volume indicator helps distinguish pivots that occurred on meaningful participation from low-volume reversals. For trend bias, a moving average or Supertrend on a higher timeframe filters which pivot direction to trade with versus against. Key S/R levels (daily highs/lows, prior swing clusters) give the structural context this tool measures but doesn't assess quality-wise — a confirmed pivot at a prior level is a different read than one in open air.
ZigZag Confluence gives you swing structure you can trust: pivots that don't move after the fact, a developing leg that tells you honestly it's still forming, and an excursion read that shows what this chart has actually done after past pivots — how far they ran, how much heat they took, and whether the net follow-through held — not what a backtest on a different instrument claims. The rails and the distribution are displays, not filters; the trader reads the evidence and decides.
Open source under MPL-2.0. The probability layer describes past signals on your chart — it is a measurement, not a prediction, and nothing here is financial advice.
Chỉ báo Pine Script®






















