True Range (TR)
Calculate the True Range (TR) for a given price series.
The True Range (TR) is a measure of market volatility that considers the differences between the high and low prices and the previous closing price. It provides insights into the price movement of an asset.
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}))\]Also known as: TR, true range.
True Range (TR) in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_true_range as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
tickers=["NGUSD"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.technicals.get_true_range().tail(5)
Or, after setting up the Finance Toolkit MCP, ask:
How wide was the true range of natural gas on each trading day from 26 to 31 December 2025?
Which returns:
| Date | NGUSD | Benchmark |
|---|---|---|
| 2025-12-26 | 0.5251 | 2.3714 |
| 2025-12-28 | 0.482 | 2.7386 |
| 2025-12-29 | 0.2422 | 3.1057 |
| 2025-12-30 | 0.2599 | 1.9646 |
| 2025-12-31 | 0.3043 | 5.6062 |
Parameters
get_true_range accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”. | "weekly" |
close_column | str | The 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" |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the True Range. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |