New “extended” version of the classic Supertrend indicator.
The Supertrend band is made from the supertrend itself (which can be calculated from 3 different manner) and from 1 Average True Range value above or below it, depending of the direction of the price.
There are 3 different type of the Supertrend Extendend calculation: (you can choose which one with the “type” parameter).
All these values are multiplied by the “multiplier” settings to extend or narrow the band. These indicators share the same “period” setting.
The indicator also uses the mean of the price over the last “midperiod”, instead of the Close (middle of a Donchian channel or just like a Kijun from Ichimoku).
//PRC_SuperTrend Extended | indicator
//31.10.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- settings
//multiplier=2.236
//period=66
//type=1 //1 = use ATR , 2 = Use standard deviation , 3 = Use standard error
//midperiod=10
// --- end of settings
type=max(1,type)
if type=1 then
moy=averagetruerange[period](close)
elsif type=2 then
moy=std[period](close)
elsif type=3 then
moy=ste[period](close)
endif
price=(highest[midperiod](high)+lowest[midperiod](low))/2
up=price+multiplier*moy
dn=price-multiplier*moy
once trend=1
if close>up[1] then
trend=1
elsif close<dn[1] then
trend=-1
endif
if trend<0 and trend[1]>0 then
flag=1
else
flag=0
endif
if trend>0 and trend[1]<0 then
flagh=1
else
flagh=0
endif
if trend>0 and dn<dn[1] then
dn=dn[1]
endif
if trend<0 and up>up[1] then
up=up[1]
endif
if flag=1 then
up=price+multiplier*moy
endif
if flagh=1 then
dn=price-multiplier*moy
endif
if trend=1 then
mysupertrend=dn
offset=moy
color1=0
color2=191
color3=255
else
mysupertrend=up
offset=-moy
color1=255
color2=69
color3=0
endif
drawcandle(mysupertrend,mysupertrend+offset,mysupertrend,mysupertrend+offset) coloured(color1,color2,color3,50)bordercolor(100,100,100,0)
if trend=1 and trend[1]<>1 then
drawarrowup(barindex,mysupertrend) coloured(color1,color2,color3)
endif
if trend=-1 and trend[1]<>-1 then
drawarrowdown(barindex,mysupertrend) coloured(color1,color2,color3)
endif
return mysupertrend coloured (color1,color2,color3) as "SuperTrend Extended 1", mysupertrend+offset coloured (color1,color2,color3) as "SuperTrend Extended 2"