indicator · on price · open source

Pivot Trend

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

About

Pivot Trend colours bars green when price is trapped between the most recent pivot low and pivot high (the active swing range) and red when it breaks out.

  • Useful for visualising when the market is range-bound vs breaking structure.
  • A break of the range on strong volume often leads to the next leg.

Source code

//@version=5
indicator("Pivot Trend", overlay=true)
swing = input.int(5, "Swing Strength", minval=2)
ph = ta.pivothigh(high, swing, swing)
pl = ta.pivotlow(low, swing, swing)
lastPh = ta.valuewhen(not na(ph), ph, 0)
lastPl = ta.valuewhen(not na(pl), pl, 0)
trend = close > lastPl and close < lastPh ? 1 : 0
barcolor(trend ? color.green : color.red)
alertcondition(trend and not trend[1], "Inside range", "Price re-entered the active pivot range")
alertcondition(not trend and trend[1], "Out of range", "Price broke out of the active pivot range")

Comments

No comments yet.

Sign in to comment.