Back to Guides
Guide

Kaufman Adaptive Moving Average Formula (KAMA)

Kaufman adaptive moving average formula in three steps, and what squaring does: the published slow period of 30 behaves like an average of about 480 bars.

The Kaufman adaptive moving average is an exponential moving average whose smoothing constant changes on every bar, set by how much of a stretch's total movement ended up as net movement. Three steps: measure that efficiency, blend a fast and a slow smoothing constant according to it, then square the result and feed it into the usual EMA recursion.

Squaring the constant means the slow period of 30 that everybody publishes behaves like an average of roughly 480 bars. A KAMA that looks stuck in a quiet market is running about sixteen times slower than the number on the dialog suggests.

Perry J. Kaufman created it. TradingView dates it to 1995, and MetaTrader names the book: Kaufman developed and described the indicator in Smarter Trading. On MetaTrader it is called simply the Adaptive Moving Average, with no K. Two other adaptive averages sit beside it in that menu and decide their smoothing from different measurements: the variable index dynamic average, which scales by the Chande Momentum Oscillator, and the fractal adaptive moving average, which uses the fractal dimension of the price series.

What is the KAMA formula?

Three steps. TradingView's page has every bracket in place, and tulipindicators.org prints the same arithmetic in different notation. Here it is with keyboard operators, so you can retype it:

1. Change     = Abs(Price - Price N bars ago)
   Volatility = Sum of Abs(Price - Price 1 bar ago) over N bars
   ER         = Change / Volatility

2. Fast SC = 2 / (Fast Length + 1)
   Slow SC = 2 / (Slow Length + 1)
   SC      = (ER x (Fast SC - Slow SC) + Slow SC)^2

3. KAMA = SC x Price + (1 - SC) x Previous KAMA

Step 3 is an ordinary exponential moving average. What makes this indicator different is step 2, and particularly the squaring at the end of it.

Where is it on a ChartLabs chart, and which inputs does it expose?

Kaufman Adaptive Moving Average is built in, and it exposes all three periods. Open the chart's Indicators menu, stay on the Standard list and pick it under Moving Averages. It draws on the price pane, and its settings are Efficiency Length, Fast Length, Slow Length and Source.

Ours starts at Efficiency Length 30, Fast Length 2, Slow Length 30 and Source Close. The 2 and the 30 match the numbers everybody publishes, but the built-in's efficiency length is 30 rather than the 10 those writers give, so set it to 10 if you want their line. Over a stretch with no movement at all the built-in reads the efficiency ratio as 1, where QuantStrategy calls it zero, so the line closes on the flat price at the fast speed instead of crawling.

Why does my KAMA barely move in a quiet market?

Because of that squaring. A smoothing constant of c corresponds to an EMA of period 2/c - 1, and a half-life of log(0.5) / log(1 - c) bars. Run the published constants through it:

Smoothing constantSquaredEquivalent EMA periodHalf-life
Fast end, published period 20.66666670.44444443.5 bars1.2 bars
Slow end, published period 300.06451610.0041623479.5 bars166.2 bars

So "2 and 30" are not the limits of this filter. At the fast end, squaring moves a 2-period EMA to about three and a half periods, which barely matters. At the slow end it moves a 30-period EMA, whose half-life is 10.4 bars, to something nearer a 480-period average with a half-life of 166 bars. In a stretch the efficiency ratio scores as pure noise, KAMA takes about sixteen times as long to forget an old price as the dialog implies.

TradingView names the effect, and leaves it as an adverb: "Squaring the factor significantly reduces the moving average's responsiveness during periods of choppy or inefficient price movement". MetaTrader records the recommendation without quantifying it either: "For a more efficient influence of the obtained smoothing constant on the averaging period Kaufman recommends squaring it".

The table is arithmetic on published constants, so it says nothing about how KAMA performs on any instrument. Those are also the extremes: on a real chart the ratio sits somewhere between, so the filter does too.

What is the efficiency ratio?

How much of a stretch's total up-and-down movement ended up as net movement. A straight line in one direction scores 1. A lot of movement that goes nowhere scores near 0.

TradingView states both ends: an ER near 1 "indicating efficient price movement in one direction", and a value near 0 "indicating choppy or inefficient movement over the period".

None of the sources handles a perfectly flat stretch. If price does not move at all over the window, the change is zero and the total movement is zero too. The ratio is 0 divided by 0, which is undefined, not zero.

QuantStrategy states it as zero: "The efficiency ratio is considered zero if the price stays constant for 10 periods". WallStreetMojo says the same in its own calculation steps. The conclusion is reasonable, since treating a motionless market as maximally inefficient is what you would want. The arithmetic does not produce it, though, so what your chart draws there is that platform's decision about how to handle a zero denominator.

QuantStrategy's paragraph also disagrees with itself in consecutive sentences. It says the ratio "is considered 1 if the price constantly rises or declines for 10 periods" and then, immediately, that "it fluctuates between 0 and 1, when the price moves up or down for 10 consecutive periods", the same condition with two different answers.

A worked example with round numbers

Ours, as an illustration. An efficiency ratio period of 5, with the published fast and slow periods of 2 and 30, so the constants are fast SC = 2/(2+1) = 0.6666667 and slow SC = 2/(30+1) = 0.0645161, and the difference between them is 0.6021505.

Prices: 100, 102, 101, 103, 102, 104.

The efficiency ratio at the sixth bar:

  • Change = |104 - 100| = 4
  • Volatility = |102-100| + |101-102| + |103-101| + |102-103| + |104-102| = 2 + 1 + 2 + 1 + 2 = 8
  • ER = 4 / 8 = 0.5

Price travelled 8 points of movement to get 4 points of progress, so half the motion was useful.

The smoothing constant:

  • Blended = 0.5 x 0.6021505 + 0.0645161 = 0.3655914
  • Squared = 0.3655914 x 0.3655914 = 0.1336571

The squaring cut the constant to about a third of itself. Now two more bars of the recursion, starting from a previous KAMA of 102.0000:

BarPriceERSquared SCKAMA
61040.50000.1336571102.2673
71060.50000.1336571102.7662
81080.77780.2839349104.2523

On the third row price kept rising, so the efficiency ratio rose to 0.7778, the squared constant more than doubled, and the line moved 1.49 instead of 0.50.

The tulipindicators.org page prints fifteen dated rows at a period of 5, seeded at the fifth bar. We recomputed all eleven output rows from the formula as printed there, and every one matched to the cent. That page is a good place to check your own implementation.

Where the published formulas go wrong

Three published versions are defective, and one of them is a platform's own help page.

MetaTrader prints the slow constant two different ways, seventeen words apart. It first gives "for the period of no trend EMA period must be equal to 30 (slow SC = 2/(30+1) = 0.06452)", then two lines later writes SSC(i) = ER(i) * 0.60215 + 0.06425. Since 2/31 is 0.0645161, the first value is right and the second has two digits transposed. You can catch it with the page's own numbers: 0.60215 plus 0.06452 gives 0.66667, which is the fast constant 2/3 exactly, while 0.60215 plus 0.06425 gives 0.66640, which is not. Type the second line into a script and you are running a slightly different filter from the one the same page described.

The same page also drops a bracket, printing SSC(i) = (ER(i) * ( fast SC - slow SC) + slow SC: two opening brackets, one closing.

DevExperts has an efficiency ratio that spans the wrong number of bars and a garbled denominator. Its numerator is a difference between the current price and the price i-n+1 bars back, which spans one bar fewer than the n bars TradingView and tulipindicators.org use, and its sum ends with the term "|Pricei-n+1 - Pricei-n+1 - Pricei-n|", which has the same price twice and then a third, all inside one absolute value. That is as printed, not a transcription slip.

QuantStrategy puts the brackets in the wrong place on the slow constant, writing "The slowest SC for the 30-period exponential moving average is (2/30+1)". As written that is 2/30 plus 1, which is 1.067, not 2/31.

The ratio is only guaranteed to sit between 0 and 1 when the numerator's window and the denominator's sum cover the same bars, which is exactly what the off-by-one breaks.

What are the best KAMA settings?

It depends which platform you are on, because the same indicator exposes one setting, three or four.

One: tulipindicators.org hard-codes 2 and 30 into the formula, so the indicator "takes one parameter, the efficiency ratio period n". DevExperts exposes a single input labelled "Length", with no indication which of the three periods it sets.

Three: TradingView exposes ER length, Fast length and Slow length, plus the price source.

Four: MetaTrader's developer reference takes ama_period ("The calculation period, on which the efficiency coefficient is calculated"), fast_ma_period, slow_ma_period and ama_shift.

That is why a best-settings answer cannot travel. A recommendation written for a three-input version is not usable on a one-input version, and a one-input version may not be setting the period you assume.

The numbers everyone publishes are 10, 2 and 30: an efficiency ratio over 10 bars, a fast period of 2 and a slow period of 30. WallStreetMojo states all three and QuantStrategy repeats them. Neither sources the numbers, and none of those pages names a platform default for any of them. They are what writers recommend rather than what a platform ships, and ours ships a different efficiency length.

Then the part that follows from the squaring. The slow period is squared too, so raising it does far more than it looks. Moving it from 30 to 40 does not make the quiet-market filter a third slower, it changes a squared constant, and the half-life moves much further than the dialog suggests. If you change it, change one number, re-run the same symbol over the same dates, and compare. Hunting for a best triple across many runs on the same data is how a test stops meaning anything.

How do you read it?

Like any moving average: the direction of the line, and price crossing it. A flat line here is information rather than a fault.

When KAMA goes flat it is telling you the efficiency ratio is low, which is to say price has been moving a lot and getting nowhere. TradingView puts both uses in one sentence: "Traders often analyze movements in KAMA to identify trends and choppy market conditions, and use the crossings between KAMA and price or other moving averages to find potential turning points and signals".

A flat KAMA and a slow KAMA look identical on the chart while meaning different things, and the figure that tells them apart is the efficiency ratio itself.

How is it different from a DEMA or a TEMA?

Different mechanism and a different failure. KAMA adapts its smoothing to conditions, keeping one weighting rule and changing its strength, so it cannot print a value outside the prices it was built from. The DEMA and the TEMA keep a fixed weighting rule and cancel lag arithmetically, which is why they can overshoot the price.

Is there a KAMA strategy?

Not one published with a result. No source reports a trade count, a win rate or a profit factor for this indicator.

The most-asked version pairs the line with an average true range for a long entry, which is a reasonable thing to want: the moving average gives direction, the ATR sizes the stop from current volatility. To be testable, such a rule would have to state the three periods, the ATR period, how far from the line the entry sits, how the stop is derived from the ATR, which bar the condition is read on, and what invalidates it. None of the sources states any of that.

The sources publish confidence instead. WallStreetMojo writes that the indicator lets traders "minimize time lag" and that KAMA "generates fewer false signals and is less susceptible to whipsaw signals when compared to any other moving average. This ensures more dependable trade signals". QuantStrategy carries the same paragraph reworded, ending "This guarantees more reliable trading signals". The near-identical wording across two sites is copying, not two independent findings.

So we cannot tell you whether it works either. That answer only exists for your symbol, your three periods and your own counted sample.

What each source publishes

SourceFormulaSettings exposedHandles a flat marketPublished a test
tradingview.comCorrect, every bracketSource, ER, fast, slow lengthsNoNo
tulipindicators.orgCorrect, with a worked example that reproducesOne, the ER periodNoNo
devexperts.comER window off by one, denominator garbledOne, labelled "Length"NoNo
wallstreetmojo.comRecursion correct, three periods statedNot a platform pageStates it as zeroNo
quantstrategy.ioRecursion correct, bracket slip on the slow constantNot a platform pageStates it as zeroNo

Tulipindicators.org publishes its own caveat: "This documentation is still a work in progress. It has omissions, and it probably has errors too." Its example uses a period of 5, chosen for the example rather than recommended as a setting.

How do you write a KAMA rule you can test?

Name the event, the direction, the bar you read it on, what confirms it, and all three periods, written down before the first bar.

The three periods matter more here than on a fixed moving average, because they are not three ways of saying the same thing. The ER period decides how long a window the efficiency is judged over. The fast and slow periods decide the two ends the filter moves between, after squaring. A result on 10, 2 and 30 says nothing about a result on 20, 2 and 30.

Testable: "price closes above KAMA(10, 2, 30) on a completed 4-hour candle, having been below it for at least three candles, and I enter at the next candle's open." Not testable: "KAMA has turned up", with no definition of turned and no periods recorded.

Then one symbol, one timeframe, one date range, the same settings throughout, and every trade recorded including the ones you nearly took. Apply costs, because an adaptive line produces clusters of signals when conditions change. Per trade, log the date and time, symbol and timeframe, the direction, entry, stop and exit, the result in R, all three periods every time, whether the line was rising, falling or flat, and the efficiency ratio at entry if your platform shows it, since that is the only number that says which filter was actually running on that bar.

Judging on the bar whether the line has turned, rather than letting a script decide with hindsight, is what makes this suit stepping through bars by hand. On ChartLabs you step through real historical candles one at a time and place the trades yourself. Variable Index Dynamic Average, Fractal Adaptive Moving Average and MESA Adaptive Moving Average sit under the same heading, if you want to see three adaptive rules side by side.

Every moving average can have its own colour and line style, and one indicator instance can be edited without changing the others, so you can put the same indicator on twice with two different slow periods and watch how much further apart they sit than the two numbers suggest. Commission and slippage are set per symbol and feed every trade's P&L, balances and analytics, because a counted result without costs is not a result.

Next step

Put the line on one symbol, write the rule down with all three periods, and step through a date range counting what happened. ChartLabs has a 7-day free trial: start the free trial.

Related reading: how to backtest a strategy step by step, forex backtesting, and why backtest results and live results drift apart.

Related Topics

kaufman-adaptive-moving-averagekamaadaptive-moving-averageefficiency-ratiomoving-averagesbacktesting