Adaptive Moving Average Indicator: Kaufman’s KAMA on MT4 and MT5

Written by Dominic Walsh · Published · Last updated

The adaptive moving average indicator is a genuine Kaufman KAMA. It is not a smoothing trick borrowing the name. It measures how efficiently price has moved: the distance travelled, divided by the total path taken to get there. A straight run scores high and speeds the average up. A choppy one scores low and slows it down.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 3: KAMA, Buy, Sell
Alerts popup, push notification, email, sound
Inputs 10

What the Adaptive Moving Average Indicator draws on the chart

KAMA is the gold line, tightening against price in trends and flattening in chop.

Buy places a wide lime arrow where the close crosses above the line.

Sell places a wide red arrow on the downward cross.

Nothing else is drawn, so the line and the two crossings are the whole output.

  • KAMA: line, gold, width 2
  • Buy: arrow, lime, width 4, arrow code 233
  • Sell: arrow, red, width 4, arrow code 234
Adaptive moving average indicator on EURUSD H1 with the KAMA line and cross arrows
Adaptive moving average indicator on EURUSD H1 with the KAMA line and cross arrows

How the Adaptive Moving Average Indicator calculates its values

Measuring efficiency

change takes MathAbs(close[i] – close[i + ErPeriod]), the net distance covered. vol accumulates the bar-to-bar movement across the same window, which is the total path. er is their ratio. A perfectly straight move scores near 1. A market that ends where it started scores near 0.

Turning efficiency into a speed

fastSC takes 2.0 / (FastPeriod + 1.0), and slowSC does the same for `SlowPeriod`. sc then blends them: MathPow(er * (fastSC – slowSC) + slowSC, 2). Kaufman squares the result on purpose. That pushes the average toward the slow constant unless efficiency runs genuinely high. With `FastPeriod` at `2` and `SlowPeriod` at `30`, the line can move as fast as a 2-period EMA or as slow as a 30-period one.

Applying it and marking the cross

Kama[i] takes Kama[i+1] plus sc times (close[i] – Kama[i+1]). That is the standard exponential shape, but with a smoothing constant that changes each bar. A buy then needs close[i+1] at or below Kama[i+1], and close[i] above Kama[i]. Each close is judged against the line as it stood on that same bar.

How to read the signals

A flat KAMA is the tool working. Low efficiency means the average deliberately stopped chasing.

A steepening line means price has begun moving in a straighter path.

Crossings during a flat stretch are the least reliable, because the line is barely moving.

The gap between price and the line widens in fast trends. Even the fast constant lags.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

Four channels sit beneath `EnableAlerts`: a popup dialog, a mobile notification, SMTP email configured through Tools then Options, and a sound file from the MT4 Sounds folder. Popup ships enabled. The guard permits one message per closed bar.

Every Adaptive Moving Average Indicator input

Core settings

Setting What it does Default
ErPeriod Bars over which efficiency is measured, default `10`. Shorten it and the average switches speed more abruptly. 10
FastPeriod The fastest the line may move, default `2`, equivalent to a 2-period EMA at full efficiency. 2
SlowPeriod The slowest, default `30`. Widening the gap between the two makes the adaptation more dramatic. 30

Display settings

Setting What it does Default
ArrowOffsetPoints Distance between candle and arrow, default `30` points, set wide because the arrows draw at width 4. 30

Alert settings

Setting What it does Default
EnableAlerts master toggle. on
EnablePopup MT4 popup dialog. on
EnablePushNotify mobile MT4 push notification. off
EnableEmail SMTP email (Tools > Options > Email). off
EnableSound play sound file from MT4/Sounds/. off
SoundFile (see inputs panel) alert.wav
Adaptive moving average indicator inputs: ErPeriod, FastPeriod and SlowPeriod
Adaptive moving average indicator inputs: ErPeriod, FastPeriod and SlowPeriod

Settings that fit your chart

KAMA earns its keep where a market alternates between trending and ranging. That describes the majors through the session. EURUSD H1 is the reference chart. On the daily the efficiency ratio changes slowly, so the line behaves close to a fixed average. On M1 the ratio swings hard, and the line can change character several times an hour.

When the Adaptive Moving Average Indicator fails

Adaptation is not prediction. KAMA slows down after chop has already started, and speeds up after a trend is underway.

Price crossing any single average is a weak signal. Making the average adaptive does not change that.

A smooth trend that reverses sharply scores high efficiency right up to the turn. The line is therefore at its fastest exactly when it is about to be wrong.

Copy the compiled Adaptive Moving Average Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Related on forexmt4systems.com: Moving Average Crossover Strategy.

Download the Adaptive Moving Average Indicator for MT4 and MT5

The zip holds the compiled Adaptive Moving Average Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

What is ErPeriod’s efficiency ratio measuring?

How directly price got from A to B. change is the net distance over `ErPeriod` bars. vol is the total path walked to cover it. Divide one by the other and you get a number between 0 and 1. Near 1 means a straight run. Near 0 means the market went nowhere despite moving constantly.

Why do FastPeriod and SlowPeriod get squared after blending?

To bias the average toward slow. sc takes MathPow of the blended value, so a middling efficiency ratio lands much closer to the slow end than a plain blend would. In practice the line stays calm unless price moves with real conviction.

What happens if I widen FastPeriod and SlowPeriod?

The adaptation becomes more dramatic. At `2` and `30` the line can behave anywhere between a very fast and a fairly slow average. Bring them together, say 5 and 15, and KAMA starts acting like a fixed EMA. There is simply less range to adapt across.

Is this the same KAMA published by Perry Kaufman?

Yes, this build follows the standard formulation: efficiency ratio over `ErPeriod`, fast and slow smoothing constants derived from `FastPeriod` and `SlowPeriod`, blended and squared, then applied as an exponential update. The plot is even labelled KAMA. Nothing here is a substitute borrowing the name.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Adaptive Moving Average Indicator as one input. Always backtest before trading live.

Category: this is part of our Trend collection. Thus, browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment