Supertrend Indicator

noumann

Newbie
Messages
1
Likes
0
Hi everyone.I'm studying the supertrend indicator.I found an excellent formula but it's in bullcharts language.Can someone help me to translate it in metastock language?The code is:
{==== BullScript ====}

[Description="SuperTrend - Max"]
[target=price]
Mult:=Input("ATR Multiplier",3,1);
Nb:=Input("Nb Periods",8,1);
method:=inputma("Method",Wilders);
price:=Input("1=Median, 2=Close",1,1);
TruRan:=ma(ATR(1),Nb,method)*Mult;
HiLimit:=if(price=1,(H+L)/2-TruRan,C-TruRan);
LoLimit:=if(price=1,(H+L)/2+TruRan,C+TruRan);
LB:=If(HiLimit>=PREV and HiLimit<C,HiLimit,If(C<PREV,HiLimit-0.1,PREV));
UB:=If(LoLimit<PREV and LoLimit>C,LoLimit,If(C>PREV,LoLimit+0.1,PREV));
Trend:=if(UB>ref(UB,-1),1,if(LB<ref(LB,-1),-1,prev));
[drawundefined=gap]
[Color=lime green]
if(Trend=1 and hist(Trend,1)=-1,LB,if(Trend=-1,UB,undefined));

if(Trend=-1 ,UB,if(hist(Trend,1)=1 ,LB,undefined));
[Color=lime green]
if(Trend=1 or Trend=0,LB,undefined);
{ Paint bars}
Flag:=input("PaintBars On=1, Off=0",0,0,1);
[linestyle=pricecolor; color=rgb(98,217,98)]
If(Trend=1 and Flag=1,1,if(Flag=0 and C>O,1,undefined));
{red}
If(Trend=-1 and Flag=1,1,if(Flag=0 and C<=O,1,undefined));

Thanks in advance
 
Top