Systemicbeta

Kaufman's Adaptive Moving Average

systemic:core-kamaIndicators

Inputs

NameTypeDescription
WindowWhole numberThe number of bars used to calculate the Efficiency Ratio (ER), often written as $N$.
Slow PeriodWhole numberThe EMA length that KAMA approaches in a choppy market; it sets the most smoothing KAMA applies.
Fast PeriodWhole numberThe EMA length that KAMA approaches in a strong trend; it sets the least smoothing KAMA applies.
PriceNumber seriesThe price series KAMA is calculated on, usually closing prices.

Outputs

NameTypeDescription
KAMANumber seriesThe adaptive moving average value for each bar of the price series.

Cost

6
credits per run
1,000
bars

0.209 + 0.00575·n credits for n bars, rounded up. The marks are each plan's limit of bars.

At a Glance

KAMAt=KAMAt−1+SC2×(Pricet−KAMAt−1)\text{KAMA}_t = \text{KAMA}_{t-1} + SC^2 \times (\text{Price}_t - \text{KAMA}_{t-1})

where SC=ER×(αfast−αslow)+αslowSC = ER \times (\alpha_{fast} - \alpha_{slow}) + \alpha_{slow}

KAMA is a moving average that adapts. When the market trends strongly, it follows price closely. When the market moves sideways, it smooths more to filter noise. The Efficiency Ratio controls this behavior.


The Problem KAMA Solves

Traditional moving averages force a 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-bar EMA) react quickly to price changes. This is good in trends, but gives whipsaws in sideways markets.

Slow moving averages (like a 50-bar SMA) filter out noise well. But when they signal a trend, much of the move is already over.

KAMA's solution: Do not choose. Let the market decide when to be fast and when to be slow.


The Mathematics of Adaptation

KAMA is built from three parts: the Efficiency Ratio, the Smoothing Constant, and the recursive update formula.

Step 1: The Efficiency Ratio (ER)

The Efficiency Ratio measures how efficiently price moved from point A to point B. It asks: "Of all the price movement, how much was directional and how much was noise?"

ER=∣Pricet−Pricet−N∣∑i=1N∣Pricet−i+1−Pricet−i∣ER = \frac{|\text{Price}_t - \text{Price}_{t-N}|}{\sum_{i=1}^{N} |\text{Price}_{t-i+1} - \text{Price}_{t-i}|}

Numerator (Change): The absolute net price change over the window: how far price actually traveled.

Denominator (Volatility): The sum of all absolute bar-to-bar changes: the total "path length" of price.

ER ValueMarket ConditionInterpretation
ER = 1Perfect trendPrice moved in one direction only—no retracements
ER = 0Pure noisePrice ended exactly where it started despite movement
ER ≈ 0.5MixedSome 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 turns the Efficiency Ratio into a smoothing factor. It moves between a "fast" and a "slow" exponential moving average, based on ER:

SC=ER×(αfast−αslow)+αslowSC = ER \times (\alpha_{fast} - \alpha_{slow}) + \alpha_{slow}

where the EMA smoothing factors are:

αfast=2Fast Period+1andαslow=2Slow Period+1\alpha_{fast} = \frac{2}{\text{Fast Period} + 1} \quad \text{and} \quad \alpha_{slow} = \frac{2}{\text{Slow Period} + 1}

With the standard values (Fast = 2, Slow = 30):

  • αfast=23≈0.667\alpha_{fast} = \frac{2}{3} \approx 0.667
  • αslow=231≈0.065\alpha_{slow} = \frac{2}{31} \approx 0.065

The squaring trick: KAMA uses SC2SC^2 in the final formula. This widens the difference between trending and ranging markets. When ER is low, SC2SC^2 becomes very small and KAMA is nearly flat.

Step 3: The KAMA Update

The final KAMA value is calculated recursively:

KAMAt=KAMAt−1+SC2×(Pricet−KAMAt−1)\text{KAMA}_t = \text{KAMA}_{t-1} + SC^2 \times (\text{Price}_t - \text{KAMA}_{t-1})

This is the same structure as an EMA, but with a dynamic smoothing factor SC2SC^2 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 link between the Efficiency Ratio and KAMA's behavior is the core 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-bar EMA<br/>More Smoothing"]
        SC1["SC → Fastest<br/>2-bar EMA<br/>Less Smoothing"]
    end
    
    ER0 -.-> SC0
    ER1 -.-> SC1

Interpreting KAMA Signals

Trend Direction

The simplest use: KAMA slope indicates trend.

KAMA BehaviorSignalConfidence
Rising with steep slopeBullish trendHigh (ER is high)
Falling with steep slopeBearish trendHigh (ER is high)
Nearly flatNo clear trendMarket 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

One 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 a possible trend acceleration, and the reverse.


Practical Applications

1. Cryptocurrency Volatility Regime Detection

Cryptocurrencies like Bitcoin alternate between strong trends and long consolidation. KAMA's Efficiency Ratio works as a volatility regime detector.

The Insight: When ER stays above 0.6 for a long time, the market is in a trending regime, which suits momentum strategies. When ER stays below 0.3, mean-reversion or range-trading strategies fit better.

System Design Idea:

  1. Connect a cryptocurrency price series to KAMA
  2. Track ER over time (you can approximate it by how quickly KAMA responds to price)
  3. When KAMA closely tracks price (high ER regime), tilt toward trend-following
  4. When KAMA moves slowly despite price swings (low ER regime), tilt toward range-trading

This lets you adapt your strategy to market conditions, as KAMA adapts its own smoothing.

2. Multi-Timeframe Trend Confirmation

A classic problem: short-term signals that go against the larger trend lead to losses. KAMA on several timeframes helps.

Implementation:

  • Apply KAMA to daily data for the "macro" trend direction
  • Apply KAMA to hourly data for entry timing
  • Only use 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 suggests another 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 is more than risk management: the size follows the quality of the trend.


Advantages Over Other Moving Averages

FeatureSMAEMAKAMA
Lag in trendsHighMediumLow (adaptive)
Noise filtering in rangesLowLowHigh (adaptive)
Parameter sensitivityHighMediumLower (self-adjusting)
ComplexitySimpleSimpleModerate

Because KAMA adjusts itself, it needs less parameter tuning. You still choose the window, fast period and slow period, but a less than ideal choice matters less.


Limitations and Considerations

Lag still exists. KAMA has less lag than slow moving averages, but it cannot remove it. In very fast markets, such as crypto flash crashes, KAMA also trails price.

Not a forecast. KAMA shows what the market has been doing, not what it will do. A high ER today does not guarantee the trend continues 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 window − 1 bars are empty (the warm-up). The first KAMA value equals the price on that bar, and later values adapt from there.


References and Further Reading


Glossary

TermDefinition
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 PeriodThe shortest EMA length, used when ER = 1 (maximum responsiveness)
Slow PeriodThe longest EMA length, used when ER = 0 (maximum smoothing)
Window (N)The look-back window for calculating the Efficiency Ratio
CrossoverWhen price moves from one side of KAMA to the other
WhipsawA false signal where price crosses a moving average but quickly reverses

Data Alignment and Timeframe Considerations

Single series input: KAMA only needs a price series, so there is nothing to align with other series. The output has one value per bar of the Price input.

Constant parameters: Window, Fast Period and Slow Period are fixed values set on the module, not series.

Minimum data: The price series must have at least as many bars as the largest of Window, Slow Period and Fast Period. With fewer bars, the module returns an error.


Missing Data

A closed-market or missing bar stays empty in the output. No value is filled in or repeated. The Efficiency Ratio and the KAMA update use only bars that have a price (a window-bar ER counts window bars with a price):

  • Gaps are bridged: Friday and Monday are treated as two bars next to each other, and KAMA continues across the gap. The weekend bars themselves are empty.
  • Warm-up: the first window − 1 bars with a price are empty. A partial-window value is never returned.
  • All bars missing: every bar of the output is empty.

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]
DimensionStocksCryptoNotes
Popularity5.5/105.0/10Less known than SMA/EMA; favored by systematic traders
Reliability8.0/107.5/10Self-adjusting reduces false signals; crypto volatility tests limits
Complexity6.5/106.5/10Requires understanding of ER and smoothing mechanics
Versatility8.0/108.0/10Works across timeframes and asset classes
Recent Interest6.0/106.5/10Growing use in systematic 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.

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5