Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 10/16/2009(UTC) Posts: 34
|
Hello everyone,
i'm tryiing to convert in metastock language the modified FRAMA formula.The process is indicated here http://etfhq.com/blog/2010/09/30/fractal-adaptive-moving-average-frama/
The original FRAMA formula is:
y:=Input("sample time periods",1,1000,8);
y2:=2*y;
n1:=(HHV(H,y)-LLV(L,y))/y;
n2:=Ref((HHV(H,y)-LLV(L,y))/y,-y);
n3:=(HHV(H,y2)-LLV(L,y2))/y2;
x:=(Log(n1+n2)-Log(n3))/Log(2);
xt:=Exp(-4.6*(x-1));
x1:=If(xt<0.01,0.01,If(xt>1,1,xt));
x2:=1-x1;
If(Cum(1)=y2,
(C * x1) + (Ref(C,-1) * x2),
(C * x1) + (PREV * x2))
My modified FRAMA formula is:
y:=Input("sample time periods",1,1000,63);
Len:=Input("Lentaped",1,1000,252);
Vel:=Input("Veloceped",1,1000,126);
a:=(Len-Vel)/2;
pd:=If(a=Int(a),a,Int(a)+1);
ped:=pd+Vel;
y2:=2*y;
n1:=(HHV(H,y)-LLV(L,y))/y;
n2:=Ref((HHV(H,y)-LLV(L,y))/y,-y);
n3:=(HHV(H,y2)-LLV(L,y2))/y2;
x:=(Log(n1+n2)-Log(n3))/Log(2);
b:=Log(2/(Len+1));
xt:=Exp(b*(x-1));
OrN:=(2-xt)/xt;
NewN:=((Len-Vel)*((OrN-1)/(Len-1)))+Vel;
Newxt:=2/(NewN+1);
x1:=If(Newxt<(2/(Len+1)),2/(Len+1),If(Newxt>1,1,Newxt));
x2:=1-x1;
If(Cum(1)=y2,
(C * x1) + (Ref(ExtFml( "Forum.Sum",C ,ped )/ped,-1) * x2),
(C * x1) + (PREV * x2))
I'm not sure my formula is correct.
Could you help me?
Thanks
|