Constants/probuilder · probacktest · proorder · proscreener

Open

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

Syntax

probuilder
Open

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

How it works

Open reads the first traded price of a bar on the chart's working timeframe. Unlike the close, the open is fixed the instant the bar begins and does not change while the bar is still forming.

The bracket offset addresses earlier bars relative to the one being processed. Open[1] is the previous bar's open and Open[20] is the open twenty bars ago. The index must stay within the loaded history, since referencing a bar before the first available one produces an error.

The open is often paired with the close to describe the direction of a bar. A bar where Close > Open closed higher than it opened, while Close < Open closed lower. Gap logic also uses the open, comparing the current Open against the previous Close.

Examples

Example 1, Bar body direction (Indicator)

probuilder
// 1 when the bar closed above its open, -1 when it closed below
IF Close > Open THEN
  direction = 1
ELSIF Close < Open THEN
  direction = -1
ELSE
  direction = 0
ENDIF
RETURN direction AS "Bar direction"

The indicator reports whether each bar closed above, below, or level with its opening price.

Example 2, Screening for gap-up opens (ProScreener)

probuilder
// Instruments that opened above the previous bar's close
gapUp = Open > Close[1]

SCREENER[gapUp] (Open AS "Open")

The screener returns instruments whose latest bar opened above the prior close, a simple gap-up filter.

Example 3, Entry on a strong opening bar (ProOrder)

probuilder
DEFPARAM CumulateOrders = false

// Open above the previous close by more than a small threshold
gapSize = Open - Close[1]

IF gapSize > 0 AND Close > Open THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

SET STOP %LOSS 1.5

The rule combines a positive gap at the Open with a bar that continued upward into the close.

Common errors and gotchas

  • Offset out of range. Open[N] fails when N points before the first loaded bar. Guard deep lookbacks with a BarIndex check or load more history.
  • Open is fixed, close is not. The open is set when the bar starts and stays constant, so comparisons against it are stable within the bar, unlike comparisons against a live close.
  • Gaps depend on timeframe. On intraday charts the difference between Open and Close[1] reflects the gap over the chart's bar interval, which may not match the overnight session gap.
  • Close, the closing 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.
  • Range, the high minus low of a bar.
  • TotalPrice, the average of open, high, low, and close.
  • DOpen, the opening price of a past daily bar.