Idea in brief
A regular moving average is equally slow in a trend and in a range. KAMA, which Perry Kaufman invented in the 1970s, changes its speed on every bar. The speed is set by the Efficiency Ratio: the share of the path price has traveled that went into net displacement. When price moves almost in a straight line, KAMA catches up with it quickly. When price chops in place, KAMA barely moves.
In a joint webinar, Kevin Davey took the simplest system: buy when the close crosses the average from below, exit when it crosses from above. Davey ran it on ES futures on 360-minute bars with a simple average and with KAMA of the same lengths. KAMA gave slightly more profit and a noticeably smaller drawdown (Davey's data). In the same webinar Kaufman explained that the standard parameters of KAMA, the author's own indicator, have changed for trend following, and why.
Why it might work
Kaufman came from the aerospace industry and built KAMA as a filter separating signal from noise. The original idea from a 1972 article changed the length of the average in steps depending on the price level, and Kaufman replaced the steps with a continuous function. In noise the average slows down, and there are fewer false crossovers. In a trend it speeds up and turns after price sooner. On Davey's chart KAMA turns up noticeably earlier than the SMA.
The foundation is an exponential moving average. Kaufman considers the EMA the weakest of the trend methods but the best carrier of adaptivity: its speed is changed by a single constant on every bar.
Kaufman explains the new parameters by changes in the markets. After the dot-com crash in 2000, volume grew strongly, and contrary to the author's expectations markets became more volatile and erratic. According to Kaufman, the 10-day average that made Donchian famous now works poorly, and the original KAMA settings make the average too fast for such markets.
Another point from the author: a trend system does not work on all markets, and markets should be selected with the same Efficiency Ratio. At the top of Kaufman's list are interest rates, at the bottom are stock indices. Davey's test, meanwhile, was run on an index. Kaufman says KAMA was tested on a broad set of markets and beats regular averages, but no figures were shown.
Rules
Indicator (code from Kaufman's book, shown on a slide)
// Efficiency Ratio: net change over N bars divided by the path traveled. From 0 to 1
NetChg = |Close - Close[N]|
TotChg = Sum(|Close - Close[1]|, N)
ER = NetChg / TotChg // if TotChg = 0, then ER = 0
// Kaufman twice stated the fraction upside down when speaking. The version from the code is correct: a high ER means a trend
FastSC = 2 / (Fast + 1) // Fast = 2 → 0.666 (book code)
SlowSC = 2 / (Slow + 1) // Slow = 30 → 0.0645
SC = (ER * (FastSC - SlowSC) + SlowSC) ^ 2 // squared, as in the book code
KAMA = KAMA[1] + SC * (Close - KAMA[1])
// start per the book code: while the bar number is not greater than N, KAMA = Close
Davey's system (author)
// ES, 360-minute bars, long only, no stop-loss, no optimization
IF Close crosses above KAMA(N = 50, Fast = 2, Slow = 30)
BUY AT NEXT BAR OPEN
IF Close crosses below KAMA(N = 25, Fast = 2, Slow = 30)
EXIT AT NEXT BAR OPEN
// crosses above: Close > KAMA AND Close[1] <= KAMA[1]
// benchmark for comparison: the same rules on SMA(50) for entry and SMA(25) for exit
Variant B. Kaufman's current parameters for trend following
Kaufman describes using KAMA as a trend system in its pure form, without additional filters. The entry and exit rules were not specified, so we carry them over from Davey's system.
// daily bars
N = 60 // author: instead of the previous 10
Fast = 6..8 // author, verbally: fast end 6–8 days instead of 2–3
Slow = 30 // author: label on the slide
// on the slide the lower panel is labeled (60,3,30), constant 0.00851 at ER 0.0637.
// Finetiq: recalculating with the formula matches Fast = 3, not 8. Test both values
IF Close crosses above KAMA(60, Fast, 30) BUY AT NEXT BAR OPEN // Finetiq: Davey's rule with a single line
IF Close crosses below KAMA(60, Fast, 30) EXIT AT NEXT BAR OPEN // Finetiq
// Finetiq: test a mirrored short separately, the author did not name the side
Market selection (author)
// Kaufman: put the trend system on markets with a high ER. There is no threshold, the rank is relative
ER10_i = Efficiency Ratio(10) on the daily bars of market i // author: a short period, 10
Rank = markets sorted by average ER10 over the last year // Finetiq: averaging over a year
trade KAMA on the top third of the list // Finetiq
// calculation check per the author: interest rates at the top, stock indices at the bottom
Parameters
| Parameter | Value | Source |
|---|---|---|
| ER formula | net change divided by path | author (code on the slide) |
| Fast and slow ends, Davey | 2 and 30 | author |
| ER length for entry, Davey | 50 | author |
| ER length for exit, Davey | 25 | author |
| Timeframe and market, Davey | 360 minutes, ES | author |
| Side, Davey | long only | author |
| Stop-loss | none | author |
| ER length, Kaufman | 60 instead of 10 | author |
| Fast end, Kaufman | 6–8 verbally, 3 on the slide | author |
| Slow end, Kaufman | 30 | author (slide) |
| Timeframe, Kaufman | daily bars | author |
| Variant B entry and exit | price crossing KAMA | Finetiq |
| ER for market selection | 10 bars, relative rank | author |
| Share of markets traded | top third by ER | Finetiq |
What to test
- KAMA versus SMA on many markets. Davey has one market and one timeframe. Run both systems on 20–30 futures and add an EMA of the same lengths as a third benchmark. Look at the median across markets, not at the best market.
- Parameters before and after 2000. Grid: N 10, 20, 40, 60, 90; fast end 2, 3, 6, 8. Separately on data before 2000 and after. Kaufman's thesis: the optimum has shifted toward longer values on both axes.
- Fast end 3 versus 8 at N = 60. The slide and the verbal version disagree, and the results may disagree too.
- Price crossover versus KAMA slope. Entry on the condition
KAMA > KAMA[1]instead of a crossover. Kaufman notes that an EMA turns exactly when price crosses it, and in the test on 44 markets Davey used the slope of the average as the basis. Calculate how much the trades differ. - Market selection by ER. The same system on the top and the bottom third of markets by ER10. If there is no difference, selection does not work on your data.
- Costs. According to Davey's data, the average trade on ES is $312. One tick of slippage on entry and on exit plus commission is about $30 per round trip, roughly a tenth of the average trade. Recalculate the test with costs for both averages.
- Warm-up. Compare KAMA values over the first 3–4 lengths of N on two platforms. Initialization differs between implementations, so exclude these bars from the test.
Platform notes
TradingView (Pine Script)
- There is no built-in KAMA, it has to be written from the formula. Public scripts differ: check that the constant is squared and that ER is calculated as net change divided by path.
- Start: the book code keeps KAMA = Close for the first N bars. An implementation via
nz(kama[1], close)starts from the first bar, and the values will differ until the end of the warm-up. - A 360-minute ES chart is built from the start of the symbol's trading session. Compare bar times with TradeStation, otherwise the signals will diverge from Davey's test.
- Crossovers:
ta.crossover(close, kama50)andta.crossunder(close, kama25). Execution at the open of the next bar is the default, as in Davey's code.
MultiCharts and TradeStation (EasyLanguage)
- Davey's code uses the TradeStation function
AdaptiveMovAvg(Close, 50, 2, 30): the second argument is the Efficiency Ratio length, the third and fourth are the fast and slow ends. The rules carry over line by line:If Close crosses above AdaptiveMovAvg(Close, 50, 2, 30) then Buy next bar at market. - In MultiCharts, check that the function exists and that its implementation matches the formula. It is safer to write KAMA from the formula so that the parameters match the source.
- Davey stresses that a 1440-minute bar is not the same as a daily bar. For TradeStation futures the daily bar closes on the settlement. For variant B, choose one bar type for both testing and trading.
- The exit in Davey's code is
Sell next bar at marketon the second, shorter KAMA. The position may stay open when price is already below KAMA 50: this is the rule, not a bug.
MetaTrader 5 (MQL5)
- Built-in
iAMA(symbol, period, ama_period, fast_ma_period, slow_ma_period, ama_shift, applied_price). Before testing, check its values against the formula from the book code on one stretch of history: initialization and calculation details differ between implementations. - 360 minutes in MT5 is
PERIOD_H6, but the bars are aligned to midnight on the broker's server, not to the start of the CME session. Six-hour bars in MT5 and TradeStation contain different hours, and the signals will be different. - An S&P 500 CFD differs from ES in price and trading schedule. Davey's dollar results per ES contract do not carry over to a CFD, so recalculate them using the broker's point value.
- Compute the signal on the closed bar (index 1) and check for a new bar.
Where the idea can break
- Davey's result is one market, one timeframe and an unnamed test period. The difference in net profit is about 2.5%, and the maximum drawdown is a single event. The conclusion "KAMA is better than SMA" does not follow from this table.
- Kaufman's new parameters are based on personal experience. The webinar has no results with a period of 60 and a fast end of 6–8, and the slide labels do not match the verbal version.
- The ER formula is easy to invert when transcribing it from speech. Selection will then pick the opposite markets, while the test does not fail and looks plausible.
- According to Kaufman, indices are the least trending markets. About the S&P, the author says that in optimization fast averages lose on it and slow ones make money. A result on ES may not carry over to other markets, and vice versa.
- The webinar is a warm-up for a paid course. The authors kept some materials, such as the table ranking markets by ER, for the course.
- There is no stop-loss. On 360-minute bars, an exit on a cross below KAMA 25 may come only after a large gap.