Kaufman Adaptive Moving Average

The Kaufman Adaptive Moving Average (KAMA) of Perry Kaufman changes its speed with the efficiency of the price move: it follows the price closely in a clean trend and barely moves in a choppy, sideways market.

The formula for the Kaufman Adaptive Moving Average starts from the Efficiency Ratio ER: the net change of the close over the last n periods divided by the sum of the absolute changes from period to period over those periods, the path the price took:

\[\text{Change} = \left\lvert \text{Close} - \text{Close}_{t-n}\right\rvert\] \[\text{Volatility} = \sum_{i=0}^{n - 1} \left\lvert \text{Close}_{t-i} - \text{Close}_{t-i-1}\right\rvert\] \[\text{ER} = \frac{\text{Change}}{\text{Volatility}}\]

The ER sets the smoothing constant SC between that of a fast EMA of f periods and that of a slow EMA of s periods, squared to slow it down further in a choppy market:

\[\text{Fast SC} = \frac{2}{f + 1}\] \[\text{Slow SC} = \frac{2}{s + 1}\] \[\text{SC} = (\text{ER} \cdot (\text{Fast SC} - \text{Slow SC}) + \text{Slow SC})^{2}\]

Each KAMA then moves the KAMA of the period before the fraction SC of the way to the latest close:

\[\text{KAMA} = \text{KAMA}_{t-1} + \text{SC} \cdot (\text{Close} - \text{KAMA}_{t-1})\]

Where \(\text{Close}_{t - i}\) is the close i periods ago. The ER runs from 0, a price that went nowhere, to 1, a price that moved in a straight line. Kaufman’s settings are \(n = 10\), \(f = 2\) and \(s = 30\). A KAMA that turns signals a trend; one that flattens, a market without direction.

A moving average smooths the price by averaging it over the last n periods, so that the trend shows through the noise of single periods. It is the oldest and most widely used trend indicator: the direction of the average shows the direction of the trend, the price above (below) it an uptrend (downtrend), and other indicators, from the MACD to the Bollinger Bands, are built on it. Every moving average trades smoothness against lag: the more periods it averages, the smoother it is and the later it turns after the price. The averages differ in how they weight the prices within the window and whether they adapt their speed to the market, each a different answer to that trade-off.

Also known as: KAMA, Kaufman’s Adaptive Moving Average, adaptive moving average, AMA.

In the Finance Toolkit this is get_moving_average with method="kaufman_adaptive", the same function as Moving Average.

Example · ^GSPC · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_moving_average:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["^GSPC"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_moving_average(method="kaufman_adaptive", window=50)

Which returns:

References

  • Paper Kaufman, P.J. (1998). “Trading Systems and Methods.” 3rd ed. Wiley.
  • Library Referenced against TA-Lib’s KAMA (Kaufman Adaptive Moving Average)
Share