indicator · on price · open source

Supertrend

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

About

Classic Supertrend: ATR-based bands that flip direction with the trend — green line under price in an uptrend, red above in a downtrend.

  • Flip points are marked with triangles and alert on both sides.
  • Raise the factor for fewer, longer trends; lower it for faster flips.
  • Works on any market; a 3.0x factor on the daily is the standard starting point.

Source code

//@version=5
indicator("Supertrend", overlay=true)
atrLen = input.int(10, "ATR Length", minval=1)
factor = input.float(3, "Factor", minval=0.5, step=0.1)
[st, dir] = ta.supertrend(factor, atrLen)
up = dir < 0
p_Up_Trend = plot(up ? st : na, "Up Trend", color=color.green, style=plot.style_linebr, linewidth=2)
p_Down_Trend = plot(up ? na : st, "Down Trend", color=color.red, style=plot.style_linebr, linewidth=2)
plotshape(up and not up[1], "Flip Up", style=shape.triangleup, location=location.belowbar, color=color.green, text="↑")
plotshape(not up and up[1], "Flip Down", style=shape.triangledown, location=location.abovebar, color=color.red, text="↓")
alertcondition(up and not up[1], "Trend turns up", "Supertrend flipped bullish")
alertcondition(not up and up[1], "Trend turns down", "Supertrend flipped bearish")

Comments

No comments yet.

Sign in to comment.