Skip to content

Free MT5 Expert Advisor

KAMA Trend EA

MT5 Expert Advisor that trades closes across Kaufman's Adaptive Moving Average when the efficiency ratio shows a trending market.

Trendv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Stop-loss on every trade
Strategy
Buys when price closes above Kaufman's Adaptive Moving Average while the 10-bar efficiency ratio is at least 0.30, and sells when price closes below it under the same condition. The stop is 1.5 x ATR and the target is 2R.
Risk model
1% of balance per trade (configurable), stop-loss on every order, one position at a time

What it does

Kaufman's Adaptive Moving Average (KAMA) speeds up when price moves efficiently in one direction and slows down when price is noisy. This EA buys when price closes above KAMA and sells when it closes below, but only when the efficiency ratio confirms that recent movement has been directional rather than random.

Trades use an ATR stop-loss, a reward-to-risk target and risk-based position sizing.

How it works

The EA uses MetaTrader's built-in Adaptive Moving Average (10, 2, 30) and computes its own efficiency ratio filter.

  • Efficiency ratio (ER): |close now - close 10 bars ago| ÷ the sum of the 10 absolute bar-to-bar changes. A value near 1 means price moved in a straight line; near 0 means it went nowhere.
  • Buy: the last closed bar closed above KAMA and the bar before closed at or below it.
  • Sell: the mirror image.
  • Filter: the ER on the signal bar must be at least 0.30; otherwise the cross is ignored and logged.
  • Stop-loss: 1.5 x ATR(14). Take-profit: 2R.
  • Exit: by default a position closes when price closes back across KAMA.

How to use it

KAMA's flattening in noisy conditions already reduces whipsaws; the ER threshold adds a second layer. Raising the threshold to around 0.4 or 0.5 makes the EA wait for cleaner trends, while lowering it trades more often. It suits liquid pairs and gold on H1 and H4.

Because KAMA adapts to volatility and noise, it is worth watching how the line behaves on your symbol before trusting the defaults.

Settings

InputDefaultWhat it changes
KAMA efficiency period10Bars used by KAMA to measure trend efficiency.
KAMA fast / slow EMA2 / 30Fastest and slowest smoothing KAMA can switch between.
Efficiency ratio period10Bars used for the entry filter.
Minimum efficiency ratio0.30Crosses are ignored below this value (0 to 1).
Stop-loss distance (x ATR)1.5Stop distance as a multiple of ATR(14).
Take-profit (R multiple)2.0Target as a multiple of the stop distance.
Exit on opposite crosstrueCloses the trade when price closes back across KAMA.
Risk per trade (% of balance)1.0Share of balance risked between entry and stop.
Fixed lots0Fixed volume instead of risk %; 0 = risk-based.
Maximum spread (points)20Skips signals when the spread is wider; 0 = off.
Trading start / end hour7 / 20Server-time window for new trades; equal values = 24 hours.
Move stop to break-eventrueStop to entry + 20 points once profit reaches 1R.
Use trailing stopfalseTrails the stop 2 x ATR behind price.
Magic number2611007Identifies this EA's trades.

Limitations

  • The efficiency ratio is calculated over a short window and can swing quickly.
  • In a slow, grinding trend ER may stay below the threshold and the EA will miss it.
  • Price can cross a flat KAMA several times in a row near the threshold.
  • Results depend on the symbol's noise level, so defaults that suit EURUSD may not suit other markets.

Before you run it live

Test on a demo account and in the MetaTrader 5 Strategy Tester over several years first. No backtest results are published for this EA, and any test describes the past only.

  • Match the spread limit and trading hours to your broker's spreads, stop level and session times, and include commission and swap in tests.
  • Start with 1% risk or less and check the lot sizes in the Experts log; the Position Size Calculator is a useful cross-check.
  • Use a different magic number on each chart, and keep the terminal (or a VPS) running so stops are managed.

Look at how many crosses the ER filter rejects in the Experts log during a tester run; it shows how selective your threshold is.

Key inputs

Key inputs of KAMA Trend EA
InputDefaultDescription
KAMA efficiency period10Bars used by KAMA to measure trend efficiency.
KAMA fast / slow EMA2 / 30Fastest and slowest smoothing KAMA can switch between.
Efficiency ratio period10Bars used for the entry filter.
Minimum efficiency ratio0.30Crosses are ignored below this value (0 to 1).
Stop-loss distance (x ATR)1.5Stop distance as a multiple of ATR(14).
Take-profit (R multiple)2.0Target as a multiple of the stop distance.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors