indicator · on price · open source
Supertrend indicator
Supertrend is a free open-source indicator by @deepwick. Classic Supertrend: ATR-based bands that flip direction with the trend — green line under… Deepwick Script runs a subset of Pine Script.
Running…
Loading chart…
What Supertrend does
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
Deepwick Script, a subset of Pine Script · read-only
//@version=6
indicator("Supertrend", overlay=true)
atrLen = input.int(10, "ATR Length", minval=1, maxval=50)
factor = input.float(3, "Factor", minval=0.5, maxval=10, step=0.1)
colorUp = input.color("color.green", "Color Up")
colorDown = input.color("color.red", "Color Down")
[st, dir] = ta.supertrend(factor, atrLen)
up = dir < 0
p_Up_Trend = plot(up ? st : na, "Up Trend", color=colorUp, style=plot.style_linebr, linewidth=2)
p_Down_Trend = plot(up ? na : st, "Down Trend", color=colorDown, style=plot.style_linebr, linewidth=2)
plotshape(up and not up[1], "Flip Up", style=shape.triangleup, location=location.belowbar, color=colorUp, text="↑")
plotshape(not up and up[1], "Flip Down", style=shape.triangledown, location=location.abovebar, color=colorDown, 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")
No comments yet.
Sign in to comment.