Indicators/probuilder · probacktest · proorder · proscreener

OBV

OBV in ProBuilder returns On-Balance Volume, a cumulative total that adds volume on up bars and subtracts it on down bars. Syntax, formula and examples.

Syntax

probuilder
OBV(price)

Parameters

NameTypeDefaultDescription
priceprice sourcecloseThe series whose direction decides whether volume is added or subtracted. Almost always close, but any price array is accepted.

Formula

code
if price > price[1] then OBV = OBV[1] + volume
if price < price[1] then OBV = OBV[1] - volume
if price = price[1] then OBV = OBV[1]

The result is a cumulative sum, so it is unbounded and its absolute value depends on where the loaded history begins.

How it works

On-Balance Volume treats every bar's volume as either buying or selling depending on which way the reference price moved. An up bar adds its full volume to the total, a down bar subtracts it, an unchanged bar leaves the total alone. Over time the line accumulates the net direction of volume flow.

The idea is that volume tends to lead price. When the OBV line rises while price moves sideways, accumulation may be under way and a breakout upward becomes more plausible. When OBV falls while price holds or rises, distribution may be occurring behind the scenes. Confirmation, where OBV and price make new highs or lows together, supports trend continuation.

Because the line is cumulative, only its shape carries information. The number itself reflects nothing more than the sum of signed volume since the first loaded bar, so two charts of the same instrument with different history lengths show different OBV values with identical shapes.

Examples

Example 1, OBV momentum over 10 bars (Indicator)

probuilder
// Compare current OBV with the OBV computed on prices shifted 10 bars back
i1 = OBV(close)
i2 = OBV(close[10])
test = i1 - i2
RETURN test

Calculates OBV on the closing price and on the close shifted 10 bars back, then returns the difference. The spread indicates how much net signed volume has accumulated recently.

Example 2, Volume-confirmed trend entry (ProOrder)

probuilder
// Long only when both price and OBV are above their own averages
obvline = OBV(close)
obvavg = Average[20](obvline)
trend = Average[50](close)

IF NOT OnMarket AND close > trend AND obvline > obvavg THEN
  BUY 1 CONTRACT AT MARKET
ENDIF
IF LongOnMarket AND obvline < obvavg THEN
  SELL AT MARKET
ENDIF

Requires the OBV line to trade above its 20-bar average before a long entry, and exits when signed volume flow rolls back under that average.

Example 3, Rising OBV screener (ProScreener)

probuilder
// Instruments where signed volume has been building for 20 bars
obvline = OBV(close)
rising = obvline > obvline[20]
SCREENER[rising]((obvline - obvline[20]) AS "OBV change 20")

Lists instruments whose OBV is higher than 20 bars ago and sorts them by the size of the increase, a simple accumulation scan.

Interpretation

PatternReading
OBV rising with priceVolume confirms the uptrend.
OBV falling with priceVolume confirms the downtrend.
Price new high, OBV lower highBearish divergence, the advance lacks volume support.
Price new low, OBV higher lowBullish divergence, selling pressure is drying up.
OBV trending while price is flatPossible accumulation or distribution ahead of a break.

OBV gives no overbought or oversold levels. Analysis relies on trendlines, moving averages of the OBV line itself, and divergences against price.

Common errors and gotchas

  • Absolute values are arbitrary. The total starts accumulating at the first loaded bar, so the level depends on chart history and differs between platforms and history lengths. Never compare raw OBV values across instruments or code fixed thresholds against them.
  • Volume data required. On instruments without genuine exchange volume, such as many spot forex feeds, OBV is built from tick or estimated volume and may not mean what the textbook assumes.
  • All-or-nothing volume assignment. A bar closing up by one tick contributes exactly as much volume as a strong full-bodied bar. Indicators like PVT or AccumDistr weight volume by the size or location of the move instead.
  • Flat closes add nothing. When price equals the previous value the total is unchanged, so on low-priced or thinly traded instruments with frequent equal closes the line can understate activity.
  • Volume, the raw per-bar volume being accumulated.
  • PVT, similar running total weighted by percentage price change.
  • AccumDistr, accumulation and distribution line weighted by close location in the range.
  • ChaikinOsc, oscillator of the accumulation and distribution line.
  • MoneyFlow, bounded -1 to 1 buying and selling pressure gauge.
  • MoneyFlowIndex, volume-weighted RSI on a 0 to 100 scale.
  • ForceIndex, price change multiplied by volume for single-bar strength.
  • WilliamsAccumDistr, alternative accumulation and distribution formula.