Constants/probuilder · probacktest · proorder · proscreener

DClose

DClose returns the closing price of a daily bar in ProBuilder. Use DClose(N) to read the close N days ago on any timeframe, without switching to daily bars.

Syntax

probuilder
DClose(N)

N is a non-negative value giving the number of days back. DClose(0) is the current day, DClose(1) is the previous trading day, and so on.

How it works

DClose reads the closing price of a daily bar even when the chart runs on an intraday timeframe. On a one-hour chart, DClose(1) returns yesterday's daily close rather than the close of a single one-hour bar.

The argument uses parentheses and counts in trading days. On the current day, DClose(0) tracks the latest price and settles only at the end of the session, so it behaves like a live value until the day completes. N must stay within the loaded daily history, otherwise the call errors.

Previous daily closes are common reference points: gap measurement, prior-day pivots, and percentage change over days all build on DClose(1) and earlier values. It pairs with DOpen, DHigh, and DLow to reconstruct entire daily bars from within any timeframe.

Examples

Example 1, Percentage change from yesterday's close (Indicator)

probuilder
// Move of the current price versus the previous daily close, in percent
prevClose = DClose(1)
pct = (Close - prevClose) / prevClose * 100
RETURN pct AS "Change vs prev close %"

The indicator expresses the current price as a percentage move from yesterday's close.

Example 2, Screening for strength over five days (ProScreener)

probuilder
// Current price above the daily close of five days ago
stronger = Close > DClose(5)

SCREENER[stronger] (DClose(5) AS "Close 5d ago")

The screener returns instruments trading above their close from five trading days back.

Example 3, Bias from the prior daily close (ProOrder)

probuilder
DEFPARAM CumulateOrders = false

// Only take longs while price holds above yesterday's close
IF Close > DClose(1) AND Close CROSSES OVER Average[20](Close) THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

SET STOP %LOSS 1.5

The entry requires price above DClose(1), using the previous daily close as a directional filter.

Common errors and gotchas

  • Parentheses, not brackets. DClose takes its argument in parentheses like DClose(1). Square brackets are a syntax error.
  • Today is not settled. DClose(0) is the current day's price and keeps changing until the session ends. For a fixed value use DClose(1) or earlier.
  • Needs daily history. A large N requires enough loaded daily data, or the reference errors.
  • DOpen, the opening price of a past daily bar.
  • DHigh, the highest price of a past daily bar.
  • DLow, the lowest price of a past daily bar.
  • Close, the closing price of the current timeframe's bar.
  • Open, the opening price of a bar.
  • High, the highest price of a bar.
  • Low, the lowest price of a bar.
  • CustomClose, the user-selectable price source.