Average True Range (ATR)
Calculate the Average True Range (ATR) of a given price series.
The Average True Range (ATR) is a technical indicator that measures the volatility of an asset’s price movements over a specified number of periods. It provides insights into the potential price range of an asset, which can help traders and investors make more informed decisions.
The formula is as follows:
\[\text{TR} = \max(\text{high} - \text{low},\; \operatorname{abs}(\text{high} - \text{previous\_close}),\; \operatorname{abs}(\text{low} - \text{previous\_close}))\] \[\text{ATR} = \text{Wilder's Smoothed Moving Average of TR over} \text{window} \text{periods}\]Also known as: ATR, volatility indicator. See volatility_model.get_average_true_range for the full formula; Wilder’s smoothing constant (1/window) is slower than a standard EMA’s (2/(window+1)) of the same window.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Average True Range (ATR) for you. Just ask in plain English.
Calculate the Average True Range (ATR) in Python
The Average True Range (ATR) is available in the Technicals module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_average_true_range as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(tickers=["AAPL", "MSFT"])
toolkit.technicals.get_average_true_range()
Which returns:
| Date | AAPL | MSFT | Benchmark |
|---|---|---|---|
| 2026-06-18 | 8.1636 | 12.5379 | 11.0343 |
| 2026-06-22 | 8.065 | 12.4293 | 11.1386 |
| 2026-06-23 | 7.945 | 11.7 | 11.7414 |
| 2026-06-24 | 7.85 | 11.4886 | 11.9636 |
| 2026-06-25 | 8.9529 | 11.9543 | 12.1729 |
| 2026-06-26 | 9.2186 | 12.5764 | 12.0579 |
| 2026-06-29 | 8.6679 | 13.4336 | 12.3993 |
| 2026-06-30 | 8.345 | 12.9479 | 11.1721 |
| 2026-07-01 | 8.3464 | 13.5143 | 10.7443 |
| 2026-07-02 | 8.9414 | 13.1671 | 10.4364 |
Parameters
get_average_true_range accepts the following parameters:
- period (str): Period for which to calculate the ATR.
- window (int): Number of periods for ATR calculation. The number of periods (time intervals) over which to calculate the Average True Range.
- rounding (int | None): Number of decimal places to round the resulting ATR values to. If None, no rounding is performed.
- growth (bool): Flag indicating whether to return the ATR growth rate. If True, the ATR growth rate is calculated.
- lag (int | list[int]): Number of periods to lag the ATR values by. If an integer is provided, all ATR values are lagged by the same number of periods. If a list of integers is provided, each ATR value is lagged by the corresponding number of periods.
- standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.
Related Volatility Indicators
The Technicals module page introduces the module, and the sidebar lists all of its functions.