Similar to a supertrend in many aspect, this indicator act as a trend following system by itself. Based on a 89 Weighted moving average by default, the trend reverse is triggered by the crosses of the high or low with the Aktivator line. I changed a bit the RETURN instruction to show 2 different colors.
//parameters
// x = 89
// gg = 4
// rr = 11
// factor = 1
a = round(WeightedAverage[x](close))
green = a[round(x/gg)]
red = a[round(x/rr)]
if red > green then
up1 = red
dn1 = green
elsif red < green then
up1 = green
dn1 = red
endif
atr = AverageTrueRange[14](close)
up = up1+(atr*factor)
dn = dn1-(atr*factor)
once trend=1
if high>up[1] then
trend=1
elsif low<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=up1+(atr*factor)
endif
if flagh=1 then
dn=dn1-(atr*factor)
endif
if trend=1 then
super=dn
else
super=up
endif
return super coloured by trend as "89WMA Aktivator"
//Indicator form the Kevin Britains archive.