Kaufman's Adaptive Moving Average
systemic:core-kamaIndicatorsfunction1 crInputs
| Name | Type | Description |
|---|---|---|
| Window | integer | The **window** parameter (often denoted as $N$) controls how many periods are used to calculate the Efficiency Ratio (ER). This is the *memory* of KAMA's trend detection. |
| Slow Period | integer | The **slow period** defines the *maximum smoothing* KAMA can apply—the equivalent of a long EMA when markets are choppy and directionless. |
| Fast Period | integer | The **fast period** defines the *minimum smoothing* KAMA can apply—the equivalent of a short, highly responsive EMA when markets are trending strongly. |
| Price | floatarray | The **price data** input is a time series of numerical values representing the asset's price history—typically closing prices, though any consistent price type (open, high, low, or a custom calculation) can be used. |
Outputs
| Name | Type | Description |
|---|---|---|
| KAMA | floatarray | The **KAMA output** is a time series of the same length as the input price data, representing the adaptive moving average at each point in time. |
At a Glance
where
KAMA is a moving average that thinks. When markets trend strongly, it hugs price tightly. When markets chop sideways, it smooths aggressively to filter noise. This adaptive behavior—controlled by the Efficiency Ratio—makes KAMA one of the most sophisticated trend-following tools available.
The Problem KAMA Solves
Traditional moving averages force you into an uncomfortable trade-off:
flowchart LR
subgraph Problem["The Moving Average Dilemma"]
direction TB
Fast["🏃 Fast MA<br/>Responsive to trends<br/>But noisy in ranges"]
Slow["🐢 Slow MA<br/>Smooth in ranges<br/>But lags in trends"]
end
Fast <--> |"Pick your poison"| Slow
Fast moving averages (like a 10-period EMA) react quickly to price changes—great during trends, but they generate whipsaws during sideways markets.
Slow moving averages (like a 50-period SMA) filter out noise beautifully—but by the time they signal a trend, you've missed half the move.
KAMA's solution: Don't choose. Let the market tell you when to be fast and when to be slow.
The Mathematics of Adaptation
Understanding KAMA requires grasping three interconnected concepts: the Efficiency Ratio, the Smoothing Constant, and the recursive update formula.
Step 1: The Efficiency Ratio (ER)
The Efficiency Ratio measures how efficiently price has moved from point A to point B. Think of it as asking: "Of all the price movement that occurred, how much was directional versus noise?"
Numerator (Change): The absolute net price change over the window—how far price actually traveled.
Denominator (Volatility): The sum of all absolute period-to-period changes—the total "path length" price took.
| ER Value | Market Condition | Interpretation |
|---|---|---|
| ER = 1 | Perfect trend | Price moved in one direction only—no retracements |
| ER = 0 | Pure noise | Price ended exactly where it started despite movement |
| ER ≈ 0.5 | Mixed | Some trend, some noise—typical market behavior |
Why absolute values? Direction doesn't matter when measuring efficiency. A 10-point drop is equally "directional" as a 10-point rise.
Step 2: The Smoothing Constant (SC)
The Smoothing Constant translates the Efficiency Ratio into an actionable smoothing factor. It interpolates between a "fast" and "slow" exponential moving average based on ER:
where the EMA smoothing factors are:
With default parameters (Fast = 2, Slow = 30):
The squaring trick: KAMA actually uses in the final formula. This amplifies the difference between trending and ranging markets—when ER is low, becomes very small, making KAMA nearly flat.
Step 3: The KAMA Update
The final KAMA value is computed recursively:
This is the same structure as an EMA, but with a dynamic smoothing factor instead of a fixed one.
flowchart TD
A[Price Data Series] --> B[Calculate Change]
A --> C[Calculate Volatility]
B --> D["Efficiency Ratio (ER)"]
C --> D
D --> E[Apply Fast/Slow SC]
E --> F["Smoothing Constant (SC)"]
F --> G["Square SC → SC²"]
G --> H[Recursive KAMA Update]
H --> I[KAMA Output Series]
How KAMA Adapts: A Visual Guide
The relationship between the Efficiency Ratio and KAMA's behavior is the heart of the indicator:
flowchart LR
subgraph ER["Efficiency Ratio Spectrum"]
direction TB
ER0["ER → 0<br/>Choppy/Noisy<br/>Market"]
ER1["ER → 1<br/>Strong Trend<br/>Market"]
end
subgraph SC["Smoothing Response"]
direction TB
SC0["SC → Slowest<br/>30-period EMA<br/>More Smoothing"]
SC1["SC → Fastest<br/>2-period EMA<br/>Less Smoothing"]
end
ER0 -.-> SC0
ER1 -.-> SC1
Interpreting KAMA Signals
Trend Direction
The simplest use: KAMA slope indicates trend.
| KAMA Behavior | Signal | Confidence |
|---|---|---|
| Rising with steep slope | Bullish trend | High (ER is high) |
| Falling with steep slope | Bearish trend | High (ER is high) |
| Nearly flat | No clear trend | Market is ranging |
Price-KAMA Crossovers
When price crosses above or below KAMA, it often signals a trend change. However, KAMA's adaptive nature means crossovers in trending markets are more significant than crossovers during chop.
sequenceDiagram
participant Price
participant KAMA
participant Trader
Note over Price,KAMA: Ranging Market (Low ER)
Price->>KAMA: Multiple crossovers
KAMA-->>Trader: ⚠️ Filter these signals
Note over Price,KAMA: Trending Market (High ER)
Price->>KAMA: Decisive crossover
KAMA->>Trader: ✅ Act on this signal
Dual-KAMA Strategy
A powerful approach uses two KAMA lines with different responsiveness:
- Faster KAMA: Lower fast period (e.g., KAMA with Fast = 2)
- Slower KAMA: Higher fast period (e.g., KAMA with Fast = 5)
When the faster KAMA crosses above the slower KAMA, it signals potential trend acceleration—and vice versa.
Practical Applications
1. Cryptocurrency Volatility Regime Detection
Cryptocurrencies like Bitcoin are notorious for alternating between explosive trends and grinding consolidation. KAMA's Efficiency Ratio provides a real-time volatility regime detector.
The Insight: When ER stays above 0.6 for extended periods, the market is in a trending regime—ideal for momentum strategies. When ER hovers below 0.3, mean-reversion or range-trading strategies become more appropriate.
System Design Idea:
- Connect a cryptocurrency price feed to KAMA
- Use a separate module to track ER over time (you can approximate this by observing how quickly KAMA responds to price)
- When KAMA closely tracks price (high ER regime), tilt toward trend-following
- When KAMA moves slowly despite price swings (low ER regime), tilt toward range-trading
This approach lets you adapt your strategy to market conditions, much like how KAMA adapts its own smoothing.
2. Multi-Timeframe Trend Confirmation
A classic problem: short-term signals that contradict the larger trend lead to losses. KAMA on multiple timeframes provides a solution.
Implementation:
- Apply KAMA to daily data for the "macro" trend direction
- Apply KAMA to hourly data for entry timing
- Only take signals when both timeframes agree
For example, if daily KAMA is rising and price pulls back to hourly KAMA during a consolidation (low hourly ER), a bounce off hourly KAMA becomes a high-probability long entry.
3. Dynamic Position Sizing Based on Trend Quality
Most position sizing methods use fixed percentages or volatility adjustments (like ATR). KAMA introduces a more nuanced approach: scale position size with trend quality.
The Concept:
- When KAMA is responsive (high ER), trends are clean—increase position size
- When KAMA is sluggish (low ER), markets are noisy—reduce position size
This isn't just risk management; it's opportunity sizing. You're betting bigger when conditions favor directional trades and smaller when they don't.
Advantages Over Other Moving Averages
| Feature | SMA | EMA | KAMA |
|---|---|---|---|
| Lag in trends | High | Medium | Low (adaptive) |
| Noise filtering in ranges | Low | Low | High (adaptive) |
| Parameter sensitivity | High | Medium | Lower (self-adjusting) |
| Complexity | Simple | Simple | Moderate |
KAMA's self-adjusting nature means less parameter tuning. While you still choose the window, fast period, and slow period, KAMA's adaptive logic reduces the impact of suboptimal choices.
Limitations and Considerations
Lag still exists. KAMA reduces lag compared to slow moving averages, but it cannot eliminate it entirely. In extremely fast markets—like crypto flash crashes—even KAMA will trail.
Not a crystal ball. KAMA tells you what the market has been doing, not what it will do. High ER today doesn't guarantee trend continuation tomorrow.
The squaring effect. Because SC is squared, KAMA can become very unresponsive during choppy periods. This is usually desirable, but in some cases you may miss the start of a new trend.
Initial value matters. The first KAMA value is typically set as a simple average of the first N prices. In backtesting, be aware of this "warm-up" period.
References and Further Reading
- StockCharts: Kaufman's Adaptive Moving Average — Comprehensive calculation guide with examples
- Investopedia: KAMA — Beginner-friendly overview
- Corporate Finance Institute: KAMA — Step-by-step calculation walkthrough
- Binance Academy: Moving Averages in Crypto — Crypto-specific applications
- Perry Kaufman, Trading Systems and Methods (6th Edition, Wiley, 2019) — The definitive source from the creator
Glossary
| Term | Definition |
|---|---|
| Efficiency Ratio (ER) | A measure of directional movement relative to total movement; ranges from 0 to 1 |
| Smoothing Constant (SC) | The adaptive factor that controls KAMA's responsiveness |
| Fast Period | The shortest EMA period used when ER = 1 (maximum responsiveness) |
| Slow Period | The longest EMA period used when ER = 0 (maximum smoothing) |
| Window (N) | The lookback period for calculating the Efficiency Ratio |
| Crossover | When price moves from one side of KAMA to the other |
| Whipsaw | A false signal where price crosses a moving average but quickly reverses |
Data Alignment and Timeframe Considerations
When using KAMA in Systemic, understanding how data is aligned is essential for accurate calculations.
Single Input Simplicity: KAMA only requires price data, so there's no multi-series alignment to worry about—unlike indicators that combine price with volume.
Constant Parameters: The Window, Fast Period, and Slow Period are all constant values—not dynamic series. This means they don't participate in time-series alignment and remain fixed throughout the calculation.
Missing Data
A closed-market or missing-data bar (null) is never fabricated — not padded with the last available value, not echoed as a raw price, not frozen. The Efficiency Ratio and the recursive KAMA update both run over the observed bars only ("window-bar ER" = window observed bars, weekends bridged), then the result is placed back at the original grid slots:
- Gaps are bridged, not broken: a Friday-to-Monday transition is evaluated as adjacent observed bars — the recursive KAMA state carries across the gap — the closed-weekend slot itself is
null, never a repeated or interpolated value. - Warm-up (first
window− 1 observed bars) isnull, not the raw price echoed back and not a partial-window ER. - All bars missing returns every slot
null, no crash. - Live execution returns exactly one datapoint — the newest bar's value, or
nullwhen that bar itself is missing or still in warm-up.
Indicator Profile
quadrantChart
title KAMA Indicator Profile
x-axis Low Popularity --> High Popularity
y-axis Low Reliability --> High Reliability
quadrant-1 High potential
quadrant-2 Established leaders
quadrant-3 Niche tools
quadrant-4 Popular but risky
KAMA - Stocks: [0.55, 0.80]
KAMA - Crypto: [0.50, 0.75]
| Dimension | Stocks | Crypto | Notes |
|---|---|---|---|
| Popularity | 5.5/10 | 5.0/10 | Less known than SMA/EMA; favored by systematic traders |
| Reliability | 8.0/10 | 7.5/10 | Self-adjusting reduces false signals; crypto volatility tests limits |
| Complexity | 6.5/10 | 6.5/10 | Requires understanding of ER and smoothing mechanics |
| Versatility | 8.0/10 | 8.0/10 | Works across timeframes and asset classes |
| Recent Interest | 6.0/10 | 6.5/10 | Growing adoption in algo trading; well-suited for crypto regime detection |
This documentation is for educational purposes only and does not constitute investment advice. Markets involve risk, and past performance does not guarantee future results. Always conduct your own research and consult with qualified professionals before making investment decisions.