Code Library / Supertrend

Pine Script MTF Supertrend

Multi-timeframe Supertrend showing trend from multiple TFs.

Language: Pine Script · Category: Supertrend · Tags: supertrend, multi-timeframe, Pine Script, confluence, MTF

Source code

//@version=5
indicator("MTF ST",overlay=true)
[s1,d1]=ta.supertrend(3,10)
[s2,d2]=request.security(syminfo.tickerid,"60",ta.supertrend(3,10))
[s3,d3]=request.security(syminfo.tickerid,"240",ta.supertrend(3,10))
bgcolor(d1<0 and d2<0 and d3<0?color.new(color.green,90):na)
plot(d1<0?s1:na,"Up",color.green,2,plot.style_linebr)
plot(d1>0?s1:na,"Dn",color.red,2,plot.style_linebr)

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.

Related snippets