Part of the Indicator Math series. This post walks through the gap-adjusted range and Wilder smoothing inside Average True Range (ATR).

Why High minus Low misses half the story

Suppose a stock closes Friday at $509.00, gaps down Monday to open at $504.00, and trades between $507.50 and $502.50 all session. Measuring Monday’s candle alone with High minus Low gives $5.00, even though weekend holders saw a $6.50 drop from Friday’s close to Monday’s low. In commodity futures with daily price limits, a contract that trades at a single limit-up price throughout the session prints High equal to Low, making its single-bar range look like zero on an extreme move.

Average True Range (ATR) closes that blind spot without making any directional claim. It answers one plain-English question: how far does this market typically travel per bar in price units, counting any gap from the previous close?

The ATR formula

Mechanical engineer J. Welles Wilder Jr. introduced True Range and Average True Range in his 1978 book New Concepts in Technical Trading Systems, alongside RSI, ADX, and Parabolic SAR. As StockCharts ChartSchool notes, Wilder designed ATR for daily commodity charts where overnight gaps and limit moves hid volatility from High-minus-Low averages. While Wilder often used an 8-period ATR in his own work, 14 periods became the standard charting default on TradingView, StockCharts, and most platforms.

Calculating ATR takes two steps: find each bar’s True Range (TR), then smooth True Range with Wilder’s recursive average.

True Range (TR) = max of:
  1. High − Low
  2. |High − Previous Close|
  3. |Low − Previous Close|

First ATR (bar N) = (Sum of first N TR values) ÷ N

Subsequent ATR    = ((Prior ATR × (N − 1)) + Current TR)
                    ÷ N

Every term in those equations has a specific job:

  • True Range’s three comparisons: Whenever the previous close sits between today’s High and Low, High minus Low is the largest of the three numbers. If price gaps above the previous close and stays higher, |High − Previous Close| stretches the range down to yesterday’s close. If price gaps below the previous close and stays below, |Low − Previous Close| stretches the range up to yesterday’s close. Equivalently, True Range equals max(High, Previous Close) minus min(Low, Previous Close). On the first bar of a dataset with no prior close, True Range equals High minus Low.
  • Seed value at bar N: Standard Wilder ATR takes the simple arithmetic mean of the first N True Range values as its starting value on bar N.
  • Wilder’s smoothing vs. a simple average: Rewrite Wilder’s update step to see its moving-average weights directly:
Wilder ATR = (1 ÷ N) × Current TR
           + ((N − 1) ÷ N) × Prior ATR

As TA-Lib’s RMA reference (added in TA-Lib 0.8.1 and matching TradingView Pine’s ta.rma) explains, Wilder’s smoothing is an exponential moving average with smoothing factor α = 1 ÷ N rather than a classic EMA’s 2 ÷ (N + 1). At N = 14, Wilder’s formula puts 1 ÷ 14 (about 7.14%) weight on the newest bar and 13 ÷ 14 (about 92.86%) on the prior average. Because 2 ÷ (27 + 1) also equals 1 ÷ 14, a 14-period Wilder average and a 27-period EMA apply the exact same per-bar decay from the first update onward, while their different initial seeds leave a small gap that shrinks over subsequent bars. That makes Wilder ATR calmer than a 14-bar SMA of True Range and avoids a sudden drop 14 bars after a single shock candle leaves a fixed window.

Notice the shared math across Wilder’s 1978 indicators: this α = 1 ÷ N recursive average is the exact same smoothing used inside RSI (smoothing upward and downward close changes) and inside ADX and DMI (smoothing True Range, directional movement, and DX). TradingView also lets you change ATR’s smoothing to SMA, EMA, or WMA, so keep it on RMA when matching standard Wilder values.

A worked example by hand

Let’s compute 14-period ATR across 15 hypothetical daily bars near $500, including one gap-up session (Day 4) and two gap-down sessions (Days 9 and 15):

DayHighLowClosePrev CloseTrue Range
1501.60500.00501.00–1.60
2503.50500.50502.50501.003.00
3504.00501.50503.00502.502.50
4507.00505.00506.50503.004.00
5508.00505.50506.00506.502.50
6506.50503.50504.00506.003.00
7505.90502.50504.50504.003.40
8506.00503.50505.50504.502.50
9503.00500.50501.00505.505.00
10502.50499.50502.00501.003.00
11504.00501.50503.50502.002.50
12505.50503.00505.00503.502.50
13507.00504.00506.50505.003.00
14509.50506.00509.00506.503.50
15507.50502.50503.00509.006.50

Check all three True Range cases. On Day 2, the prior close (501.00) sits inside the 500.50–503.50 bar, so High minus Low wins (3.00). On Day 4, price gaps above 503.00 into a 505.00–507.00 range; High minus Low is 2.00, while |507.00 − 503.00| captures the 4.00-point span. On Day 15, price gaps down from 509.00 to 502.50–507.50, so |502.50 − 509.00| = 6.50 beats the 5.00 candle height.

Day 14 Seed ATR(14) (Days 1–14):
  Sum of Days 1–14 TR = 42.00
  Day 14 ATR(14)      = 42.00 ÷ 14 = 3.00

Day 15 Wilder ATR(14):
  Day 15 ATR = ((3.00 × 13) + 6.50) ÷ 14
             = 45.50 ÷ 14 = 3.25

Day 15 Simple Average of TR (Days 2–15):
  Day 15 SMA = (42.00 − 1.60 + 6.50) ÷ 14
             = 46.90 ÷ 14 = 3.35

Compare the two Day 15 readings. A 14-bar simple average drops Day 1’s quiet 1.60 bar completely and jumps to 3.35. Wilder’s smoothing blends 1 ÷ 14 of Day 15’s 6.50 spike with 13 ÷ 14 of the 3.00 prior reading, lifting ATR by (6.50 − 3.00) ÷ 14 = 0.25 to 3.25.

What ATR actually measures

ATR measures smoothed, gap-inclusive bar range in raw price units (dollars on a stock or ETF, index points on ES or NQ). When candles stretch and overnight gaps widen, ATR climbs; when bars overlap tightly, ATR drifts lower.

The chart below shows daily SPY candles with Wilder’s ATR(14) from December 19, 2025 through November 19, 2026. Calm winter sessions compressed ATR(14) to 5.66 on January 16, whereas wide selloff bars in March and again in November lifted ATR(14) to 12.21 on November 19.

SPY daily candles with ATR(14) below; ATR rises during the March and November declines and falls in calm stretches.
SPY daily, Dec 19, 2025–Nov 19, 2026, with Wilder ATR(14): ATR ranged from 5.66 (Jan 16) to 12.21 (Nov 19), rising in each selloff.

In that SPY window, ATR climbed during the March and November declines, yet wide upside bars or gap-up rallies lift ATR in the exact same way. Keep clear what ATR does not measure:

  • Trend direction: Every input is nonnegative. If two price series start from the same seed ATR and print the exact same sequence of True Ranges, their ATR paths are identical whether price is rallying or selling off.
  • Cross-ticker percentage volatility: Because ATR stays in price units, a $500 stock with a $7.50 ATR (1.5% of price) prints a larger raw ATR than a $40 stock with a $1.60 ATR (4.0% of price). To compare across tickers or multi-year price levels, divide by close using Average True Range Percent (ATRP): (ATR ÷ Close) × 100.
  • Close dispersion around a mean: Unlike Bollinger Bands, ATR ignores how far closes sit from a moving average. A steady stair-step trend where every bar prints a $3 True Range (with the prior close inside each bar) keeps ATR at $3 while Bollinger Bands widen.

How traders use it

ATR belongs in the stop, sizing, and filter rules of a plan rather than the directional trigger:

  • Volatility-padded structural stops: Anchor invalidation at a swing high or low first, then add a tested buffer such as 0.5 × to 1.5 × ATR(14) beyond that level so routine bar noise is less likely to clip your stop-loss; when sizing that trade, use the entire entry-to-stop distance (structure distance plus the ATR buffer), and match ATR’s timeframe to the bars you hold.
  • Direct ATR stops and futures position sizing: For systems that place a stop directly at k × ATR from entry, divide fixed dollar risk per trade by (k × ATR × Dollars per Point) and round down to whole contracts so position size scales down when volatility rises. Planned price-only risk of $150 (before fees and slippage) with a 2 × ATR stop on 5-minute MES ($5 per point) allows 3 contracts when ATR is 5 points ($150 ÷ (10 × $5) = 3), and drops to 1 contract when ATR widens to 12 points ($150 ÷ (24 × $5) = 1.25, rounded down to 1).
  • Ratcheted trailing stops and ATR targets: Compute a long candidate stop on each closed bar as Highest High (or Highest Close) since entry minus k × ATR(14), then set the active stop to max(Prior Stop, Candidate Stop) so a jump in ATR without a new high cannot move the stop backward. Pair that with exit targets at fixed multiples such as 1.5 × and 3.0 × entry ATR (used in the ATR Trailing Stop with ATR Targets script on the TRDR Zone indicators page); trailing ATR stops require sustained trends and get tagged repeatedly in chop.
  • Intraday range and expansion filters: On ES or NQ setups, compare a breakout bar’s True Range against the prior completed 5-minute ATR(14) (such as requiring TR > 1.5 × prior ATR) so the breakout bar does not enter its own threshold. You can also test passing on late-day breakouts once regular-hours travel exceeds the prior completed daily ATR(14) during session windows. Keep consistent whether your daily chart includes overnight Globex data, and treat that threshold as a testable filter rather than proof a move is exhausted.

Where it fails

Intraday session transitions distort short-timeframe ATR. On continuous ES or NQ charts, quiet overnight Globex bars feed small True Ranges into 5-minute ATR(14) up to 9:30 a.m. Eastern. Sizing a 9:35 a.m. cash-open stop off overnight ATR sets the stop for premarket drift right as regular-hours volume widens ranges; after the afternoon close, regular-hours bars leave intraday ATR overstated for slow evening trade.

Slow bar-by-bar decay across volatility shifts. Because Wilder’s α = 1 ÷ 14 sheds old data at the same per-bar rate as a 27-bar EMA, a single FOMC candle or earnings gap keeps ATR elevated across dozens of subsequent bars (weeks on a daily chart, hours on a 5-minute chart), widening stops and shrinking ATR-sized positions even if subsequent bars calm down. Conversely, on the first bar of a sharp selloff after a long quiet stretch, trailing ATR understates the new volatility.

Warm-up history and unclosed bars. Recursive Wilder ATR retains a diminishing trace of its initial 14-bar seed (StockCharts ChartSchool calculates at least 250 prior bars so short spreadsheet excerpts do not drift from chart values). And while a candle is still open, High minus Low can only widen or stay flat tick by tick, never shrink, so read ATR on completed bars.

Takeaway: Average True Range extends each bar’s High-minus-Low span to include any gap from the prior close, then smooths those True Ranges with Wilder’s 1 ÷ N recursive average. It measures typical bar travel in raw price units — never direction — giving you a consistent ruler for stop buffers, ratcheted trailing exits, and volatility-adjusted contract sizing once price structure defines the trade.

Next up: ADX and DMI: Measuring Trend Strength, Not Direction

One thought on “ATR: The Math Behind Average True Range”

Leave a Reply