The formula for calculating the Average True Range (ATR) is as follows:
ATR = [(Previous ATR x (n-1)) + TR] / n
Where:
TR = True Range for the current period
n = the number of periods used to calculate the ATR
Previous ATR = the ATR for the previous period
The first ATR value is simply the average of the true range for the first n periods.
To calculate the ATR, you need to follow these steps:
Choose a number of periods to use for the calculation (e.g., 14, 20, or 50).
Calculate the true range (TR) for each period using the following formula:
TR = max[(high – low), abs(high – previous close), abs(low – previous close)]
Calculate the first ATR value by averaging the true range values for the first n periods.
For subsequent periods, calculate the ATR using the formula above.
The ATR is expressed in the same units as the price of the asset and can be used to determine the size of stop-loss orders, as well as to identify potential price breakouts and trend changes. The larger the ATR value, the greater the volatility of the asset’s price movements, and vice versa.
For example, let’s say you want to calculate the 14-day ATR for a stock. You would take the true range for each of the 14 days, then calculate the first ATR value as the average of those true ranges. For each subsequent day, you would use the formula above to calculate the ATR for that day, using the previous ATR value and ATR for the current day.