logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ohad@altris.co.il  
#1 Posted : Sunday, October 9, 2016 10:48:05 AM(UTC)
ohad@altris.co.il

Rank: Newbie

Groups: Registered Users, Subscribers, Unverified Users
Joined: 9/13/2016(UTC)
Posts: 4

 

Hi,

 

 

I'm trying to write down the KAMA indicator in the formula editor, but I can't make it work.

There's probably somthing basic I'm missing. I wrote the following code (skipped calculations):

CurrentKAMA:=If(Cum(1)<ObservationPeriod,C,If(Cum(1)=ObservationPeriod,Ref(C,-1)+SC *(C-Ref(C,-1)),CurrentKama + SC * (C -CurrentKama)));

CurrentKama;

 

The first KAMA will be the Close price from a certain chosen period (observation period). The first KAMA will be C+SC (C-prev C) , and the following KAMA should create an iterative process.

The code doesn't work as expected though.

What am I missing?

Thank you

 

 

 

 

mstt  
#2 Posted : Sunday, October 9, 2016 8:47:43 PM(UTC)
mstt

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;
thanks 1 user thanked mstt for this useful post.
MS Support on 10/11/2016(UTC)
ohad@altris.co.il  
#3 Posted : Monday, October 10, 2016 7:41:30 AM(UTC)
ohad@altris.co.il

Rank: Newbie

Groups: Registered Users, Subscribers, Unverified Users
Joined: 9/13/2016(UTC)
Posts: 4

Hi msst, I'm still a novice at the metastock formula language, so for me it's the way to the solution rather than the solution itself. You've really helped, thank you very much! Ohad
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.