Average True Range

Introduction

The Average True Range (ATR) is a volatility indicator developed by J. Welles Wilder Jr. in his book, New Concepts in Technical Trading Systems. It measures market volatility by decomposing the entire range of an asset for that period. Unlike other indicators that focus solely on price movements, ATR considers gaps in the price, making it a valuable tool for traders assessing potential trade opportunities and risk.

Calculation of ATR

The ATR is calculated using the following steps:

  1. Calculate the True Range (TR):

    • The True Range is defined as the greatest of the following:
      • Current High - Current Low
      • Current High - Previous Close (absolute value)
      • Current Low - Previous Close (absolute value)
  2. Calculate the ATR:

    • The ATR is typically calculated as a moving average (usually a 14-period) of the True Range.

Formulas

  1. True Range (TR):
mathematical expression or equation
  1. Average True Range (ATR):
mathematical expression or equation

Where:

  • SMA represents the Simple Moving Average.
  • ( n ) is the number of periods typically set to 14.

Example Calculation

Let’s assume we have the following daily price data for a stock over 5 days:

DayHighLowClose
1302528
2322931
3343033
4333132
5363235

Step 1: Calculate True Range (TR)

  1. Day 2:

    • Current High = 32
    • Current Low = 29
    • Previous Close = 28
    mathematical expression or equation
  2. Day 3:

    • Current High = 34
    • Current Low = 30
    • Previous Close = 31
    mathematical expression or equation
  3. Day 4:

    • Current High = 33
    • Current Low = 31
    • Previous Close = 33
    mathematical expression or equation
  4. Day 5:

    • Current High = 36
    • Current Low = 32
    • Previous Close = 32
    mathematical expression or equation
DayHighLowCloseTrue Range (TR)
1302528N/A
23229314
33430334
43331322
53632354

Step 2: Calculate the ATR

To calculate the ATR over 3 days, we would take the average of the TR values from Day 2 to Day 5.

mathematical expression or equation

Python Code

import pandas as pd

def calculate_true_range(data):
    """Calculate True Range (TR) for the DataFrame."""
    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_atr(data, n=14):
    """Calculate Average True Range (ATR)."""
    data = calculate_true_range(data)
    data['ATR'] = data['True Range'].rolling(window=n).mean()  # Calculate the ATR as a rolling mean
    return data

Interpretation of ATR

  • Higher ATR: Indicates increased market volatility, suggesting that a security may experience larger price movements.
  • Lower ATR: Indicates lower volatility, suggesting a more stable market environment with smaller price fluctuations.

Trading Strategy

Traders often use ATR to set stop-loss levels. A common approach is to set a stop-loss at a multiple of the ATR (e.g., 1.5 or 2 times the ATR) to allow for volatility without being prematurely stopped out.

Analogy

Consider the Average True Range as a measure of excitement in a game. If there are a lot of unexpected turns and intense moments (high volatility), the excitement level (ATR) is high. Conversely, if the game is predictable and calm, the excitement level remains low. Just like you would anticipate a thrilling experience with high excitement, traders can anticipate more volatile price movements with a higher ATR.

Conclusion

The Average True Range (ATR) is a vital tool for traders that provides insights into market volatility. By understanding and applying ATR, traders can make more informed decisions regarding their risk management and trading strategies.


References