KAMA

A moving average that speeds up in clear trends and slows down in choppy markets.

Kaufman adaptive moving average. Efficiency ER = |x − x[period]| ÷ Σ|x − x[1]| over period changes; sc = (ER × (2 ÷ (fast + 1) − 2 ÷ (slow + 1)) + 2 ÷ (slow + 1))²; kama = prev + sc × (x − prev), seeded with the previous candle's value. Ready at period + 1 candles. A flat window (Σ changes 0) is not ready and leaves the average unchanged.

Settings

SettingDefaultRangeWhat it does
period101 to 1000Changes in the efficiency ratio.
fast21 to 1000Fastest EMA period.
slow301 to 1000Slowest EMA period.

What it gives

OutputWhat it is
kamaThe average, in price.

What it reads

It reads open, high, low, close, hl2, hlc3, ohlc4, hlcc4, close by default.

Warm-up

With its default settings, KAMA needs 311 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses KAMA with its default settings