Most trend-following ideas fail in the same quiet way: the entry rule fires in a market that is not trending. A moving average cross does not know whether the market is going somewhere or just wandering sideways. The ADX indicator was designed to answer exactly that question, which makes it a useful building block even if you never use it as the only rule.
In this post I will walk through one small, concrete example: an ADX trend EA built from blocks in the MT5 EA Builder at mt5depot. I will explain what the three ADX lines mean, show how the flow is wired, list the settings you would normally touch, and then spend a good part of the article on the part people skip: where this kind of rule breaks and how to check it before trusting it.
You can open the exact example and follow along here: https://mt5depot.com/ea-builder?template=adx_trend
Three lines, two jobs
ADX comes from Welles Wilder's 1978 book New Concepts in Technical Trading Systems. In MetaTrader 5 the indicator draws three lines from a single period setting (14 by default):
- ADX (main line) measures how strong a trend is. It does not say up or down. A rising ADX means the move is getting stronger; a falling ADX means it is fading or the market is moving sideways.
- +DI measures upward directional movement.
- -DI measures downward directional movement.
So the lines split into two jobs. The main line answers "is there a trend at all?" The two DI lines answer "which way is it pointing?" If +DI is above -DI, buyers have had the upper hand over the lookback period. If -DI is above +DI, sellers have.
A common reading is that an ADX value above 25 suggests a trend worth following, and a value below it suggests a range. That threshold is a convention, not a law. Treat 25 as a starting point you can test, not a fact about the market.
Figure 1. ADX measures strength. The two DI lines carry the direction.
The rule we want
Written as plain sentences, the example rule is short:
- If ADX is above 25 and +DI is above -DI, open a buy.
- If ADX is above 25 and -DI is above +DI, open a sell.
- Otherwise do nothing.
Notice that each entry needs two conditions to be true at once. That is where the AND block comes in.
Here is the rule on real prices. Under the price chart are the three lines: ADX in white, +DI in green and -DI in red, with the 25 level dashed. A mark appears on the bar where a rule's conditions turn true.
Figure 2. EURUSD H1, Sep 23 to 28, 2026, MT5 demo account price data. ADX (14) is computed with the formula of the MT5 sample ADX indicator. Marks are drawn at bar close and show where each condition turns true. This illustrates the rule; it is not a trading result.
Wiring it in the Builder
The example in the Builder has a flow of blocks running left to right.
Figure 3. The adx_trend example in the EA Builder.
Here is what each part does.
Start (OnTick). Every flow begins with a Start block, the trigger. The block is labelled OnTick, but when an entry is actually evaluated is set by the Entry timing option in the Settings tab. Its default is "Bar close - once per candle", which ignores what happens inside the candle; "Every tick" and "On touch" are the other choices. Check it before you compare the EA with a chart, because it changes how often the rule can fire.
Three ADX blocks. The same indicator block is used three times, each set to period 14 and a different line: the main line, +DI and -DI. In the Builder these show up as three separate ADX blocks, which keeps each value explicit and easy to wire.
Compare blocks. A Compare block takes two inputs and an operator. The example uses three:
- ADX main compared against a threshold of 25 with the greater-than operator. This is the "is there a trend" check.
- +DI against -DI, greater-than. This is the "buyers lead" check.
- -DI against +DI, greater-than. This is the "sellers lead" check.
AND blocks. Two AND blocks combine the trend check with each direction check. The buy side is "ADX above 25 AND +DI above -DI". The sell side is "ADX above 25 AND -DI above +DI". Only when both inputs are true does the signal pass through.
Open Buy and Open Sell. The AND outputs feed the order blocks. The example uses a stop loss of 50 pips and a target (TP) of 100 pips on each order. These are the template's starting values, not recommendations. Both order blocks also take a lot input from a Fixed Lot block set to 0.01.
That is the whole flow: one trigger, three indicator reads, three comparisons, two AND gates, two orders and a lot size. If you can read the sentences in the previous section, you can read the diagram.
Settings you will probably touch
Besides the blocks, the Builder has a settings area for things that apply to the whole EA. For this kind of strategy, three are worth knowing about:
- Lot sizing. The example uses a fixed lot of 0.01. The Builder also offers other lot modes, so you can change how position size is decided without rewiring the flow.
- Filters. A spread filter lets you cap the spread at which the EA is allowed to open trades. A time filter limits the hours it may trade. Both are useful here, because trend entries that fire in thin, wide-spread hours behave differently from entries during active sessions.
- Exits. A trailing stop can be switched on instead of, or alongside, a fixed target. A trend rule often benefits from letting a move run rather than cutting it at a fixed distance, though whether it does for your symbol and timeframe is something to test, not assume.
The Builder also has a Preflight check panel that flags problems in the flow before you compile. Run it. A disconnected input is much cheaper to find there than after a confusing backtest.
Where this rule breaks
Now the honest part. A rule can be correct as written and still be a poor fit for the market you point it at. Here are the weak spots of an ADX filter, so you know what to look for.
ADX lags. It is smoothed over a lookback period, so by the time it rises above 25 a trend is often already under way. The rule will tend to enter after the start of a move, not at it. That is not a bug, but it is a trade-off: you gain some confidence that a trend exists and give up part of the early move.
Whipsaws near the threshold. When ADX hovers around 25, the condition flips on and off. Combined with +DI and -DI crossing back and forth, you can get several quick entries in a row in a market that is not really going anywhere. A threshold is a sharp line drawn through a gradual change, and prices do not respect it. In Figure 2 the ADX line spends most of the window within a few points of 25 while the DI lines cross each other, which is exactly where the condition flips most easily.
Fixed stop and target distances. A 50 pip stop means very different things on different symbols and in different volatility regimes. If you move the same flow from one pair to another, or from a quiet period to a volatile one, the stop and target need rethinking. An ATR-based stop is one option to try.
Both sides can fire in turn. Because the rule has a buy side and a sell side, a market that reverses can trigger one after the other. Decide up front whether you want to allow that, or whether you want a single open position at a time.
None of this means the idea is bad. It means the example is a starting structure, and the numbers in it are placeholders you are meant to question.
Testing it properly
The MT5 Strategy Tester is where a flow like this should spend most of its time before you trust it with anything. A few habits that cost nothing:
- Watch it run in visual mode first. Before looking at any summary, step through a few dozen entries and check that each one matches the sentence you wrote. If a buy fires when -DI is above +DI, the wiring is wrong, and no statistic will tell you that as clearly as seeing it.
- Test more than one period. A rule that behaves well in one stretch of data and badly in another is telling you something. Run a trending period, a ranging period and a volatile one separately.
- Include realistic costs. Spread and slippage matter more for rules that trade often. Set the tester to realistic spread, and do not assume the zero-cost case.
- Look at the worst stretch, not the average. Check the longest run of consecutive losing trades and the deepest drop in the equity curve. Whether you can tolerate those is a better filter for a strategy than any single summary number.
- Change one thing at a time. If you adjust the ADX threshold, the period, the stop and the lot all at once, you will not know which change did what. It is also an easy way to fit the settings to one stretch of history by accident.
If you tune the numbers until a single backtest curve looks good, you have mostly described that period, not the rule. Prefer settings that behave reasonably across a range of values over a single sharp peak.
Variations worth trying
Once the basic flow works and you understand it, small changes teach you a lot:
- Raise or lower the ADX threshold and see how the number of entries changes.
- Add a time filter so the EA only trades during the sessions you care about.
- Swap the fixed target for a trailing stop.
- Add a spread filter and compare behaviour with and without it.
- Add a higher-timeframe condition so the EA only takes signals in the direction of a slower trend.
Each of these is a change of one or two blocks or a setting, not a rewrite, which is the main point of building from blocks: you can change the structure of an idea quickly and then let the tester tell you whether the change mattered.
Wrapping up
ADX is a good example of an indicator that is easy to misuse by itself and genuinely useful as one part of a rule: it separates "how strong" from "which way". The block diagram makes that separation visible, because the strength check and the direction check are literally different branches joined by an AND gate.
If you want to try it, the example opens directly in the Builder: https://mt5depot.com/ea-builder?template=adx_trend
Open it, read the flow against the sentences above, run it in the Strategy Tester, and break it on purpose. Knowing where a rule fails is worth more than the rule itself.
This article was drafted with AI assistance and reviewed by the mt5depot team.



Top comments (0)