StockFetcher Forums · Filter Exchange · Adaptive Moving Average?<< >>Post Follow-up
ryannichols
6 posts
msg #54824
Ignore ryannichols
9/15/2007 6:31:43 PM

Does anyone have code for Perry Kaufman's Adaptive Moving Average (KAMA) enumerated in Van Tharp's "Trade Your Way to Financial Freedom" and as well as Kaufman's books.

Formula is:
KAMA = alpha * close + (1-alpha) * KAMA[prev]
alpha = (ER * 0.6015 + 0.0645) ^ 2

abs (close[today] - close[10 days ago])
ER = --------------------------------------
Sum abs (close - close[prev])
past 10 days



TheRumpledOne
6,359 posts
msg #54827
Ignore TheRumpledOne
modified
9/15/2007 7:22:57 PM

A google search turns up a lot of code.

Here's TradeStation code:

Inputs: Period(Numeric);
Vars: Noise(0), Signal(0), Diff(0), efRatio(0), Smooth(1), Fastest(.6667), Slowest(.0645), AdaptMA(0);
Diff = AbsValue(Close - Close[1]);
IF CurrentBar <= Period Then AdaptMA = Close;
IF CurrentBar > Period Then Begin
Signal = AbsValue(Close - Close[Period]);
Noise = Summation(Diff, Period);
efRatio = Signal / Noise;
Smooth = Power(efRatio * (Fastest - Slowest) + Slowest, 2);
AdaptMA = AdaptMA[1] + Smooth * (Close - AdaptMA[1]);
End;
AMA = AdaptMA;

http://www.xeatrade.com/trading/14/A/460.html


Fetcher[

set{Fastest, .6667 }
set{Slowest, .0645 }
set{Diff, abs( close - close 1 day ago)}
set{Signal, abs( close - close 5 days ago)}

set{Noise , sum(Diff, 5 }
set{efRatio , Signal / Noise }
set{Smooth1 , efRatio * Diff }
set{Smooth2 , Smooth1 + Slowest }
set{Smooth , pow(Smooth2, 2) }
set{AdaptMA1 , close - AdaptMA 1 day ago }
set{AdaptMA2 , Smooth * AdaptMA1 }
set{AdaptMA, AdaptMA 1 day ago + AdaptMA2 }
]



Power? Do we have power?

Updated Sat Oct 13 (Sammy Hagar's Birthday - guess you know where I am...LOL!)

Ok.. we have power but ... will this code work since it references AdaptMA 1 day ago BEFORE IT IS DEFINED?? I don't think so...

guru_trader
485 posts
msg #54833
Ignore guru_trader
9/16/2007 3:40:10 AM

Where's the rest TRO? :D

curmudgeon
103 posts
msg #54844
Ignore curmudgeon
9/16/2007 8:34:32 PM

It's a ROYAL PITA to try and optimize the settings on that AMA. I spent literally months working with it before I gave up. Gaussian filters are the best IMO.

ryannichols
6 posts
msg #54980
Ignore ryannichols
9/20/2007 9:53:46 PM

Did anyone get results from that screen?

ryannichols
6 posts
msg #55648
Ignore ryannichols
10/12/2007 1:25:43 PM

Rumpled One,

Can you please reproduce the entire filter so that I may back test it with other criteria?

chetron
2,817 posts
msg #55667
Ignore chetron
modified
10/13/2007 6:45:57 AM

yes, we do have power, but i am not sure how to do the next variable.

Fetcher[

set{Fastest, .6667 }
set{Slowest, .0645 }
set{Diff, abs( close - close 1 day ago)}
set{Signal, abs( close - close 5 days ago)}

set{Noise , sum(Diff, 5 )}
set{efRatio , Signal / Noise}

set{var1,fastest - slowest}
set{var2,var1 * efRatio}
set{var3,var2 + slowest}


set{Smooth ,pow(var3,2)}

add column var1
add column var2
add column var3
add column Smooth

]



StockFetcher Forums · Filter Exchange · Adaptive Moving Average?<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2016 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus