obv

On-Balance Volume (Cumulative volume indicator)

obv(source)

A cumulative volume indicator that adds or subtracts volume based on price direction. OBV shows how volume flows in and out of a security to confirm price trends.

Parameters

  • source (source, optional): Data series to determine direction - price field (close, open, high, low) or indicator output
  • Default: close

Formula


If field > field[1]: OBV = OBV[1] + Volume
If field < field[1]: OBV = OBV[1] - Volume
If field = field[1]: OBV = OBV[1]

Where:
- OBV starts at 0 for the first period
- Volume is added on up days, subtracted on down days

Examples


obv();  # OBV based on close price (default)
obv(close);  # Explicit close-based OBV
x = obv(); x > x[50];  # OBV trending up (confirming uptrend)

Returns

Cumulative On-Balance Volume value (unbounded, can be positive or negative)

Notes

  • Rising OBV confirms uptrend (accumulation)
  • Falling OBV confirms downtrend (distribution)
  • Divergence between price and OBV signals potential reversal
  • Requires full price history for accurate cumulative calculation