TR
TR in ProBuilder returns the True Range of a bar, the widest of three spreads built from high, low and previous close, measuring volatility. Examples inside.
Syntax
TR(price)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
price | price source | close | Price series passed to the function, commonly close. The range itself is derived from the bar's high, low and the previous close. |
Formula
TR = MAX(high - low,
ABS(high - close[1]),
ABS(low - close[1]))The absolute values matter when the bar gaps entirely above or below the previous close. In that case the distance from the previous close, not the bar's own high-low span, defines the true range.
How it works
The plain Range of a bar (high minus low) understates volatility whenever the market gaps. If a bar opens far above the previous close, the price actually travelled from that close to the new levels, even though the bar body never covered the gap. True Range fixes this by including the previous close in the comparison, so overnight gaps and limit moves are counted as movement.
The output is expressed in price units of the instrument. On its own, a single TR value is noisy, one wide bar is enough to spike it. For that reason it is almost always smoothed over a number of bars, which is exactly what AverageTrueRange does with Wilder smoothing. Raw TR remains useful when per-bar detail matters, for example when detecting individual expansion bars or building custom volatility measures with a different smoothing method.
Because the first bar of the data series has no previous close, the earliest value falls back on the information available for that bar. Calculations that reference history should allow a warm-up period.
Examples
Example 1, Raw true range of each bar (Indicator)
// True range of the current bar, in price units
variable1 = TR(close)
RETURN variable1Plots the true range bar by bar. Spikes mark bars with unusually wide movement, including gap opens that a simple high minus low range would miss.
Example 2, Volatility scaled stop distance (ProBacktest)
// Smooth the raw true range to size the protective stop
myTR = TR(close)
smoothTR = Average[14](myTR)
IF NOT ONMARKET AND close CROSSES OVER Average[50](close) THEN
BUY 1 CONTRACT AT MARKET
SET STOP LOSS 2 * smoothTR
ENDIFThe stop is placed two smoothed true ranges away from entry, so its distance widens in volatile markets and tightens in quiet ones instead of being a fixed number of points.
Example 3, Range expansion scan (ProScreener)
myTR = TR(close)
avgTR = Average[20](myTR)
SCREENER[myTR > 2 * avgTR] (myTR AS "True Range")Returns instruments whose current bar covers more than twice their average true range of the last 20 bars, a simple way to surface breakout candidates and news-driven moves.
Interpretation
Higher TR values mean larger price excursions per bar, in other words higher short-term volatility. There are no fixed thresholds, the measure is in absolute price units, so a TR of 5 is enormous on one instrument and negligible on another. Comparisons are meaningful against the instrument's own recent history, typically as a ratio to an average such as TR(close) / Average[20](TR(close)). Rising TR often accompanies breakouts and news events, contracting TR characterises consolidation phases.
Common errors and gotchas
- Confusing TR with Range.
Rangeis only high minus low. On a gap open the two diverge substantially, and TR is the correct measure of actual movement. - Using raw TR where ATR is intended. A single bar's true range is noisy. Position sizing and stop placement logic normally use
AverageTrueRangeor an explicit average ofTR, not the raw value. - Comparing TR across instruments. TR is expressed in the instrument's price units. Screeners that rank different markets on raw TR mostly rank price levels. Divide by price or by the instrument's own average TR first.
- First bar has no previous close. The formula references
close[1], which does not exist on the first bar of loaded history, so the earliest values are not meaningful. Ignore the warm-up bars.
Related instructions
AverageTrueRange, Wilder-smoothed average of TR, the standard ATR indicator.Range, plain high minus low of the bar, ignores gaps.High, highest price of the current bar.Low, lowest price of the current bar.Highest, highest value of a series over N bars.Lowest, lowest value of a series over N bars.STD, standard deviation, an alternative volatility measure.HistoricVolatility, statistical volatility computed from returns.Volatility, Chaikin Volatility based on the high-low spread.
