indicator · on price · open source

Swing High/Low with Pivots

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

About

Swing pivots — confirmed swing highs and lows marked with H/L labels. Same engine as the ZigZag, but with explicit character labels.

  • swing controls how many bars each side of the pivot must dominate.
  • Lines persist using linebr style so you can see the stair-step of the market.
  • Use as the foundation for any structure-based system.

Source code

//@version=5
indicator("Swing High/Low with Pivots", overlay=true)
swing = input.int(5, "Swing Length", minval=2, maxval=50)
ph = ta.pivothigh(high, swing, swing)
pl = ta.pivotlow(low, swing, swing)
hiLine = ta.valuewhen(not na(ph), ph, 0)
loLine = ta.valuewhen(not na(pl), pl, 0)
p_Pivot_High = plot(hiLine, "Pivot High", color=color.green, style=plot.style_linebr, linewidth=2)
p_Pivot_Low = plot(loLine, "Pivot Low", color=color.red, style=plot.style_linebr, linewidth=2)
plotshape(not na(ph), "Swing High", style=shape.labeldown, location=location.abovebar, color=color.green, text="H")
plotshape(not na(pl), "Swing Low", style=shape.labelup, location=location.belowbar, color=color.red, text="L")
alertcondition(not na(ph), "Swing High", "New swing high confirmed")
alertcondition(not na(pl), "Swing Low", "New swing low confirmed")

Comments

No comments yet.

Sign in to comment.