OBV is a running total that adds the bar's volume on an up close and subtracts it on a down close. The absolute level is meaningless - what matters is its trend relative to price.
Formula
if close[t] > close[t-1]: OBV[t] = OBV[t-1] + volume[t]
if close[t] < close[t-1]: OBV[t] = OBV[t-1] - volume[t]
otherwise: OBV[t] = OBV[t-1]Params
None.
Output
Single column named after your indicator (e.g. obv).
Usage
- Confirmation: rising price + rising OBV = trend is real. Rising price + flat or falling OBV = volume isn't supporting the move.
- Divergence: price makes a new high, OBV doesn't. Classic weakness signal.
- OBV smoothed with an EMA is a common simplification - slope of
EMA(obv, 20)as a trend filter.
Pitfalls
- OBV is path-dependent. The current value depends on every prior bar, so two markets with identical recent price action can have very different OBV levels.
- Tick-rule artifacts: when close is unchanged, volume is ignored entirely. Real participation gets lost.
- No volume data, no OBV. Spot markets w/o reported volume produce nonsense.
