ADX Trend Filter EA
Directional Movement crossovers fire constantly, including in dead-flat markets where the resulting trades mostly just pay spread. ADX measures trend strength rather than direction, so pairing the two - DI for which way, ADX for whether it is worth acting on - is a standard, well-documented way to cut down on the crossover system's worst false signals without inventing a new indicator. The filter is asymmetric on purpose. It only gates new entries: an existing position is always closed the moment the opposite DI cross appears, regardless of where ADX sits at that instant. A trend dying is exactly the situation where ADX legitimately falls, so requiring it to stay high before letting the EA exit would trap the position in precisely the moment the exit exists to handle. Entries get the strict filter; exits do not. Stop loss and take profit are fixed pip distances, converted from pips to points per-symbol from the broker's own digit count rather than a hardcoded multiplier of ten. Position sizing can run as a fixed lot or, with InpUseRiskSizing on, as a percentage of equity risked to the stop distance, using MODE_TICKVALUE and MODE_TICKSIZE rather than a hardcoded contract size so it prices correctly on gold, indices and JPY crosses as well as plain FX pairs. Notes and limitations - The ADX filter reduces false crossover signals; it does not eliminate them. A threshold high enough to filter every loser also filters real trends, and no fixed value is correct for every symbol or timeframe - test before relying on the default. - Signals are evaluated once per closed bar, not on every tick. - One position at a time, tracked by InpMagicNumber. It will not manage or interfere with trades opened manually or by another EA. - Requires AutoTrading enabled; if trading is disabled the EA logs it and skips the entry. - On the MQL5 build, entries refuse on a netting account if the chart symbol already carries a position under a different magic number - see MQL4 VERSUS MQL5 DIFFERENCES above.
Expert advisor · MT5 · v1.0 · Free
About ADX Trend Filter EA
ADX Trend Filter EA is an expert advisor (trading robot) for MetaTrader 5 based on ADX. It can size trades from your balance and risk percent. It has 11 settings, such as Adx period, Adx threshold and Stop loss pips. MQL source code included.
Files in the download: AdxTrendEa.ex5, AdxTrendEa.mq5, AdxTrendEa.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Adx period | 14 | ADX / DI period |
| Adx threshold | 25.0 | Minimum ADX to allow a new entry |
| Stop loss pips | 50 | Stop loss distance, in pips |
| Take profit pips | 100 | Take profit distance, in pips (0 = none) |
| Use risk sizing | false | Size by percent risk instead of a fixed lot |
| Risk percent | 1.0 | Percent of equity risked per trade, when risk sizing is on |
| Fixed lots | 0.10 | Lot size when risk sizing is off, or as a fallback |
| Magic number | 20260603 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: ADX · Buy/Sell Arrows · Trend · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code