Constants/probuilder · probacktest · proorder · proscreener

Close

Close returns the closing price of a bar in ProBuilder. Use Close, or Close[N] for the close N bars ago, as a price source in indicators, screeners, and strategies.

Syntax

probuilder
Close

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

How it works

Close reads the last traded price of a bar on the chart's working timeframe. On the current bar it is the price at the moment the bar is evaluated, which on a live, not-yet-closed bar keeps updating until the bar completes.

The bracket offset addresses earlier bars relative to the one being processed. Close[1] is the previous bar's close and Close[20] is the close twenty bars ago. The offset must be a non-negative value that stays within the loaded history, since reaching past the oldest available bar produces an error.

Most indicator functions accept Close as their price input, for example Average[20](Close). Because closing prices carry the weight of end-of-period agreement between buyers and sellers, they are the default input for moving averages, oscillators, and crossover logic.

Examples

Example 1, Close versus its moving average (Indicator)

probuilder
// Compare the current close with a 20-bar average of closes
ma20 = Average[20](Close)
RETURN Close AS "Close", ma20 AS "MA 20"

The indicator plots the raw close alongside a smoothed average, a common base for trend and crossover studies.

Example 2, Screening for a close above the prior high (ProScreener)

probuilder
// Instruments whose latest close exceeds the previous bar's high
breakout = Close > High[1]

SCREENER[breakout] (Close AS "Close")

The screener returns instruments where the most recent close cleared the previous bar's high.

Example 3, Close-based crossover entry (ProOrder)

probuilder
DEFPARAM CumulateOrders = false

fast = Average[10](Close)
slow = Average[30](Close)

// Enter long when the close-based fast average crosses above the slow one
IF fast CROSSES OVER slow THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

IF fast CROSSES UNDER slow THEN
  SELL AT MARKET
ENDIF

Both averages use Close as their input, so the crossover reflects movement in closing prices.

Common errors and gotchas

  • Offset out of range. Close[N] fails when N points before the first loaded bar. Guard long lookbacks with a BarIndex check or ensure enough history is loaded.
  • Live bar keeps moving. On the current, unfinished bar Close equals the latest tick, so a condition can flip several times before the bar closes. For confirmed signals compare Close[1] or wait for the bar to complete.
  • Not the same as CustomClose. Close is always the true closing price, while CustomClose follows the price source selected in the chart settings and may differ.
  • Open, the opening price of a bar.
  • High, the highest price of a bar.
  • Low, the lowest price of a bar.
  • Volume, the traded volume of a bar.
  • CustomClose, the user-selectable price source, close by default.
  • MedianPrice, the average of high and low.
  • TypicalPrice, the average of high, low, and close.
  • DClose, the closing price of a past daily bar.