Indicators/probuilder · probacktest · proorder · proscreener

ADX

ADX in ProBuilder returns the Average Directional Index, a 0 to 100 measure of trend strength derived from DIplus and DIminus. Syntax, formula, examples.

Syntax

probuilder
// N as number of periods for the calculation
ADX[N]

Parameters

NameTypeDefaultDescription
Ninteger14Smoothing period in bars. ADX takes no price argument; it is computed internally from high, low and close.

Formula

The calculation runs in four steps:

code
+DM = max(high - high[1], 0)   when it exceeds the down move, else 0
-DM = max(low[1] - low, 0)     when it exceeds the up move, else 0

+DI = 100 * WilderAverage[N](+DM) / AverageTrueRange[N]
-DI = 100 * WilderAverage[N](-DM) / AverageTrueRange[N]

DX  = 100 * ABS(+DI - -DI) / (+DI + -DI)

ADX = WilderAverage[N](DX)

Because DX is a normalised ratio, ADX is bounded between 0 and 100 regardless of the instrument's price scale.

How it works

On every bar, ProBuilder compares the current high and low with those of the previous bar to measure positive and negative directional movement. Smoothing those movements and dividing by the true range produces +DI and -DI, the two directional indicators. When one clearly dominates the other, DX is high; when they are nearly equal, DX collapses toward zero.

ADX is then a Wilder-smoothed average of DX. The double smoothing makes it deliberately slow: it rises only after directional movement has persisted for several bars, and it falls only after a trend has genuinely stalled.

The key property is symmetry. ADX rises during strong downtrends exactly as it does during strong uptrends. Direction has to come from DIplus and DIminus, the standalone versions of the two directional indicators.

Examples

Example 1, Plotting ADX with a custom period (Indicator)

probuilder
// 21-period ADX rendered in blue
myPeriod = 21
myADX = ADX[myPeriod]
RETURN myADX coloured(9,169,243) as "Average Directional Index"

Preserved from the source page. The period is held in a variable so it can be exposed as an optimisable setting, and the line is returned with a fixed colour and label.

Example 2, Trend filter for a crossover system (ProOrder)

probuilder
// Take EMA crossover longs only when ADX confirms a trend
DEFPARAM CumulateOrders = false
strength = ADX[14]
fast = ExponentialAverage[20](close)
slow = ExponentialAverage[50](close)

IF NOT LongOnMarket AND strength > 25 AND fast CROSSES OVER slow THEN
  BUY 1 CONTRACT AT MARKET
ENDIF
IF LongOnMarket AND fast CROSSES UNDER slow THEN
  SELL AT MARKET
ENDIF

The ADX condition blocks entries in flat markets, where moving-average crossovers produce most of their false signals.

probuilder
// Instruments where ADX is above 25 and higher than 5 bars ago
strength = ADX[14]
c1 = strength > 25
c2 = strength > strength[5]
SCREENER[c1 AND c2](strength AS "ADX 14")

Returns instruments whose trend strength is both elevated and still increasing, sorted by the ADX reading.

Interpretation

ZoneRangeReading
Weak or absent trendADX < 20Directional movement is balanced. Range-bound conditions; breakout and crossover signals are unreliable.
Developing20 to 25A trend may be forming. Often combined with a DIplus and DIminus cross for direction.
Strong trendADX > 25Sustained directional movement, up or down. Trend-following logic has the odds it was designed for.

A rising ADX means the current trend, whatever its direction, is strengthening. A falling ADX means it is losing force, which is not the same as reversing; markets frequently drift sideways after ADX rolls over.

Common errors and gotchas

  • No price argument. ADX[14](close) raises a syntax error. ADX reads high, low and close internally, so the correct call is simply ADX[14].
  • Strength is not direction. A reading of 40 says nothing about whether the market is rising or falling. Filtering longs on high ADX alone will happily buy into a strong downtrend; pair it with DIplus > DIminus or an equivalent direction test.
  • Double-smoothing lag. ADX confirms trends, it does not anticipate them. By the time it crosses 25, a substantial part of the move may already have happened. Shortening N reduces lag but makes the line erratic.
  • Thresholds are conventions. The 20 and 25 levels come from daily charts of liquid markets. Intraday data and low-volatility instruments often need recalibrated levels; inspect the indicator's own history before hardcoding a cutoff.
  • ADXR, smoothed variant averaging the current ADX with an older value.
  • DIplus, the positive directional indicator (+DI).
  • DIminus, the negative directional indicator (-DI).
  • DI, the directional movement spread.
  • TR, true range of a single bar.
  • AverageTrueRange, the smoothed true range used in the DI calculation.
  • WilderAverage, the smoothing method used throughout the ADX family.
  • Supertrend, a trend-following overlay often paired with ADX filters.