Code Library / Supertrend
Pine Script Supertrend
Classic Supertrend with buy/sell signals.
Language: Pine Script · Category: Supertrend · Tags: supertrend, Pine Script, ATR, trend following, indicator
Source code
//@version=5
indicator("Supertrend",overlay=true)
[st,dir]=ta.supertrend(3.0,10)
plot(dir<0?st:na,"Up",color.green,2,plot.style_linebr)
plot(dir>0?st:na,"Dn",color.red,2,plot.style_linebr)
plotshape(dir[1]>0 and dir<0,"Buy",shape.triangleup,location.belowbar,color.green)
plotshape(dir[1]<0 and dir>0,"Sell",shape.triangledown,location.abovebar,color.red)How to use this snippet
This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.