definition of variables periods and multiplie instead of 10 and 3
//inputs
periods = 10 //ATR period
multiplier = 3 //ATR multiplier
changeATR = 1 //Change ATR Calculation Method ?
Showsignals = 1 //Show Buy/Sell Signals ?
highlighting = 1 //Highlighter On/Off
///////////////////
atr = averagetruerange[periods](close)
up = high – multiplier*atr
up1 = up[1]
if close[1] > up1 then
up = max(up,up1)
else
up = up
endif
dn = low + multiplier*atr
dn1 = dn[1]
if close[1] < dn1 then
dn = min(dn,dn1)
else
dn = dn
endif
once trend = 1
if trend = -1 and close > dn1 then
trend = 1
elsif trend = 1 and close < up1 then
trend = -1
else
trend = trend
endif
if trend = 1 then
mysupertrend = up
r=0
g=255
b=0
else
mysupertrend = dn
r=255
g=0
b=0
endif
buysignal = trend=1 and trend[1]=-1
sellsignal = trend=-1 and trend[1]=1
if buysignal then
drawtext(“▲”,barindex,mysupertrend)coloured(“green”)
drawtext(“Buy”,barindex,mysupertrend-0.3*tr)coloured(“green”)
elsif sellsignal then
drawtext(“▼”,barindex,mysupertrend)coloured(“red”)
drawtext(“Sell”,barindex,mysupertrend+0.3*tr)coloured(“red”)
endif
mplot = (open+close+high+low)/4
colorbetween(mplot,mysupertrend,r,g,b,40)
return mysupertrend coloured(r,g,b)style(line,2)