KAMA — Kaufman Adaptive Moving Average
תוכן זה אינו זמין עדיין בשפה שלך.
An average that changes speed with the market: when price covers ground efficiently it tracks like a fast EMA, and when the same range is traversed in noise it nearly freezes. The efficiency ratio — net move over total path — is what drives it.
Signature
KAMA(period, fast, slow, on=<source>)| Argument | Type | Required | Notes |
|---|---|---|---|
period |
int Param or literal | Yes | Efficiency-ratio window. Default 10, bounds 1–400. |
fast |
int Param or literal | Yes | Fastest EMA equivalent. Default 2, bounds 1–50. |
slow |
int Param or literal | Yes | Slowest EMA equivalent. Default 30, bounds 2–200. |
on= |
symbol, OHLCV field, or indicator | No | Source. Defaults to the trade symbol’s close. |
Formula
$$ ER = \frac{|C_t - C_{t-n}|}{\sum |C_i - C_{i-1}|}, \quad SC = \left(ER\left(\tfrac{2}{f+1} - \tfrac{2}{s+1}\right) + \tfrac{2}{s+1}\right)^2 $$ $$ \text{KAMA}t = \text{KAMA}{t-1} + SC,(C_t - \text{KAMA}_{t-1}) $$
Warmup
period + 1 bars; tracks the close until then.
Reading the value
kama.valueself.trade.close > kama.valueExample
class KamaFollower(Strategy): """Trade the adaptive line: it holds still in chop and moves in trends.""" trade = Symbol() sizing = FixedCapital()
def execute(self): kama = KAMA(10, 2, 30, on=self.trade) if self.trade.close > kama.value and self.trade.is_flat: self.buy(self.trade, reason="Above KAMA") if self.trade.close < kama.value and self.trade.is_long: self.sell(self.trade, self.trade.position, reason="Below KAMA")Notes
- Perry Kaufman, Smarter Trading (1995).
- Proven by an assert-via-trade run on SPY daily (tracked price inside the expected envelope on
every bar of a 140-bar run; zero alarm trades). The
EfficiencyRatioinside it is available separately in Tier 2.