Constants/probuilder · probacktest · proorder · proscreener

Range

Range returns the high minus low of a bar in ProBuilder, its full price span. Use Range or Range[N] to measure per-bar volatility in indicators and strategies.

Syntax

probuilder
Range

Range[N] returns the span N bars back, where N is 0 for the current bar, 1 for the previous bar, and so on. Range and Range[0] are equivalent.

How it works

Range is the difference between the bar's high and low, High - Low. It measures how much price moved between the extremes of a single bar, so a wide range signals an active bar and a narrow range a quiet one.

The bracket offset addresses earlier bars, so Range[1] is the previous bar's span. The index must stay within the loaded history.

Unlike the true range, Range looks only at the current bar and ignores any gap from the previous close. For volatility that accounts for gaps, use TR or AverageTrueRange. On the live bar the range grows as the high or low extends until the bar closes.

Examples

Example 1, Range versus its average (Indicator)

probuilder
// Compare the current bar's span with its recent average
avgRange = Average[20](Range)
RETURN Range AS "Range", avgRange AS "Avg range 20"

The indicator highlights bars whose span runs above or below the recent norm.

Example 2, Screening for range contraction (ProScreener)

probuilder
// Latest range narrower than the previous bar, with a lower high
contracting = Range < Range[1] AND High < High[1]

SCREENER[contracting] (Range AS "Range")

The screener returns instruments whose bar span is contracting alongside a lower high.

Example 3, Avoiding entries on wide bars (ProOrder)

probuilder
DEFPARAM CumulateOrders = false

avgRange = Average[20](Range)

// Skip signals when the current bar is unusually wide
IF Close CROSSES OVER Average[20](Close) AND Range < 1.5 * avgRange THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

SET STOP %LOSS 2

The filter blocks entries when the current Range is much larger than average, avoiding overextended bars.

Common errors and gotchas

  • Ignores gaps. Range is high minus low of one bar only. It does not include the gap from the prior close, so it can understate volatility around gaps. Use TR for a gap-aware measure.
  • Live bar grows. On the current bar the range keeps widening until close, so comparisons against completed bars are uneven until the bar finishes.
  • Offset out of range. Range[N] fails when N points before the first loaded bar. Guard long lookbacks or load more history.
  • High, the highest price of a bar.
  • Low, the lowest price of a bar.
  • TR, the true range, which accounts for gaps.
  • AverageTrueRange, a smoothed true range over several bars.
  • Close, the closing price of a bar.
  • Open, the opening price of a bar.
  • TypicalPrice, the average of high, low, and close.
  • Volume, the traded volume of a bar.