ZigZag
By LuxAlgoApr 13, 2020
The ZigZag connects successive swing highs and swing lows with straight line segments, discarding every countermove smaller than a set threshold so only the larger swings in price remain visible. Defaults are a 5% deviation filter with a pivot depth of 10 bars, and — as in any faithful zigzag — the most recent leg stays provisional, extending to each new extreme until the next pivot is confirmed. This is the standard raw construction: no labels, no ratios, just the chart reduced to alternating legs.
Once candles collapse into legs, structure that hides in bar noise — trend sequence, swing levels, pattern shapes — becomes explicit and measurable.
How to Trade the ZigZag?
- Rising pivots: successive higher swing highs and higher swing lows define an uptrend; the read holds until a confirmed pivot breaks the sequence.
- Falling pivots: lower highs and lower lows mark the downtrend; the first pivot violating the sequence is an early structural warning.
- Confirmed pivot levels: support and resistance references, stop placements behind structure, and anchors for measuring a completed leg.
- The live leg: treat the newest segment as unfinished — its endpoint follows price until the reversal criteria are met.
The tool draws structure rather than entries — it decides which swings count at your chosen scale.
ZigZag Settings
- Deviation (%) (default 5): the minimum reversal from the running leg extreme, as a percentage of that extreme, required to confirm a pivot. Raise it to keep only major swings; lower it to expose finer structure.
- Depth (default 10): the minimum number of bars required between two consecutive pivots, blocking rapid pivot alternation even when the percentage threshold is met.
- Line / Width (default width 2): purely visual — the color and thickness of the segments.
Frequently Asked Questions
Which parts of the ZigZag repaint?
Only the final leg. A pivot confirms once price reverses from the leg extreme by the full deviation with the depth spacing satisfied; until then, the last segment's endpoint slides to every new extreme. Confirmed pivots never move afterward.
How do Deviation and Depth work together?
A candidate pivot must clear both gates: the countermove has to reach the Deviation percentage, and the new pivot must sit at least Depth bars after the previous one. If the zigzag skips swings you care about, lower Deviation; if it flickers on choppy charts, raise Depth.
When do the alerts fire?
New Swing High and New Swing Low fire on the confirmation bar — the first moment a pivot is knowable — not at the extreme where the pivot is later drawn. Since pivots are placed retroactively, systematic use should anchor to confirmation rather than the plotted extreme.
Free indicator
Get free access to this indicator on the platforms below.
The Library is free. Quant makes it yours.
Pull any concept or indicator into Quant: rebuild it, retune it, or turn it into a backtested strategy of your own.