- 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
| Input | Default | What it changes |
|---|---|---|
| KAMA efficiency period | 10 | Bars used by KAMA to measure trend efficiency. |
| KAMA fast / slow EMA | 2 / 30 | Fastest and slowest smoothing KAMA can switch between. |
| Efficiency ratio period | 10 | Bars used for the entry filter. |
| Minimum efficiency ratio | 0.30 | Crosses are ignored below this value (0 to 1). |
| Stop-loss distance (x ATR) | 1.5 | Stop distance as a multiple of ATR(14). |
| Take-profit (R multiple) | 2.0 | Target as a multiple of the stop distance. |
| Exit on opposite cross | true | Closes the trade when price closes back across KAMA. |
| Risk per trade (% of balance) | 1.0 | Share of balance risked between entry and stop. |
| Fixed lots | 0 | Fixed volume instead of risk %; 0 = risk-based. |
| Maximum spread (points) | 20 | Skips signals when the spread is wider; 0 = off. |
| Trading start / end hour | 7 / 20 | Server-time window for new trades; equal values = 24 hours. |
| Move stop to break-even | true | Stop to entry + 20 points once profit reaches 1R. |
| Use trailing stop | false | Trails the stop 2 x ATR behind price. |
| Magic number | 2611007 | Identifies 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.

