Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi ohad
I can't help you develop your own Kaufman's AMA code but I have 3 versions of it as you can see below. The first version probably came from a MetaStock forum or discussion group, the second I managed to eliminate 1 PREV function, and the third uses the MSTT DLL (created by Scott Bunny) to eliminate both PREV functions.
Hope this helps.
Roy
{Kaufman's Adaptive Moving Average}
Periods:=Input("Time Periods",1,1000, 10);
Direction:=CLOSE-Ref(CLOSE,-periods);
Volatility:=Sum(Abs(ROC(CLOSE,1,$)),periods);
ER:=Abs(Direction/Volatility);
FastSC:=2/(2+1);
SlowSC:=2/(30+1);
SSC:=ER*(FastSC-SlowSC)+SlowSC;
Constant:= Pwr(SSC,2);
AMA:=If(Cum(1) = periods +1,Ref(C,-1)+constant* (C-Ref(C,-1)), PREV+Constant*(C-PREV));
AMA;
{Kaufmans AMA (2)}
Pds:=Input("Time Periods",1,1000,10);
Direction:=C - Ref(C,-pds);
Vl:= Sum(Abs(ROC(C,1,$)),pds);
Volatility:=If(Vl=0,ValueWhen(1,Vl<>0,Vl),Vl);
ER:= Abs(Direction/Volatility);
FastSC:=2/(2 + 1);
SlowSC:=2/(30 + 1);
SSC:=ER * (FastSC - SlowSC) + SlowSC;
Constant:=Pwr(SSC,2);
AMA:=If(Cum(1)=pds +1,Ref(C,-1)+constant*(C-Ref(C,-1)), PREV*(1-Constant)+C*Constant);
AMA;
{Kaufmans AMA NP}
{MSTT.DLL required}
Periods:=Input("Time Periods",1,1000, 10);
Direction:=CLOSE-Ref(CLOSE,-periods);
Volatility:=Sum(Abs(ROC(CLOSE,1,$)),periods);
ER:=Abs(Direction/Volatility);
FastSC:=2/(2+1);
SlowSC:=2/(30+1);
SSC:=ER*(FastSC-SlowSC)+SlowSC;
Constant:= Pwr(SSC,2);
AMA:=ExtFml("MSTT.EMA",C,2/Constant-1);
AMA;
|
1 user thanked mstt for this useful post.
|
|