CustomClose
CustomClose returns the user-selectable price source in ProBuilder, close by default. Use CustomClose or CustomClose[N] so indicators follow the chosen price.
Syntax
CustomCloseCustomClose[N] returns the selected price N bars back, where N is 0 for the current bar, 1 for the previous bar, and so on. CustomClose and CustomClose[0] are equivalent.
How it works
CustomClose is a stand-in for the price source chosen in the settings window. By default it resolves to the closing price, but a user can switch it to another price type such as MedianPrice, TypicalPrice, TotalPrice, or WeightedClose. The indicator code stays the same while the underlying input changes.
The bracket offset addresses earlier bars relative to the one being processed, so CustomClose[1] is the selected price on the previous bar. The index must remain within the loaded history.
Using CustomClose as the input to a calculation lets one indicator serve several price definitions without editing the code. This matches how many built-in indicators expose a price-source dropdown. When exact behavior must not depend on user settings, reference Close directly instead.
Examples
Example 1, Average built on the selected price (Indicator)
// Moving average that follows whichever price source the user picks
ma = Average[20](CustomClose)
RETURN CustomClose AS "Price", ma AS "MA 20"Switching the price source in the settings changes both the plotted price and the average without any code change.
Example 2, Screening on the chosen price (ProScreener)
// Selected price above its own 50-bar average
above = CustomClose > Average[50](CustomClose)
SCREENER[above] (CustomClose AS "Price")The screener evaluates each instrument using the configured price source rather than a hard-coded close.
Example 3, Entry driven by the selected price (ProOrder)
DEFPARAM CumulateOrders = false
fast = Average[10](CustomClose)
slow = Average[30](CustomClose)
IF fast CROSSES OVER slow THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF fast CROSSES UNDER slow THEN
SELL AT MARKET
ENDIFBoth averages read CustomClose, so the strategy adapts if the price source is reconfigured.
Common errors and gotchas
- Depends on settings.
CustomClosemay not equalCloseif the user changed the price source. When a fixed input is required, useCloseexplicitly. - Offset out of range.
CustomClose[N]fails when N points before the first loaded bar. Guard long lookbacks or load more history. - Reproducibility across charts. Sharing an indicator that relies on
CustomClosemeans results can vary between users depending on their chosen price source.
Related instructions
Close, the closing price, the default source for CustomClose.MedianPrice, the average of high and low.TypicalPrice, the average of high, low, and close.TotalPrice, the average of open, high, low, and close.WeightedClose, a close-weighted average of high, low, and close.Open, the opening price of a bar.High, the highest price of a bar.Low, the lowest price of a bar.
