indicator · on price · open source

ZigZag

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

ZigZag connects confirmed swing highs and swing lows with a line so you can see the market's actual swings free of noise.

  • Lines redraw for len bars while a new pivot is forming, then settle.
  • Use to anchor Fibonacci retracements or to mark structural breakouts.
  • Not predictive on its own — purely a visualisation of confirmed swings.

Source code

//@version=5
indicator("ZigZag", overlay=true)
len = input.int(10, "Swing Length", minval=2)
pivHi = ta.pivothigh(high, len, len)
pivLo = ta.pivotlow(low, len, len)
p_ZZ_Hi = plot(pivHi, "ZZ Hi", color=color.green, style=plot.style_linebr)
p_ZZ_Lo = plot(pivLo, "ZZ Lo", color=color.red, style=plot.style_linebr)
plotshape(not na(pivHi), "Swing High", style=shape.labeldown, location=location.abovebar, color=color.green, text="H")
plotshape(not na(pivLo), "Swing Low", style=shape.labelup, location=location.belowbar, color=color.red, text="L")

Comments

No comments yet.

Sign in to comment.