[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Kaufman MA



PureBytes Links

Trading Reference Links

> I'm Looking for the code for Kaufman Moving Average

Mail to Neville is bouncing, so here it is:


{ Function AMA_Kauf:  Kaufman's adaptive MA }

Inputs:  Price(NumericSeries), period(Numeric);
Vars:  noise(0), signal(0), diff(0), efratio(0), smooth(1), fastend(.666),
slowend(.0645), AM(0);

{ Calculate efficiency ratio }

diff = @AbsValue(Price - Price[1]);
if (currentbar <= period) 
then AM = Price
else begin
    signal = @AbsValue(Price - Price[period]);
    noise = @Summation(diff, period);
    if (noise = 0) 
      then efratio = efratio[1] 
      else efratio = signal / noise; 
    smooth = @power(efratio * (fastend-slowend) + slowend, 2);

    AM = AM[1] + smooth * (Price - AM[1]);
end;

AMA_Kauf = AM;