indicator · on price · open source
Supertrend Pro
Running…
Loading chart…
About
Classic Supertrend (ATR bands that flip with the trend) with the flip points marked and alerts on both sides.
- Green line under price = uptrend, red above = downtrend.
- Raise the factor for fewer, longer trends; lower it for faster flips.
- Works on any market; try 4h on majors and gold.
Source code
//@version=5
indicator("Supertrend Pro", overlay=true)
atrLen = input.int(10, "ATR length", minval=1)
factor = input.float(3.0, "Factor", minval=0.5, step=0.1)
[st, dir] = ta.supertrend(factor, atrLen)
up = dir < 0
plot(up ? st : na, "Up trend", color=color.green, linewidth=2, style=plot.style_linebr)
plot(up ? na : st, "Down trend", color=color.red, linewidth=2, style=plot.style_linebr)
flipUp = up and not up[1]
flipDown = not up and up[1]
plotshape(flipUp, "Turns up", style=shape.triangleup, location=location.belowbar, color=color.green)
plotshape(flipDown, "Turns down", style=shape.triangledown, location=location.abovebar, color=color.red)
alertcondition(flipUp, "Supertrend turns up", "Supertrend flipped bullish")
alertcondition(flipDown, "Supertrend turns down", "Supertrend flipped bearish")
No comments yet.
Sign in to comment.