2025-12-08 11:00:58 -08:00
# KAMA: Kaufman's Adaptive Moving Average
2025-12-20 15:08:07 -08:00
> "Perry Kaufman asked a simple question: 'Why should I use the same smoothing in a trending market as in a chopping market?' KAMA is the answer."
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
KAMA (Kaufman's Adaptive Moving Average) is an intelligent moving average that adjusts its smoothing speed based on market noise. When the price is moving steadily (high signal-to-noise ratio), KAMA speeds up to capture the trend. When the price is chopping sideways (low signal-to-noise ratio), KAMA slows down to filter out the noise.
2025-12-08 11:00:58 -08:00
2025-12-17 23:00:52 -08:00
## Historical Context
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
Perry Kaufman introduced KAMA in his book *Smarter Trading* (1998). It was one of the first widely adopted adaptive indicators, solving the problem of "whipsaws" in sideways markets without sacrificing responsiveness in trends.
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
## Architecture & Physics
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
KAMA uses an **Efficiency Ratio (ER)** to drive the smoothing constant of an EMA.
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
1. **Efficiency Ratio (ER)** : Measures the fractal efficiency of price movement.
- $ER = \frac{\text{Net Change}}{\text{Sum of Absolute Changes}}$
- ER approaches 1.0 in a straight line trend.
- ER approaches 0.0 in pure noise.
2. **Smoothing Constant (SC)** : Scales between a "Fast" EMA (e.g., 2-period) and a "Slow" EMA (e.g., 30-period) based on ER.
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
## Mathematical Foundation
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
$$ ER = \frac{|P_t - P_{t-n}|}{\sum_{i=0}^{n-1} |P_{t-i} - P_{t-i-1}|} $$
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
$$ SC = \left( ER \times (\text{FastAlpha} - \text{SlowAlpha}) + \text{SlowAlpha} \right)^2 $$
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
$$ \text{KAMA}_t = \text{KAMA}_{t-1} + SC \times (P_t - \text{KAMA}_{t-1}) $$
2025-12-17 23:00:52 -08:00
2025-12-20 15:08:07 -08:00
Note the squaring of the SC, which suppresses the response to noise even further.
2025-12-17 23:00:52 -08:00
## Performance Profile
2025-12-20 15:08:07 -08:00
KAMA is very efficient, with O(1) complexity thanks to the incremental volatility update.
2025-12-17 23:00:52 -08:00
2025-12-20 15:08:07 -08:00
| Metric | Score | Notes |
| :--- | :--- | :--- |
2025-12-22 20:42:26 -08:00
| **Throughput** | [N] ns/bar | O(1) updates |
| **Allocations** | 0 | Stack-based calculations only |
2025-12-20 15:08:07 -08:00
| **Complexity** | O(1) | Constant time update |
| **Accuracy** | 7/10 | Flattens in noise, tracks in trends |
| **Timeliness** | 8/10 | Accelerates quickly in strong trends |
| **Overshoot** | 9/10 | Very stable in sideways markets |
| **Smoothness** | 8/10 | Aggressive noise filtering |
2025-12-08 11:00:58 -08:00
2025-12-20 15:08:07 -08:00
## Validation
2025-12-17 23:00:52 -08:00
2025-12-22 20:42:26 -08:00
Validated against TA-Lib, Skender, Tulip, and Ooples.
2025-12-17 23:00:52 -08:00
2025-12-22 20:42:26 -08:00
| Library | Status | Notes |
2025-12-20 15:08:07 -08:00
| :--- | :--- | :--- |
2025-12-22 20:42:26 -08:00
| **QuanTAlib** | ✅ | Validated. |
| **TA-Lib** | ✅ | Matches `Kama` |
| **Skender** | ✅ | Matches `GetKama` |
| **Tulip** | ✅ | Matches `kama` |
| **Ooples** | ✅ | Matches `CalculateKaufmanAdaptiveMovingAverage` |
2025-12-17 23:00:52 -08:00
2025-12-20 15:08:07 -08:00
### Common Pitfalls
2025-12-17 23:00:52 -08:00
2025-12-20 15:08:07 -08:00
1. **Flatlining** : In very choppy markets, KAMA can become almost horizontal. This is a feature, not a bug—it's telling you to stay out.
2. **Parameters** : The standard settings are (10, 2, 30). 10 is the ER period, 2 is the fast EMA, 30 is the slow EMA. Tweaking the ER period changes the sensitivity to noise.
3. **Trend Following** : KAMA is excellent for trailing stops because it flattens out when momentum stalls.