Average Directional Movement Index (ADX)

Introduction

The Average Directional Movement Index (ADX) is a technical analysis indicator used to quantify the strength of a trend in a stock, commodity, or currency pair. Developed by J. Welles Wilder Jr. in his book New Concepts in Technical Trading Systems, the ADX is a component of the Directional Movement System, which includes two other indicators: the Plus Directional Indicator (+DI) and the Minus Directional Indicator (−DI).

While the ADX measures the strength of a trend, it does not indicate the direction of the trend.

Calculation of ADX

The ADX is derived from the moving average of the directional movement index, calculated as follows:

  1. Calculate the Directional Movement (+DM and -DM):

    • +DM = Current High - Previous High (if positive and greater than 0; otherwise, 0)
    • -DM = Previous Low - Current Low (if positive and greater than 0; otherwise, 0)
  2. Calculate the True Range (TR):

    mathematical expression or equation
  3. Calculate the Average True Range (ATR):

    • Typically calculated as a moving average of the True Range over a specified period (often 14 days).
  4. Calculate the Directional Indicators:

    • +DI:
    mathematical expression or equation
    • −DI:
    mathematical expression or equation
  5. Calculate the ADX:

    • The ADX is then calculated as the average of the absolute differences between +DI and -DI over a specified period (usually 14 days):
    mathematical expression or equation

Example Calculation

Assume we have the following data for a stock over five days:

DayHighLowClose
1201819
2221921
3232022
4201919
5211820

Step 1: Calculate +DM and -DM

  1. Day 2:

    • +DM = 22 - 20 = 2
    • -DM = 0 (Previous Low = 18, Current Low = 19)
  2. Day 3:

    • +DM = 1 (Current High = 23, Previous High = 22)
    • -DM = 0
  3. Day 4:

    • +DM = 0 (Current High = 20 ≤ Previous High = 23)
    • -DM = 1 (Previous Low = 19, Current Low = 19)
  4. Day 5:

    • +DM = 0
    • -DM = 1 (Previous Low = 19, Current Low = 18)
Day+DM-DM
220
310
401
501

Step 2: Calculate True Range (TR)

  1. Day 2:

    mathematical expression or equation
  2. Day 3:

    mathematical expression or equation
  3. Day 4:

    mathematical expression or equation
  4. Day 5:

    mathematical expression or equation

Step 3: Calculate Average True Range (ATR)

For simplicity, assume the ATR over 4 days is calculated as follows:

mathematical expression or equation

Step 4: Calculate +DI and -DI

  • Day 2:

    mathematical expression or equation mathematical expression or equation
  • Day 3:

    mathematical expression or equation mathematical expression or equation
  • Day 4:

    mathematical expression or equation mathematical expression or equation
  • Day 5:

mathematical expression or equation mathematical expression or equation

Step 5: Calculate ADX

After calculating the values of +DI and -DI over the chosen period, the ADX can be calculated as:

mathematical expression or equation

Python Code

import pandas as pd

def calculate_true_range(data):
    """Calculate the True Range (TR)."""
    data['previous_close'] = data['Close'].shift(1)
    data['high_low'] = data['High'] - data['Low']
    data['high_prev_close'] = (data['High'] - data['previous_close']).abs()
    data['low_prev_close'] = (data['Low'] - data['previous_close']).abs()
    
    # Calculate True Range
    data['True Range'] = data[['high_low', 'high_prev_close', 'low_prev_close']].max(axis=1)
    return data

def calculate_adx(data, n=14):
    """Calculate the ADX."""
    data = calculate_true_range(data)
    
    # Calculate +DM and -DM
    data['+DM'] = (data['High'].diff() > data['Low'].diff()).where(data['High'].diff() > 0, 0)
    data['-DM'] = (data['Low'].diff() < data['High'].diff()).where(data['Low'].diff() > 0, 0)
    
    # Calculate the smoothed TR, +DM, and -DM using a rolling window
    data['ATR'] = data['True Range'].rolling(window=n).mean()
    data['+DI'] = 100 * (data['+DM'].rolling(window=n).mean() / data['ATR'])
    data['-DI'] = 100 * (data['-DM'].rolling(window=n).mean() / data['ATR'])
    
    # Calculate ADX
    data['DX'] = 100 * (abs(data['+DI'] - data['-DI']) / (data['+DI'] + data['-DI']))
    data['ADX'] = data['DX'].rolling(window=n).mean()
    
    return data[['Date', 'Close', '+DI', '-DI', 'ADX']]

Interpretation of ADX

  1. Trend Strength:

    • Values above 20 or 25 indicate a strong trend.
    • Values below 20 suggest a weak trend or a range-bound market.
  2. Trend Direction:

    • +DI above -DI: Indicates a bullish trend.
    • -DI above +DI: Indicates a bearish trend.
  3. Crossovers:

    • Traders may use crossovers between +DI and -DI as buy/sell signals.

Analogy

Think of the ADX as a weather forecast for trends. Just as meteorologists predict stormy or clear weather by analyzing patterns in temperature, wind, and pressure, traders can use the ADX to gauge whether a security is in a strong trend or a period of low volatility. A high ADX indicates a stormy market (strong trend), whereas a low ADX indicates clear skies and calm conditions (low volatility).

Conclusion

The Average Directional Movement Index (ADX) is a valuable tool for traders seeking to assess the strength of a trend. By understanding how to calculate and interpret the ADX, traders can enhance their trading strategies and make more informed decisions.


References

  • Wilder, J. W. (1978). New Concepts in Technical Trading Systems. Trend Research.
  • Investopedia: Average Directional Index (ADX)](https://www.investopedia.com/terms/a/adx.asp)
  • TradingView: Average Directional Index](https://www.tradingview.com/wiki/Average_Directional_Index_%28ADX%29)