- Strategy
- Buys when +DI crosses above -DI while ADX is above 25 and rising, and sells when -DI crosses above +DI under the same conditions. 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
The ADX DMI EA is built on Welles Wilder's Directional Movement system. The +DI and -DI lines measure upward and downward pressure; when they cross, direction may be changing. ADX measures how strong the trend is, regardless of direction.
The EA only acts on a DI crossover when ADX says a trend is present and strengthening. The aim is to avoid the many DI crosses that happen in quiet, directionless markets.
How it works
Signals are checked once per bar on the last closed bar using MetaTrader's built-in ADX.
- Buy setup: +DI was at or below -DI two bars ago and is above it on the last closed bar.
- Sell setup: -DI was at or below +DI and is now above it.
- Strength filter: ADX on the signal bar must be at least 25.
- Rising filter: ADX on the signal bar must be higher than on the bar before.
- If either filter fails, the cross is ignored and the reason is printed.
- Stop-loss: 1.5 x ATR(14). Take-profit: 2R. Exit: by default the position closes on the opposite DI cross.
How to use it
ADX-based systems are most useful on instruments that alternate between clear trending and ranging phases, such as major pairs, gold and indices on H1 or H4. Raising the ADX threshold makes the EA trade less often but only in stronger conditions; lowering it gives more trades and more noise.
Remember that ADX is direction-neutral: a high ADX in a falling market supports sell signals just as much as buy signals.
Settings
| Input | Default | What it changes |
|---|---|---|
| ADX / DI period | 14 | Period of the ADX and directional indicators. |
| Minimum ADX value | 25 | Crosses are ignored while ADX is below this level. |
| Require ADX rising | true | ADX must be higher than on the previous bar. |
| 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 the DI lines cross the other way. |
| 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 | 2611004 | Identifies this EA's trades. |
Limitations
- ADX is heavily smoothed and lags; it often peaks after the strongest part of a move.
- Requiring a rising ADX at the exact bar of a DI cross is strict and can skip valid trends.
- DI lines can cross several times in a row around the threshold, producing quick losses.
- No adjustment is made for news releases, when ATR and spreads can jump.
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.
Try a few ADX thresholds in the Strategy Tester, but avoid fine-tuning until the history looks perfect; that rarely carries forward.

