KAMA Strategy - Kaufman's Adaptive Moving Average
Feb 9, 2021

The KAMA Strategy indicator provides a comprehensive trading framework based on Kaufman's Adaptive Moving Average to identify trend direction while filtering market noise. By dynamically adjusting its sensitivity based on volatility, the tool aims to follow strong trends closely while remaining flat during choppy, non-trending periods.
Usage
The Usage section describes how the script can be used to identify market entries and manage exits. The core logic relies on the slope of the KAMA; a rising KAMA suggests a bullish trend, while a falling KAMA suggests a bearish trend.
- Entries: The strategy initiates a long position when the primary KAMA (KAMA 1) points upward and the magnitude of the move exceeds a volatility-based threshold (the KAMA Filter).
- Exits: Users can choose from multiple exit mechanisms to secure profits or limit losses. These can be used individually or in combination:
- KAMA Exit: Closes the position when the KAMA slope turns negative and exceeds the exit filter threshold.
- ATR Trailing Stop: A dynamic stop-loss that follows price at a distance determined by the Average True Range (ATR).
- PSAR Exit: Utilizes the Parabolic SAR to trigger exits when price crosses the SAR dots.
Details
The script is built around the efficiency ratio (ER), which represents the ratio of price direction to volatility. Kaufman's Adaptive Moving Average uses this ratio to adjust the smoothing constant between a "fast" and "slow" EMA.
- Adaptability: During trending markets, the ER is high, causing the KAMA to act like a fast EMA (e.g., 2-period). During sideways markets, the ER is low, and the KAMA acts like a slow EMA (e.g., 30-period).
- KAMA Filter: To reduce whipsaws, a filter is applied based on the standard deviation of the KAMA’s own changes. This ensures that the strategy only enters or exits when the KAMA movement is statistically significant relative to recent noise.
- Visual Ribbon: The script plots eight different KAMA lengths to create a ribbon effect, providing a visual representation of trend strength across multiple time horizons.
Settings
General Settings
- Source: Determines the price data used for KAMA calculations (e.g., Close, HL2).
Exits
- KAMA 1 Stop Loss: Enables/disables exits based on the primary KAMA slope.
- ATR Trailing Stop Loss: Enables/disables the volatility-based trailing stop.
- PSAR Stop Loss: Enables/disables exits based on Parabolic SAR crossovers.
KAMA Parameters
- Length: The lookback period used to calculate the efficiency ratio.
- Fast KAMA Length: The fastest possible smoothing length used during high efficiency.
- Slow KAMA Length: The slowest possible smoothing length used during low efficiency.
- KAMA 1 - 8: Eight sets of inputs allowing users to customize the lookback and smoothing bounds for each ribbon line.
KAMA Filter
- KAMA Entry Filter: Multiplier for the standard deviation filter to trigger entries.
- KAMA Exit Filter: Multiplier for the standard deviation filter to trigger exits.
Trailing ATR Stop
- Trailing ATR Lookback Period: The window for calculating ATR volatility.
- Trailing ATR Multiplier: Determines the distance of the stop loss from the price.
- Trail Mode: Choose between "Running" (constantly recalculating) or "Trailing" (only moves in the direction of the trade).
FAQ
How do I interpret the KAMA ribbon colors? Green lines indicate the KAMA is currently rising (bullish), while red lines indicate the KAMA is falling (bearish). Darker, thicker lines represent the faster KAMA settings, while lighter lines represent the slower, smoother settings.
Can I use this strategy for shorting? The current implementation of this script is optimized for long-only entries and exits. However, the KAMA values and filters can be used visually to identify bearish reversals.
How do I access the KAMA Strategy? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.