Constants/probuilder · probacktest · proorder · proscreener

WeightedClose

WeightedClose returns a close-weighted bar price in ProBuilder, (2*Close + High + Low) / 4. Use WeightedClose, or WeightedClose[N] N bars ago, as a price source.

Syntax

probuilder
WeightedClose

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

How it works

WeightedClose blends the bar's close, high, and low, giving the close double weight: (2 * Close + High + Low) / 4. The result sits between the typical price and the close itself, leaning toward the settlement price while still accounting for the bar's range.

The bracket offset addresses earlier bars, so WeightedClose[1] is the previous bar's weighted close. The index must stay within the loaded history.

Because the close carries more influence than in TypicalPrice, this constant tracks end-of-period movement more closely while still smoothing out some intrabar noise. It is used wherever a close-leaning but range-aware price input is wanted. On the live bar it can move as the high, low, or close updates.

Examples

Example 1, Weighted close against its average (Indicator)

probuilder
// Moving average of the weighted close
ma = Average[20](WeightedClose)
RETURN WeightedClose AS "Weighted close", ma AS "MA 20"

The indicator plots the weighted close alongside a moving average built from the same series.

Example 2, Screening on weighted-close strength (ProScreener)

probuilder
// Weighted close above its 50-bar average
above = WeightedClose > Average[50](WeightedClose)

SCREENER[above] (WeightedClose AS "Weighted close")

The screener returns instruments whose weighted close sits above its longer average.

Example 3, Weighted-close crossover entry (ProOrder)

probuilder
DEFPARAM CumulateOrders = false

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

IF fast CROSSES OVER slow THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

IF fast CROSSES UNDER slow THEN
  SELL AT MARKET
ENDIF

Both averages read WeightedClose, weighting the close while still reflecting each bar's range.

Common errors and gotchas

  • Close is double weighted. The formula counts the close twice, so WeightedClose is not the same as TypicalPrice, which weights high, low, and close equally.
  • Live bar moves. On the current bar the high, low, or close can change, shifting WeightedClose until the bar completes.
  • Offset out of range. WeightedClose[N] fails when N points before the first loaded bar. Guard long lookbacks or load more history.
  • TypicalPrice, the average of high, low, and close.
  • MedianPrice, the average of high and low.
  • TotalPrice, the average of open, high, low, and close.
  • CustomClose, the user-selectable price source.
  • Close, the closing price of a bar.
  • High, the highest price of a bar.
  • Low, the lowest price of a bar.
  • Open, the opening price of a bar.