Intermediate Trading Tutorial | ProBuilder
An opening gap tells us where the next candle began relative to the preceding close. It does not tell us how much of that discontinuity was subsequently revisited. Two instruments can both gap upward by four points, yet one may trade all the way back to the prior close while the other barely retraces. A gap-fill percentage separates these two observations without confusing the direction of the opening move with the distance subsequently covered.
This tutorial implements a small, transparent ProBuilder indicator that measures the gap fill achieved during one completed candle. It is an audit of price behavior, not a forecast of an eventual gap closure. The indicator uses only OHLC data, has no dependencies on other studies, and produces two outputs so a nonqualifying gap cannot be mistaken for a qualifying gap with no retracement.
1. Define exactly what the measurement means
For a completed candle, let P be the close of its predecessor, O its open, H its high and L its low. The signed gap is O minus P. Its absolute size is the denominator. For a positive gap, the distance revisited is O minus L. For a negative gap, it is H minus O. Divide the revisited distance by the absolute gap, clamp the result to the interval from zero to one, and multiply by 100.
The clamp is essential. If a candle crosses the preceding close and continues beyond it, the original gap has already been filled. A value of 140% would mix gap closure with a different question: how far price extended beyond the reference. This indicator deliberately caps the output at 100%. For a separate extension study, use the excess distance beyond P rather than changing the meaning of the percentage.
A minimum opening gap of 0.10% of the absolute preceding close is required by default. This is a simple filter for very small gaps, rather than a claim that 0.10% is optimal for every instrument. A gap exactly equal to the threshold qualifies. If the gap is zero, the reference close is zero, or fewer than two prior bars are available, both outputs remain zero.

2. Work through the numbers before writing the code
| Case | Prior close | Open | Relevant extreme | Fill |
|---|---|---|---|---|
| Up | 100 | 104 | Low 101 | 75% |
| Down | 100 | 96 | High 99 | 75% |
| Up, fully filled | 100 | 104 | Low 99 | 100% |
| Up, no retracement | 100 | 104 | Low 104 | 0% |
| Tiny gap | 100 | 100.05 | Low 100 | 0%, excluded |
For the first row, the gap is four points and the measured retracement is three. The low remains one point above the preceding close, so the gap is not entirely closed. In the second row the high is one point below that reference and the same three-fourths ratio applies. In the third row the uncapped calculation is 125%, but the output is 100%. In the fourth and fifth rows the plotted fill is identical, yet the eligibility output differs: it is 100 for the valid untouched gap and zero for the excluded gap. Treat the eligibility value as a Boolean flag encoded at the same vertical scale, not as another fill measurement.
3. Complete ProBuilder indicator source
// Closed-bar single-candle gap fill audit
// Result appears on the bar AFTER the measured candle.
minGapPct = 0.10
fillPct = 0
qualified = 0
IF BarIndex >= 2 THEN
referenceClose = Close[2]
gapDistance = Open[1] - referenceClose
gapSize = ABS(gapDistance)
IF ABS(referenceClose) > 0 AND gapSize > 0 THEN
relativeGap = 100 * gapSize / ABS(referenceClose)
IF relativeGap >= minGapPct THEN
qualified = 100
IF gapDistance > 0 THEN
retracement = Open[1] - Low[1]
ELSE
retracement = High[1] - Open[1]
ENDIF
fillPct = 100 * MIN(1, MAX(0, retracement / gapSize))
ENDIF
ENDIF
ENDIF
RETURN fillPct AS "Gap fill %", qualified AS "Eligible (100/0)"
The source is written for the custom indicator environment, not ProOrder. The RETURN statement exposes the two named series. The code resets both outputs on every evaluation so a previous qualified event does not carry forward into a bar with no eligible gap. The threshold is an editable constant in the source. If you prefer a settings-window input, create a dynamic numeric variable in the indicator editor, give it a default of 0.10, and remove the assignment in the source so the variable is not overwritten.
4. Why the series is shifted by one bar
In an indicator that reads the current High or Low, the measured fill can increase while the candle is being built. That behavior is legitimate for a real-time tracker, but it can make comparisons against historical completed bars misleading. This version deliberately reads Open[1], Low[1] and High[1]. Close[2] belongs to the preceding candle. When a new candle begins, the audited candle has already finished and its extreme is known. No future price is used to determine the reported value.
There is a visible consequence: the value is plotted on the next candle. Do not interpret that location as the opening time of the measured gap, or use the completed result as though it had been available at the gap candle's open. On a daily chart, a Monday gap's fill is normally displayed on the next available trading candle, not necessarily the next calendar day. For a trading system, the earliest practical decision is when that confirmed information is available, with execution modeled according to the order mechanism and market conditions.
5. Installation and display
- Open the custom indicators area in ProRealTime and create a new personal ProBuilder indicator.
- Paste the complete source and give the study a recognizable name.
- Use the editor's syntax validation and add it in a separate indicator panel.
- Choose distinguishable colors for the gap-fill and eligibility series. A histogram is useful for the fill; a thin gray line or a separate view can make the eligibility flag easier to see.
- Compare several historical values against the chart's actual open, high, low and preceding close using its data cursor.
The implementation follows the documented ProBuilder historical-reference and RETURN conventions. It has not been compiled or run inside ProRealTime here. Consult the platform's personal indicators guide for editor operations.
6. Parameter and data tradeoffs
On an intraday chart, this code checks every adjacent pair of chart bars. It does not automatically isolate the cash-market opening auction. If you need only the first regular-session candle, add a session boundary test adapted to the exchange calendar and chart time zone. With extended hours enabled, the preceding close can be an overnight bar rather than the regular-session close. A daily chart with the intended session template is a sensible initial environment for checking overnight gaps.
A percentage threshold makes comparisons across price levels easier, but it is not volatility adjusted. A small percentage may be substantial in a quiet market and insignificant in a volatile one. Test a threshold expressed in ticks or a fraction of prior ATR if the trading objective demands a different definition; use only already-known volatility values. Raising the threshold reduces the number of eligible observations, and may remove otherwise useful small-gap behavior. Lowering it magnifies rounding and feed differences.
Check the treatment of corporate actions, adjusted prices, futures contract rolls and missing bars. An apparent gap may be a data discontinuity rather than a tradable event. For instruments with a zero reference price, the percent filter is deliberately undefined and the observation is excluded. Negative prices use the absolute reference in the filter. OHLC records reveal whether an extreme reached a level, but not the full intrabar sequence, available liquidity, spread, or executable fills.
7. Validation checklist and practical limitations
- Verify the first two output bars are zero and history references are available before computing.
- Test upward and downward gaps with partial, complete and zero retracement, and a gap exactly at the threshold.
- Verify the eligible flag distinguishes a valid 0% result from an excluded observation.
- Observe the indicator during a forming bar: the audited prior candle's reading should remain unchanged unless the provider corrects historical data.
- Compare identical session definitions in historical and live views, and record whether the chart uses adjusted data.
- Do not assume that a 100% historical reading indicates an order could have executed at the reference close.
To study multi-day gap closure, maintain the original gap reference in a separate state machine until closure or expiry; do not silently interpret the one-candle measurement as lifetime closure. This study can serve as a feature for research, but does not establish profitable entries, exits, or position sizing. Include transaction costs, slippage and out-of-sample testing before using any derived trading rule.
If you are interested in this free indicator or would like session-specific logic, alert integration, or a customized multi-bar version, contact us for Custom ProRealTime Development Services.