//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)
Signal = 0
if trend=1 and trend[1]<>1 then
Signal = 1
//drawarrowup(barindex,mysupertrend) coloured(color1,color2,color3)
endif
if trend=-1 and trend[1]<>-1 then
Signal = -1
//drawarrowdown(barindex,mysupertrend) coloured(color1,color2,color3)
endif
return Signal