Advanced Trading Tutorial — Range Overlap Oscillator in ProRealTime
When consecutive candles repeatedly trade through the same price area, the market may be consolidating. When their ranges migrate into new territory, overlap can decline. This tutorial measures the geometry of adjacent completed price intervals, then smooths the observations to create a bounded ProBuilder oscillator. Unlike momentum, it does not assign a bullish or bearish direction.
Mathematical definition
For two adjacent completed candles, calculate the shared interval as the smaller high minus the larger low, floored at zero. Divide this by the enclosing span, defined as the larger high minus the smaller low, and multiply by 100. For overlapping intervals the enclosing span equals their union length; for disjoint intervals it includes the gap, but the numerator is already zero. A zero span is assigned zero by convention. Average the most recent N pair scores to reduce the influence of individual candles.

Worked examples
For intervals [100,110] and [105,115], the shared range is 5 and the enclosing span is 15, giving 33.33%. Identical nonzero intervals produce 100%. Disjoint intervals [100,104] and [106,110] produce zero. A contained interval [102,108] within [100,110] gives 60%. If three successive pair scores are 33.33%, 100% and 0%, their arithmetic average is approximately 44.44%. These examples are hypothetical and illustrate calculation rather than market performance.
Native ProBuilder implementation
The code uses historical offsets one and two, MAX and MIN for interval boundaries, and Average for smoothing. The current forming candle is deliberately excluded. The first complete averaging window requires N+1 earlier candles, so the output remains undefined until sufficient history is available. The reference line at 50 is illustrative and does not represent an optimized threshold.
// ProBuilder custom indicator
// Change n to a positive integer for the averaging window.
n = 10
score = 0
IF BarIndex >= 2 THEN
// Only use the two preceding completed bars.
shared = MAX(0, MIN(High[1], High[2]) - MAX(Low[1], Low[2]))
span = MAX(High[1], High[2]) - MIN(Low[1], Low[2])
IF span > 0 THEN
score = 100 * shared / span
ENDIF
ENDIF
smoothScore = Average[n](score)
IF BarIndex < n + 1 THEN
result = Undefined
ELSE
result = smoothScore
ENDIF
RETURN result AS "Range overlap", 50 AS "Reference"
Installation and configuration
In ProRealTime open the indicator creation interface, create a new ProBuilder indicator named RangeOverlapOscillator and paste the source. Validate the code and add it to a separate indicator panel. The default smoothing length is ten; edit n in the source to experiment with other positive integer lengths. If you expose n through the platform's variable configuration instead, remove the hard-coded assignment. Ensure the chart contains enough history for the requested period.
Closed-bar timing and repainting
The value at bar t describes adjacent pairs ending no later than t−1. It therefore becomes available when the next bar is recognized and does not depend on the developing high or low of bar t. The code does not use future references or centered averages. Under ordinary operation it does not intentionally repaint completed observations, although data corrections and changes to synthetic bar construction may alter historical values. When comparing this indicator to a current-bar oscillator, account for the deliberate one-bar alignment difference.
Testing and research limitations
First verify the interval examples manually. Set n to one to inspect individual pair scores, then restore a longer smoothing period. Check identical intervals, partial overlap, containment, disjoint intervals and zero-span pairs. Observe the indicator during a forming candle and after a chart reload. Compare results only under consistent instrument, timeframe and session settings. The code has not been compiled or executed in ProRealTime here.
High overlap does not necessarily mean low absolute volatility: two wide candles can share most of their ranges. Low overlap does not guarantee a trend, because alternating gaps or erratic moves can also reduce overlap. The indicator ignores volume, close location and transaction costs. Consider independent range and directional measures when designing research hypotheses. Validate any proposed thresholds on independent data rather than treating the reference line as a trading rule.
For custom alerts, adaptive smoothing or integration into a trading system, contact our Custom ProRealTime indicator Development Services.
Risk disclosure: educational material only. Trading involves risk of loss; hypothetical examples do not establish profitability.