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}\]

The ATR is in price units, which makes it the common basis for stop distances (for example two ATRs below the entry) and for sizing positions to equal risk. For the same reason it cannot be compared across stocks or over long periods in which the price changed a lot; divide it by the price for a percentage volatility. It measures how far price moves, not in which direction.

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.

The first period has no previous close, so its True Range is High - Low and the first ATR is the average of the first window True Ranges (the StockCharts convention; TA-Lib starts one period later).

Average True Range (ATR) in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_average_true_range as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["CLUSD", "NGUSD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_average_true_range().tail(5)

Or, after setting up the Finance Toolkit MCP, ask:

How did the 14-day average true range of crude oil and natural gas compare from 26 to 31 December 2025?

Which returns:

Date CLUSD NGUSD Benchmark
2025-12-26 1.2031 0.3041 5.8269
2025-12-28 1.1614 0.3168 5.6063
2025-12-29 1.1778 0.3115 5.4277
2025-12-30 1.1558 0.3078 5.1803
2025-12-31 1.1697 0.3076 5.2107

Parameters

get_average_true_range accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”, in which case the open, high and low prices are adjusted for dividends in the same way."Close"
windowintThe number of periods over which to calculate the Average True Range. Defaults to 14.20
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding set on the Toolkit (4 unless set otherwise).2
growthboolWhether to return the growth of the ATR instead of its level. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
Share