Category
Technical
Difficulty
Intermediate
Used in
Strategy designMT5 operation

Average Directional Index

A technical indicator measuring trend strength on a 0–100 scale without saying which way the trend runs. EAs use it as a regime filter — trend strategies wait for a high reading, mean-reversion strategies for a low one.

also: ADX, Average Directional Movement Index, DMI

Updated

In plain English

A number that says how strongly the market is moving in one direction, without saying which direction. Low means it is going nowhere in particular; high means it is going somewhere, and the sign of it has to come from somewhere else.

Why it matters

Most EAs fail not because their entry logic is wrong but because it is right in one kind of market and wrong in another. ADX is the cheapest way to give a strategy an opinion about which kind it is in, which is why it appears as a filter in far more EAs than it appears as a signal.

  • It separates the two families that destroy each other. A grid or mean-reversion EA loses steadily in a strong trend, and a trend follower bleeds in a range; one threshold keeps each out of the other's weather.
  • It is directionless by construction, which makes it a filter rather than a signal — and the reason it is paired with something that has a direction.
  • It is slow. The smoothing that makes it stable also means it confirms a trend after it has begun, so it is better at excluding bad conditions than at catching good ones early.
  • A filter is testable: run the same strategy with and without it and read the difference in drawdown, not only in profit.

In MetaTrader 5

Where it appears in MT5

  • Insert → Indicators → Trend → Average Directional Movement Index
  • The indicator window draws three lines: the ADX line itself, +DI and −DI
  • The DI pair carries the direction ADX does not — +DI above −DI is the bullish arrangement
  • Strategy Tester → Inputs — the period and the threshold are inputs, and the threshold in particular invites over-fitting

How EAs use it

  • Create the handle in OnInit — iADX(_Symbol, PERIOD_CURRENT, 14) — and read buffer 0 for ADX, buffer 1 for +DI, buffer 2 for −DI.
  • As a gate before the entry rule: a trend EA returns immediately unless ADX is above its threshold; a range EA returns unless it is below.
  • As a direction check when the DI lines are used: +DI above −DI for longs, the reverse for shorts, with ADX confirming there is a trend to follow at all.
  • Read from the last completed bar, not the forming one — an ADX reading that flickers across the threshold intrabar produces entries that cannot be reproduced in testing.
  • Some EAs require ADX to be rising as well as high, which filters out the strong-but-fading readings that occur near the end of a move.

Typical settings

Setting Typical value Note
Period 14 The conventional default. Shorter periods react faster and cross the threshold more often, in both directions.
Trend threshold 20–25 Above this, trend-following logic is enabled. The exact value matters less than its stability across neighbours.
Range threshold below 20 Grid and mean-reversion EAs commonly require this before opening anything.
Strong trend above 40 Counter-trend and mean-reversion entries are usually blocked entirely here.
Timeframe read from the entry timeframe or one above Reading a higher timeframe gives a slower, steadier regime signal — at the cost of reacting later.

Common operational problems

  • Handles created inside OnTick instead of OnInit, which leaks and eventually returns INVALID_HANDLE.
  • CopyBuffer failing at startup before enough bars have loaded, which reads as a zero ADX and silently disables — or enables — the filter.
  • A threshold sitting exactly where the indicator spends most of its time, so the filter flickers on and off and the EA's behaviour becomes noise-driven.
  • Optimising the threshold to the best backtest value, producing a number that works only on the tested window.
  • Reading ADX as directional and taking longs on a high reading in a falling market.

Related MT5 functions

iADX(symbol, timeframe, adx_period)
Creates the handle; one call in OnInit, kept for the life of the EA.
CopyBuffer(handle, 0, …)
The ADX line itself — trend strength, no direction.
CopyBuffer(handle, 1, …) / CopyBuffer(handle, 2, …)
+DI and −DI, the directional pair the ADX line is derived from.
iTime(symbol, timeframe, 1)
The completed-bar timestamp EAs use to make sure the reading is stable.

Example

One entry rule, two regime filters, opposite conditions. The rule does not change; what changes is when it is allowed to fire.

ADX below 20
range regime
Mean-reversion and grid logic enabled; trend entries blocked.
ADX 20–40
moderate trend
Trend entries enabled; counter-trend entries usually not.
ADX above 40
strong trend
Mean-reversion blocked entirely — this is the regime that destroys it.
+DI vs −DI
the direction
ADX says how strongly; this pair says which way.

The measurable effect of a regime filter is usually a smaller drawdown rather than a larger profit — it removes losses rather than adding wins.

Calculation if (adx[1] < TrendThreshold) return; // trend EA does nothing in a range

Result A strategy that abstains in the conditions it was never good at

How it is used

Judge a filter by what it removes. The right comparison is the same strategy with and without it, over the same window, read on drawdown as well as on net result.

Range What it means
ADX under 20 No effective trend. Trend-following entries have their worst expectancy here, and breakout signals mostly fail.
ADX 20–40 A real trend is in progress. The usual operating range for trend logic.
ADX above 40 Strong trend, and often late in one. Trend entries still work; counter-trend and grid strategies are at their most dangerous.
Threshold tuned to the best backtest value A fitted parameter. Check that neighbouring thresholds give similar results before believing it.
  • Test the filter as a change, not as part of a package: run the strategy with the filter disabled over the same data and compare drawdown, trade count and profit factor.
  • Expect fewer trades. A filter that does not reduce the trade count is not filtering anything.
  • Read ADX on a completed bar and consider a higher timeframe for the regime decision, so the strategy is not switching character several times a session.
  • Do not use it alone for direction. The +DI/−DI pair or a moving average has to supply the sign.

The `/indicators` page for ADX covers the calculation and chart reading; this entry is about its use as an EA regime filter.

Common mistakes

Reading ADX as bullish or bearish

It is a strength measure with no sign. A high reading during a collapse is exactly as high as one during a rally, which is why it is always paired with something directional.

Setting the threshold where the indicator lives

If ADX spends most of its time near the threshold, the filter toggles constantly and the strategy's behaviour is decided by noise. A threshold is useful when it is crossed rarely and decisively.

Treating the filter as free

Every filter removes trades, including profitable ones. The test is whether it removes more loss than profit — which is a measurement, not an assumption.

Using a fast ADX period to react sooner

ADX is smoothed twice by design. Shortening the period makes it cross the threshold more often in both directions, which usually adds whipsaw rather than earlier entries.

Frequently asked questions

What ADX level indicates a trend?
Readings above roughly 20 to 25 are the conventional threshold for treating the market as trending, and above 40 as a strong trend. The exact number matters less than whether it is stable: a threshold that only works at one specific value on one specific test window is a fitted parameter rather than a regime rule.
Does ADX say whether the trend is up or down?
No. The ADX line measures strength only. Direction comes from the +DI and −DI lines it is built from — +DI above −DI is the bullish arrangement — or from a separate directional indicator such as a moving average.
How do EAs use ADX as a filter?
As a gate in front of the entry rule. A trend-following EA does nothing unless ADX is above its threshold; a grid or mean-reversion EA does nothing unless it is below. The effect usually shows up as a smaller drawdown rather than a bigger profit, because the filter removes trades taken in the conditions the strategy handles worst.
Why does my ADX filter make results worse?
Two common reasons. The threshold may sit where the indicator spends most of its time, so it toggles on noise, or the filter may have been optimised on the same window as the entry rule, in which case it fits that window's regimes rather than the concept of a regime. Testing the strategy with and without the filter on out-of-sample data separates the two.

Related articles