Specifiche
Below you can find the metastock code of the moving average trailing profit/stop indicator. I tried it and its working on metastock.
I am planning to use it on my current EA which is running on Mt4 and also utilizing it as an indicator .
INDICATOR FORMULA:
percentage:=Input("% stop",0,10,2); period:=Input("period",1,100,3);
a1:=Mov(C,period,E);
a2:=a1-(a1*percentage/100);
a3:=a1+(a1*percentage/100);
b1:=If(a1<PREV,a2,if(a2>PREV,a2,PREV));
b2:=If(a1>PREV,a3,if(a3<PREV,a3,PREV));
k1:=Cross(a1,Ref(b2,-1));
k2:=Cross(Ref(b1,-1),a1);
s1:=BarsSince(k1) < BarsSince(k2);
s2:=If(s1=-1,b1,b2); a1;s2
In above formula ;
a1: Represents the exponential moving average value;
s2: Represents the MOST value.
And in EA
when "s2" crossed above "a1" it should close the long position;
when "s2" crossed below "a1" it should close the short position.
Thats all, thanks