DINEXSPACEXAUUSD SpecialistEAs available to rentCustom EA: Strategy → Code → BacktestView rentable EA bots
// ADX.MQ5

What is the ADX indicator?

Average Directional Index (ADX)Trend

Measures the STRENGTH of a trend regardless of direction — the indicator for deciding whether to trade at all.

What is Average Directional Index?

Measures trend strength (regardless of direction) with the +DI and −DI lines showing which side controls the market.

Average Directional Index (ADX) — ADX(14) 25.6 / +DI 26.2 / −DI 17.4 — SIMULATEDDINEXSPACE / TrendADX(14) 25.6 / +DI 26.2 / −DI 17.4XAUUSD · 1H / SIMULATEDRESSUP2,334.92,363.62,449.82,418.4▲ BUYCandle 43: BUY▼ SELLCandle 93: SELL▼ SELLCandle 102: SELLVOL*25ADX / +DI / −DICANDLE 1CANDLE 29CANDLE 57CANDLE 85CANDLE 112MA · EMA 14 ━━━━ / VOL* · ILLUSTRATIVE CANDLE RANGEEMA 14Illustrative data — not real market data, not a trading signalAverage Directional Index (ADX) — ADX(14) 25.6 · +DI / −DI — SIMULATEDADX 14XAUUSD · 1H / SIMULATEDRESSUP2,418.4▼ SELLCandle 102: SELLVOL*25ADX / +DI / −DIAverage Directional Index (ADX) — ADX(14) 25.6 · +DI / −DI — SIMULATEDADX 14XAUUSD · 1H / SIMULATEDRESSUP2,334.92,418.4▼ SELLCandle 102: SELLVOL*25ADX / +DI / −DIAverage Directional Index (ADX) — ADX(14) 25.6 · +DI / −DI — SIMULATEDADX 14XAUUSD · 1H / SIMULATEDRESSUP2,334.92,418.4▼ SELLCandle 102: SELLVOL*25ADX / +DI / −DIEMA 14Illustrative data — not real market data, not a trading signal

Illustrative signals of the rule on simulated data — not a trading recommendation.

Rule: ADX(14) above 25 and +DI crosses above −DI: buy; crosses below: sell. Entry = close of the signal candle; SL = entry ∓ 1.5 × ATR(14); TP1/TP2/TP3 = 1R/2R/3R.

Use this indicator to create a Custom EA brief →
// WHY_USE_IT

Where this indicator is strong

Three reasons Average Directional Index is still used after decades.

Answers the right question

Not whether to buy or sell, but whether the market is worth trading right now.

A strong filter

Put in front of a trend system, it removes most sideways phases.

Direction comes with it

The +DI and −DI lines show which side has the upper hand.

// READING_SIGNALS

How to read Average Directional Index signals

How Average Directional Index (ADX) produces its number, and what each shape on the chart means.

Formula and how it works

+DI and −DI are calculated from directional movement (+DM, −DM) and the True Range, smoothed with Wilder's method. DX = 100 × |+DI − −DI| / (+DI + −DI); ADX is the smoothed average of DX. ADX above 25 usually shows a trend strong enough to trade in its direction.

How to use it in an EA

Use ADX as a filter: only follow the trend when ADX > 25; +DI crossing above −DI suggests buying, the reverse suggests selling. A low ADX warns of a sideways market.

Fits when

As a gate for another system, placed before the entry decision.

Struggles when

Using it alone to find entries. ADX is a lagging indicator that does not show direction, so it cannot produce a complete signal on its own.

ADX above 25A trend strong enough for trend systems to work.
ADX below 20A sideways market. This is the time to stay out or switch to an oscillator system.
+DI crosses above −DIBuyers are taking the upper hand; it only matters once ADX is high enough.
ADX rises while price fallsThe downtrend is strengthening. A high ADX does not mean price is rising.
Common mistakes

Reading a high ADX as a rising market. ADX only says the trend is strong — which direction it is strong in comes from +DI and −DI.

// PARAMETERS

Recommended MT5 parameters for Average Directional Index

Default values of the sample file; test them for your market and timeframe.

ParameterDescription
InpPeriodWilder smoothing period for DI and ADX (default 14).
// INSTALL

Put the indicator into MetaTrader 5

Four steps, no software needed besides MT5.

01Download the .mq5 file

Click the download button above; the file saves to your computer under the indicator's name.

02Open the data folder

In MetaTrader 5 choose File → Open Data Folder, then go to MQL5/Indicators.

03Compile

Open the file in MetaEditor and click Compile. No errors means the indicator is ready.

04Drag it onto the chart

Go back to MT5, refresh the Navigator and drag the indicator onto the price chart.

📄 adx.mq5

DinexSpace wrote this file from the indicator's public formula, not from any commercial source. You are free to edit and reuse it.

// THE_DIFFERENCE

How it differs from MetaTrader 5's built-in indicator

The short answer: the formula is not different. What differs is what you can do with it.

Average Directional Index here gives exactly the same number as MetaTrader 5's built-in version — on purpose. The four points below are what differs, and all four can be read from the very adx.mq5 you download.

Calls a built-in indicator
No — the calculation sits in OnCalculate and can be copied straight into an EA
External libraries
Not a single #import declaration
Code length
82 lines · 1 input parameters
How it draws
A separate window below the price chart · calculated incrementally, does not redraw the past

Why this library promises no secret formula — read the full explanation on the library page.

// COMBINATIONS

Which indicators to pair Average Directional Index with, and what you gain

Each indicator only answers one question. Pairing well means covering the right weakness, not stacking more.

Average Directional IndexMoving Average
What you gain
A two-tier system: ADX decides whether the system is switched on, the MA decides the direction.
Note
This is ADX's most common pairing and also the one truest to what it is.
See Moving Average
Average Directional IndexStochastic Oscillator
What you gain
Switch systems by market state. With a high ADX run a trend system; with a low ADX switch to an oscillator system.
Note
You need a clear numerical switching rule; otherwise it becomes switching systems on a feeling after every losing trade.
See Stochastic Oscillator
// FAQ

Frequently asked questions about Average Directional Index

What ADX level means a strong trend?

Above 25 is usually considered a strong enough trend, below 20 sideways. These are common conventions, not constants: each currency pair and timeframe has a different baseline, so observe it on the market you actually trade.

Does a rising ADX mean price will rise?

No. ADX only measures the STRENGTH of the trend, not its direction. A rising ADX in a downtrend means price is falling harder. To know the direction, look at the +DI and -DI lines.

Does Average Directional Index on this page use real or simulated data?

The chart on this page uses a deterministic simulated candle series; it is not market prices or trading results.

// SAME_GROUP

Other trend indicators

Indicators in the same trend group, often used instead of or alongside Average Directional Index.

Turn Average Directional Index into an automated EA

An indicator draws signals, but when to enter, where to stop out and how much to risk are still your set of rules. Send those rules and DinexSpace builds them into an EA.

Use this indicator to create a Custom EA brief