Here is the code of the adaptive moving average of ProRealTime. It is the same as a KAMA (Kaufman’s Adaptive Moving Average):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
// parameters : Period = 9 FastPeriod = 2 SlowPeriod = 30 Fastest = 2 / (FastPeriod + 1) Slowest = 2 / (SlowPeriod + 1) if barindex < Period+1 then Kama=close else Num = abs(close-close[Period]) Den = summation[Period](abs(close-close[1])) ER = Num / Den Alpha = SQUARE(ER *(Fastest - Slowest )+ Slowest) KAMA = (Alpha * Close) + ((1 -Alpha)* Kama[1]) endif return kama |
Kaufman Adaptive Moving Average KAMA