Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 10/16/2009(UTC) Posts: 34
|
henry,
i can't translate in ms language your mql4 code.But i've found this version on bullcharts forum:
[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));
[Color=red]
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));
[color=rgb(226,118,118)] {red}
If(Trend=-1 and Flag=1,1,if(Flag=0 and C<=O,1,undefined));
I'm trying to translate it in ms language as follows:
Mult:=Input("ATR Multiplier",0.1,10,3);
Nb:=Input("Nb Periods",1,30,8);
TruRan:=Mov(ATR(1),Nb,w)*Mult;
HiLimit:= (H+L)/2-TruRan;
LoLimit:= (H+L)/2-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));
if(Trend=1 and Ref(Trend,1)=-1,LB,if(Trend=-1,UB,undefined));
if(Trend=-1 ,UB,if(Ref(Trend,1)=1 ,LB,undefined));
if(Trend=1 or Trend=0,LB,undefined);
But "undefined" is not a ms function.
Any suggestions?
Thank you
|