Kaufman |
The Kaufman's Adaptive Moving Average (Kama) indicator was developed to address the problem of market noise when identifying trends. The indicator, in its essence, is an Exponential Moving Average (Ema) that automatically becomes more sensible (fast) or robust (slow) depending upon the conditions that prevail in the market. On a trending market, there are relatively small swings, so Kama shorts the Ema period and follows the price very closely. If the market moves sideways then Kama increases the Ema period to eliminate market noise and follows the price slowly.
To measure the strength of a trend, Kaufman introduced the Efficiency Ratio (ER) that compares price direction with the level of volatility. The ER value defined within the range [0 … 1] is then used to regulate the Ema smoothing period from the minimal (fast) to the maximal (slow) value.
Kama informs about trends prevailing on the market:
Calculate the Efficiency Ratio over the period N specified:
Calculate the Smoothing Constant (SC):
Calculate Kama value:
To initialize Kama use one of the following constructors:
Kama – sets default values: period = 10, fastPeriod = 2, slowPeriod = 30
Kama(Int32)- sets value for period, others are default
Kama(Int32, Int32, Int32) - sets values for periods
Use
KAMA - property to get current value.
1// Create new instance 2Kama kama = new Kama(28, 6, 30); 3 4// Number of stored values 5kama.HistoryCapacity = 2; 6 7// Add new data point 8kama.Add(CurrentPrice); 9 10// Get indicator value 11double IndicatorValue = kama.KAMA; 12 13// Get previous value 14if (kama.HistoryCount == 2) 15{ 16 double IndicatorPrevValue = kama[1]; 17}