top of page

Average Directional Index (ADX)

  • Writer: Doji
    Doji
  • May 28, 2024
  • 2 min read

Updated: May 29, 2024

What it is and how to use it


What is it?

The Average Directional Index (ADX) is a technical indicator used to measure the strength of a trend, regardless of its direction. It helps you identify whether the market is trending or ranging, which is crucial for applying the appropriate trading strategy.


Who made it?

The Directional Movement System, including the DI and ADX, was introduced by J. Welles Wilder in his 1978 book "New Concepts in Technical Trading Systems."


How is it calculated?

The ADX calculation involves several steps, including determining the True Range (TR) and Directional Movement (DM), and then calculating the Directional Indicators (DI+ and DI-), followed by the ADX itself.


Calculating DI+ and DI-:

  1. Calculate the differences:

    1. upMove = high - high[1]

    2. downMove = low[1] - low

  2. Determine the Directional Movement (DM):

    1. DMplus = 0

    2. DMminus = 0

    3. if (upMove > downMove and upMove > 0) then DMplus = upMove endif

    4. if (downMove > upMove and downMove > 0) then DMminus = downMove endif

  3. Calculate the True Range (TR):

    1. TR1 = high - low

    2. TR2 = abs(high - close[1])

    3. TR3 = abs(low - close[1])

    4. TRValue = max(TR1, max(TR2, TR3))

  4. Smooth the DM and TR over a specific period (e.g., 14 periods):

    1. smoothedDMplus = summationperiod / summationperiod

    2. smoothedDMminus = summationperiod / summationperiod

  5. Calculate the Directional Indicators (DI+ and DI-):

    1. DIplusValue = 100 * (smoothedDMplus / summationperiod)

    2. DIminusValue = 100 * (smoothedDMminus / summationperiod)

  6. Calculate the Directional Index (DX):

    1. DX = 100 * abs(DIplusValue - DIminusValue) / (DIplusValue + DIminusValue)

  7. Smooth the DX values over the specified period to get the ADX:

    1. ADXValue = averageperiod


Code (ProRealTime)

// Parameters

period = 14


// Initialize variables

upMove = high - high[1]

downMove = low[1] - low


DMplus = 0

DMminus = 0

if upMove > downMove and upMove > 0 then

DMplus = upMove

endif

if downMove > upMove and downMove > 0 then

DMminus = downMove

endif


TR1 = high - low

TR2 = abs(high - close[1])

TR3 = abs(low - close[1])

TRValue = max(TR1, max(TR2, TR3))


if barindex = period then

// Initial summation for the first period values

smoothedTR = summation[period](TRValue)

smoothedDMplus = summation[period](DMplus)

smoothedDMminus = summation[period](DMminus)

endif


if barindex > period then

// Use Wilder's smoothing method after the initial period

smoothedTR = smoothedTR[1] - (smoothedTR[1] / period) + TRValue

smoothedDMplus = smoothedDMplus[1] - (smoothedDMplus[1] / period) + DMplus

smoothedDMminus = smoothedDMminus[1] - (smoothedDMminus[1] / period) + DMminus

DIplusValue = 100 * (smoothedDMplus / smoothedTR)

DIminusValue = 100 * (smoothedDMminus / smoothedTR)

DX = 100 * abs(DIplusValue - DIminusValue) / (DIplusValue + DIminusValue)

// Smooth DX to get ADX

if barindex = 2 * period then

ADXValue = average[period](DX)

else

ADXValue = (ADXValue[1] * (period - 1) + DX) / period

endif

endif


// Plot the ADX value

return ADXValue as "ADX"


Note: ProRealTime has the ADX indicator as standard, called "ADX".


How do you use the ADX?

Trend Strength: 

The ADX line measures the trend strength, regardless of direction. An ADX value above 25 typically indicates a strong trend, while an ADX value below 20 usually indicates a weak or non-trending market.


Filter for Other Indicators:  ADX can filter signals from other indicators, ensuring trades are only taken in strong trending conditions.


FAQ

Q: Is ADX a leading or lagging indicator?

A: ADX is a lagging indicator. It measures the strength of a trend without considering its direction, helping you identify strong trends.


Q: What are the best settings for ADX?

A: The default setting for ADX is 14 periods. You can adjust it to fit your trading style and the asset you're analyzing.


Q: How does ADX compare to RSI?

A: ADX measures trend strength, while RSI measures the speed and change of price movements. ADX is great for confirming strong trends, while RSI helps spot overbought and oversold conditions.


Strategies using ADX

  • None so far.

bottom of page