# What is ATR (average true range)? Formula, ATR% and a backtest

Canonical URL: https://marketheist.io/portfolio/learn/atr
By Jeffrey Lin · Published 2026-11-23 · Updated 2026-11-24 · Data through Sep 2026
Category: Indicators

## Key takeaways

- ATR, the average true range, measures how far a price typically moves in a day, counting overnight gaps as well as the distance from the day's high to its low.
- Written as a percentage of the price (ATR%), it can be compared across decades and across funds that trade at very different prices.
- It says how much the market is moving, not which way: a high reading comes with sharp falls and with sharp rebounds alike.
- Holding only while ATR% is low steps aside during turbulent stretches. The cost is buying back in late, after the turbulence has passed and often after much of the recovery.
- MarketHeist uses the same measure for its volatility filter, which keeps any rule out of the market while ATR% is above a chosen level.

## Definition

The average true range (ATR) is a measure of how far a price moves in a typical day, introduced by J. Welles Wilder in 1978: it averages the true range, the largest of the day's high-to-low range and the gaps from the previous close. ATR% divides it by the closing price, so the reading is a percentage that can be compared across years and across funds with very different prices.

Also known as: ATR, ATR%, ATR percent, average true range percent, true range, Wilder's ATR, ATR volatility filter, normalized ATR.

## How it works

A day's high minus its low misses part of the move when the price gaps. If a fund closes at one level and opens well below it the next morning, the overnight drop is real loss or gain for a holder but sits outside that day's range. Wilder fixed this with the true range: the largest of three distances, today's high to today's low, today's high to yesterday's close, and today's low to yesterday's close. On a day without a gap the true range is just the ordinary range; on a gap day it stretches to cover the gap.

The average true range smooths the daily true ranges with Wilder's average, which gives the newest day a weight of one over the period (one fourteenth for the usual 14 days) and lets older days fade gradually instead of dropping out all at once. The result is in price units, dollars per share for a fund. That makes raw ATR hard to compare over time: a fund trading at several times its old price has a larger ATR for the same percentage moves. ATR% divides by the close and fixes that.

Traders use ATR to size things to the market's current pace: a stop-loss placed a few ATRs below the entry, a position sized so that a one-ATR move costs a set amount, or a filter that stands aside when the market is wild. The reason it carries information is that volatility clusters. Calm days tend to follow calm days and turbulent days follow turbulent ones, an observation that goes back to Benoit Mandelbrot's work on cotton prices in 1963, so a moving measure of recent range says something about the next few weeks, though not about direction.

ATR works like a speedometer, not a compass: it tells you how fast the price is travelling, never which way it is heading.

As a trading rule, holding only while ATR% is below a level keeps a portfolio out of the market's most violent stretches, which in stock markets have mostly been declines. The rule has a built-in delay on the way back: after a crash the daily ranges stay wide for weeks, so the rule waits in cash through the first part of the rebound. Whether stepping aside paid for that wait is a question for the data, and the answer changes with the fund, the threshold and the period.

## Formula

**True range of day t**

```
TR_t = max (H_t - L_t, |H_t - C_{t - 1}|, |L_t - C_{t - 1}|)
```

where:

- Hₜ, Lₜ: the high and low of day t
- Cₜ₋₁: the previous day's close
- TRₜ: true range of day t, in price units

The first bar of the data has no previous close, so its true range is its high minus its low.

**Average true range (Wilder's smoothing)**

```
ATR_t = \frac{\sum_{k = 0}^t (1 - \alpha)^k TR_{t - k}}{\sum_{k = 0}^t (1 - \alpha)^k}, \alpha = \frac{1}{n}
```

where:

- n: the period: 14 by default
- α: the weight of the newest day, one over the period
- k: how many days back a true range lies

Once the history is long, this is Wilder's recursion ATRₜ = ((n − 1) ATRₜ₋₁ + TRₜ) / n; the two differ only in the first few dozen bars, where Wilder seeded the average with a plain mean of the first n true ranges.

**ATR% and the calm-market rule**

```
ATR%_t = 100 \times \frac{ATR_t}{C_t}, s_t = {\begin{pmatrix} 1 & ATR%_t < \theta \\ 0 & otherwise \end{pmatrix}, r_{t + 1}^{rule} = s_t \cdot r_{t + 1}
```

where:

- Cₜ: the close of day t
- θ: the threshold in percent: 2 by default
- sₜ: the position decided at the close of day t: 1 = hold, 0 = cash
- rₜ₊₁: the fund's total return on the next day

The decision at the close of day t earns the next day's return (an execution delay of one bar), so a day's own move never decides whether that day is held.

## Worked example

SPY daily bars from Oct 2006 to Sep 2026, about 20 years: the rule holds SPY for the next day whenever its 14-day ATR% closes below 2, and holds cash otherwise, with no trading costs.

Over the window SPY's ATR% had a median of 1.12%, stayed under 2.20% on nine days in ten, and read 0.86% on the last day. The rule's condition held on 86.4% of days, so after the one-day delay it was invested 86.4% of the time and made 31 round trips, 1.6 a year.

The days it skipped were the violent ones. Its volatility was 13.0% against 19.4% for holding SPY throughout, and its worst decline from a peak was -33.7% against -55.2%: the rule was in cash for the steepest part of the 2008 crash, from the autumn of 2008 into 2009, when daily ranges were far above the threshold.

Growth was 8.8% a year against 11.1% for buy-and-hold, and $10,000 became $53,627 against $82,292. The rule paid at the turns: after a crash the daily ranges stay wide for weeks, so it bought back in only after much of the rebound had already happened.

Per unit of volatility the rule earned more: its Sharpe ratio, return per unit of volatility with cash at zero, was 0.71 against 0.64. Moving the threshold shifts the trade-off. At 1.5 the rule was invested 71.2% of the time and grew 6.7% a year with a worst decline of -18.3%; at 3 it was invested 96.0% and grew 11.4% a year with a worst decline of -25.0%.

Data through Sep 2026. Reproduce id: c25fc39b66fce354 (this guide, its lab setup and the data month).

## How MarketHeist computes it

- **Data**: Daily bars (open, high, low, close, volume) of the fund as the MarketHeist data service serves them to the backtester: prices adjusted for splits and dividends, so a dividend counts as reinvested. They come from a snapshot taken each month and cut at the data month of this page, and are not rounded. The fund's own history, not an extension: a fund younger than the window is measured over the years it has.
- **Window**: The worked example and the lab measure the last 20 years of trading days, Oct 2006 to Sep 2026 (5030 days), ending at the data month of this page. Every setup, and buy and hold, is measured over exactly these days; an indicator is warmed up on the days before them, so changing a setting never moves the window, and a setting that needs more history than exists before the window is refused rather than measured over fewer days.
- **Backtest**: The backtester's own engine, in the order it runs it: the indicator, the position rule (or entry and exit triggers) and the optional regime filter produce a position for every day of the fund's whole history; the position is then shifted forward by the execution delay and applied to each day's return over the window. Cash earns 0, there is no leverage, and a one-way cost in basis points is charged on the size of every change of position. Round trips are the closed entries of the trade log (a trade still open on the last day is not counted); the win rate is the share of them with a gain; the payoff ratio is the average win over the size of the average loss; expectancy is the average return per trade; the per-trade profit factor is the sum of the winning trades' returns over the size of the sum of the losing ones, while the per-day profit factor sums days.
- **Years and volatility**: A year is 252 trading days, the engine's convention: trades per year is round trips over days divided by 252, the CAGR is the growth multiple to the power 252 over the days, and volatility is the sample standard deviation of the daily returns times the square root of 252.
- **Indicator statistics**: The indicator's main output over the window: its last value, its 10th, 50th and 90th percentile (linear interpolation between ranks), and the share of days the rule alone says long, before the delay and any regime filter. Every output of the indicator is also summarized by its median and the share of days below 0.
- **Buy and hold**: The fund held every day of the window with dividends reinvested. The largest one-day gain and loss are the highest and lowest daily returns; the CAGR without the 10 or 30 largest gains (or losses) replaces those days' returns with 0 and recompounds.
- **True range**: The largest of high minus low, |high − previous close| and |low − previous close|. The first bar of the data, which has no previous close, uses high minus low. (`compute` in packages/shared/engine/indicators/atr.ts)
- **Smoothing**: Wilder's average written as an exponentially weighted mean with weight 1/period on the newest bar (alpha = 1/14 by default), normalised over the bars seen so far (the pandas ewm convention with adjust=True). The first value appears on the period-th bar. After a long history this equals Wilder's recursive average; only the first few dozen bars differ from Wilder's simple-average start. (`ewmMeanAlpha` in packages/shared/engine/utils.ts)
- **ATR% (the signal)**: ATR divided by the same bar's close, times 100. This is the indicator's primary output, the value the position rule reads; raw ATR and the true range are computed alongside it. Period from 2 to 200, default 14. (`SPEC` in packages/shared/engine/indicators/atr.ts)
- **Default rule**: Long while ATR% is strictly below 2, otherwise flat (the module's default threshold and direction). (`generatePosition` in packages/shared/engine/positions.ts)
- **Prices**: Daily bars with the dividend-adjusted close; the open, high and low are scaled by each bar's own adjustment factor so the bar stays consistent. Without that scaling a dividend would show up as a false gap in the true range. (`yahooResultToRows` in packages/platform/ohlcv.ts)
- **Timing, costs and cash**: The position decided at a bar's close is applied to the next bar's return (execution delay 1). No trading costs unless set; out of the market the return is 0. (`runBacktest` in packages/shared/engine/backtest.ts)
- **Volatility regime filter**: The backtester's volatility filter recomputes the same true range and the same smoothing, and forces any rule flat on a bar where ATR% is above its maximum or not yet available. (`applyRegimeFilter` in packages/shared/engine/regime_filter.ts)
- **Engine functions**: `computePosition` (packages/shared/engine/run_basic.ts), `generatePosition` (packages/shared/engine/positions.ts), `applyRegimeFilter` (packages/shared/engine/regime_filter.ts), `generateTriggeredPosition` (packages/shared/engine/triggered_position.ts), `runBacktest` (packages/shared/engine/backtest.ts), `getIndicator` (packages/shared/engine/indicators/registry.ts)

## Average true range (ATR) compared with its neighbours

ATR% and other measures of how much a market moves

| Measure | What it uses | Gaps counted | Direction |
| --- | --- | --- | --- |
| ATR% (Wilder) | Daily high, low and previous close, smoothed | Yes | None |
| Standard deviation of returns | Close-to-close returns | Yes, through the close | None |
| Bollinger bandwidth | Standard deviation of closes around their average | Through the close only | None |
| ADX | Directional movement, smoothed | Yes, through the true range | Strength of a trend, not its sign |
| Implied volatility (VIX) | Option prices | Expected, not measured | None |

## Limitations

- ATR has no direction. A high reading comes with crashes and with the sharp rallies inside them, so a rule built on ATR alone steps out of both.
- The threshold is a choice. A level that marks calm for one fund marks turbulence for another, and the same fund's typical ATR% changes from decade to decade; the percentiles in the worked example show where a level sits in this fund's own history.
- The rule re-enters late. Wide daily ranges persist after a bottom, so the first part of a recovery is usually spent in cash.
- The test ignores trading costs, spreads and taxes, earns nothing on cash, and trades at the close of the signal day. A turbulent market is also where real fills are worst.
- The figures describe one historical path of one fund. A handful of crises decide most of the result.

## Frequently asked questions

**What is a good ATR value?**

There is no universal level. ATR% depends on the fund and the period: a broad stock index fund moves several times as far in a day during a crisis as in a quiet year, and funds of different kinds have different normal ranges. Compare a reading with the fund's own history, as the percentiles in the worked example do.

**What is the difference between ATR and standard deviation?**

Both measure how much a price moves. Standard deviation uses the spread of close-to-close returns around their average; ATR uses each day's full range, including moves inside the day and gaps from the previous close, and does not subtract an average. ATR reacts to wide intraday swings that end near where they started; standard deviation does not.

**Why does the true range use the previous close?**

To count gaps. When a price opens far from the previous close, the move between the two is part of what a holder experienced, but it falls outside that day's high and low. Using the previous close stretches the range to include it.

**Why divide ATR by the price?**

Raw ATR is in price units, so it grows as the price grows. Dividing by the close turns it into a percentage that is comparable over decades and across funds, which is what a fixed threshold needs.

**Does a low ATR mean the market is safe?**

No. It means recent days were calm. Calm periods tend to continue, but several large declines started from low volatility, and ATR only rises after the first wide days have happened.

## References

1. Wilder, J. W. (1978) New Concepts in Technical Trading Systems. Trend Research. Introduces the true range, the average true range and Wilder's smoothing.
2. Mandelbrot, B. (1963) The Variation of Certain Speculative Prices. Journal of Business 36(4). Large price changes tend to be followed by large changes: volatility clustering.
3. Moreira, A. and Muir, T. (2017) Volatility-Managed Portfolios. Journal of Finance 72(4). Reducing exposure when recent volatility is high, across many factors.
4. Kaufman, P. J. (2013) Trading Systems and Methods. Wiley, fifth edition. ATR in stops, position sizing and volatility filters.

## Try it

App: https://marketheist.io/backtest/?c=eyJ0aWNrZXIiOiJTUFkiLCJmcmVxdWVuY3kiOiIxZCIsImluZGljYXRvcl9pZCI6ImF0ciIsImluZGljYXRvcl9wYXJhbXMiOnsicGVyaW9kIjoxNH0sInBvc2l0aW9uX3J1bGUiOnsidHlwZSI6InRocmVzaG9sZCIsInRocmVzaG9sZCI6MiwiZGlyZWN0aW9uIjoiYmVsb3cifSwiZXhlY3V0aW9uX2RlbGF5IjoxLCJ0cmFuc2FjdGlvbl9jb3N0c19icHMiOjAsImxldmVyYWdlIjp7Im1vZGUiOiJub25lIn19

MCP prompt (MarketHeist MCP server, https://marketheist.io/mcp):

```
Using MarketHeist.io, backtest SPY on daily bars with ATR% (14): hold SPY while ATR% is below 2, otherwise cash, one-bar delay, no costs, over the last 20 years. Compare CAGR, volatility, maximum drawdown and Sharpe ratio with buy-and-hold.
```

Historical simulation, not advice.
