Average True Range(ATR)
The average size of a bar, including gaps from the previous close.
atr(high, low, close, period: int = 14)True range is the largest of three distances: the current bar high to low, the high to the previous close, and the low to the previous close. Averaging it gives a measure of how much this instrument typically moves in a bar, in the instrument’s own units. Including the previous close is what makes it handle gaps — a high-to-low range alone reports a gap-up day as quiet.
ATR is directionless, which is the point. It answers "how far does this thing move" and not "which way", and that makes it the natural unit for position sizing and stop placement. A stop at two ATR is the same risk statement on a currency pair and on a small-cap equity, which a stop at two percent is not.
This is the indicator most worth wiring into a strategy even if you never plot it. Sizing in ATR units is what stops a portfolio being accidentally concentrated in whatever happens to be most volatile.
Dividing ATR by price gives a unitless figure, usually called ATR percent, and that is the version worth comparing across a universe. Raw ATR ranks instruments by price level as much as by volatility, so a screen sorted on it returns the most expensive things you follow rather than the most active. The normalised version is also what makes a volatility filter portable between asset classes.
Where it misleads
- ATR is in price units, so it is not comparable across instruments without normalising by price first.
- It is backward-looking. Volatility regimes change faster than a 14-period average tracks them, and the gap is widest exactly when it matters.
- On illiquid instruments a single bad print inflates true range and, through it, your position sizing for the next fortnight.
In code
from quantide import fetch_data, atr
data = fetch_data("CL=F", "2018-01-01", "2025-01-01")
a = atr(data["High"], data["Low"], data["Close"], period=14)
risk_per_trade = 0.005
stop_distance = 2 * a
size = (risk_per_trade * 100_000) / stop_distance