Indicators/probuilder · probacktest · proorder · proscreener

AverageTrueRange

AverageTrueRange in ProBuilder returns the ATR, a volatility measure based on Wilder's smoothed True Range over N bars. Syntax, formula, worked examples.

Syntax

probuilder
AverageTrueRange[N](price)

Parameters

NameTypeDefaultDescription
Ninteger14Smoothing period in bars. 14 is Wilder's original setting. Shorter periods track volatility shifts faster, longer periods give a steadier baseline.
priceprice sourceclosePrice series passed to the function, conventionally close.

Formula

code
TR  = Max(High - Low, Abs(High - Close[1]), Abs(Low - Close[1]))
ATR = WilderAverage[N] of TR

The True Range is the greatest of three distances: the current bar's range, the distance from the previous close to the current high, and the distance from the previous close to the current low. The two close-based terms fold overnight gaps into the measurement. The smoothing uses Wilder's method, an exponential average with alpha = 1/N.

How it works

A plain high-minus-low range understates volatility whenever the market gaps, because the move happened between bars rather than inside one. The True Range fixes this by anchoring the measurement to the previous close, so a bar that opens far from yesterday's close registers the full jump.

Smoothing the True Range over N bars produces a stable per-bar movement estimate expressed in price units. Because ATR is denominated in the instrument's own units, a reading of 25 points means something entirely different on an index than on a currency pair. For cross-instrument comparisons, ATR is usually divided by price to get a percentage.

ATR carries no directional information. Rising ATR means larger bars and gaps, whether the market is climbing or collapsing. Its main practical roles are position sizing, stop placement, and volatility filtering, all of which need a movement estimate rather than a direction estimate.

Examples

Example 1, Plotting the 14-period ATR (Indicator)

probuilder
// 14-bar Average True Range, drawn in dark red
ATR = AverageTrueRange[14](close)
RETURN ATR coloured(100,0,0)

The standard configuration. Rising values indicate expanding volatility, falling values indicate contraction.

Example 2, ATR-based stop distance (ProOrder)

probuilder
// Long breakout entry with a stop placed 2 ATR below entry
atr = AverageTrueRange[14](close)

IF NOT LongOnMarket AND close CROSSES OVER Highest[20](high)[1] THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

// Stop loss expressed as a price distance
SET STOP LOSS atr * 2

The stop distance scales with current volatility: wide in fast markets, tight in quiet ones. This keeps the risk per trade proportional to how much the instrument actually moves.

Example 3, Screening for volatility expansion (ProScreener)

probuilder
// Instruments whose ATR has grown at least 50% above its quarterly norm
atrNow  = AverageTrueRange[14](close)
atrBase = Average[60](atrNow)
SCREENER[atrNow > atrBase * 1.5]((atrNow / close) * 100 AS "ATR % of price")

Returns instruments in a volatility expansion phase, ranked by ATR as a percentage of price so different markets are comparable.

Interpretation

ObservationReading
ATR risingBars and gaps are getting larger, volatility is expanding. Common around breakouts and panics.
ATR fallingMovement is contracting. Extended contractions often precede directional expansion.
ATR high vs its own historyWide stops and smaller position sizes are appropriate.
ATR low vs its own historyBreakout setups become more interesting, ranges are compressing.

Because ATR is unbounded and instrument-specific, all interpretation is relative to the instrument's own recent readings, not to fixed thresholds.

Common errors and gotchas

  • Wrong bracket type. AverageTrueRange(14) and AverageTrueRange(14, close) fail. The period goes in square brackets, the price source in parentheses: AverageTrueRange[14](close).
  • Comparing raw ATR across instruments. ATR is in price units. An ATR of 50 on one market and 0.005 on another says nothing until both are normalised, typically as atr / close * 100.
  • Using ATR as a direction signal. ATR rises in crashes just as it does in rallies. Logic like buying because ATR increases confuses volatility with trend.
  • Timeframe changes rescale everything. The same instrument has a completely different ATR on 5-minute and daily bars. Stop distances and filters tuned on one timeframe must be re-derived after switching.
  • TR, the raw True Range before smoothing.
  • Volatility, alternative built-in volatility measure.
  • HistoricVolatility, statistical volatility from log returns.
  • STD, standard deviation of price over a window.
  • Supertrend, trend-following level built on ATR.
  • KeltnerBandUp, volatility channel using average range.
  • ChandeKrollStopUp, ATR-based trailing stop level.
  • Highest, highest value over a lookback, used in breakout logic.
  • Lowest, lowest value over a lookback window.