OBV — On-Balance Volume
OBV (On-Balance Volume) is a running total of volume, added or subtracted based on whether each bar closed up or down. It tracks whether volume is flowing into or out of an instrument over time. The standalone number doesn't matter — the slope and divergence vs. price do. Developed by Joseph Granville in 1963.
How OBV is calculated
Start at 0. For each new bar:
- If close > prior close → add this bar's volume
- If close < prior close → subtract this bar's volume
- If close == prior close → no change
That's it. The running total becomes the OBV line.
The indicator's specific value is meaningless (it depends on how far back you started). What matters is:
- Slope. OBV rising = money flowing in. Falling = money flowing out.
- Divergence vs. price. Price new highs but OBV not confirming = warning signal.
The key OBV signals
Confirmation. Price makes a new high and OBV makes a new high = volume supports the breakout. Healthy.
Divergence. Price makes a new high, OBV makes a lower high = volume is not supporting the move. Often precedes reversal.
Inverse for bearish confirmation and bullish divergence.
Trend break. OBV breaking below a prior trendline can precede a price breakdown by several bars. Same for breakouts. Some traders use OBV trendlines as early-warning signals.
Why OBV still matters
Modern traders have tick-level volume data, volume profile, and order flow tools that OBV predates by 50+ years. So why use a crude running total?
- It's universally available. Every charting platform has OBV.
- Higher-timeframe signals are cleaner. On daily and weekly charts, OBV divergence is still a reliable indicator of institutional accumulation/distribution.
- Simplicity. One line, one decision: is it confirming price or not.
For intraday scalping, OBV is largely obsolete — volume profile and order flow give you more. For swing trading and trend confirmation on higher timeframes, OBV is still useful.
OBV in Pine Script (v6)
//@version=6
indicator("OBV + Divergence Signal", overlay=false)
obvValue = ta.obv
plot(obvValue, color=color.blue, linewidth=2, title="OBV")
plot(ta.sma(obvValue, 20), color=color.orange, title="OBV 20-SMA")
// Simple divergence: price higher high but OBV lower high over last N bars
lookback = input.int(20, "Divergence lookback")
priceHH = high == ta.highest(high, lookback)
obvLH = obvValue < ta.highest(obvValue, lookback)[1] // OBV not at its recent high
bearDiv = priceHH and obvLH
priceLL = low == ta.lowest(low, lookback)
obvHL = obvValue > ta.lowest(obvValue, lookback)[1]
bullDiv = priceLL and obvHL
plotshape(bearDiv, style=shape.triangledown, location=location.abovebar, color=color.red, title="Bearish OBV divergence")
plotshape(bullDiv, style=shape.triangleup, location=location.belowbar, color=color.green, title="Bullish OBV divergence")
if bearDiv
alert("Bearish OBV divergence on " + syminfo.ticker, alert.freq_once_per_bar_close)
if bullDiv
alert("Bullish OBV divergence on " + syminfo.ticker, alert.freq_once_per_bar_close)
Settings
OBV has no period parameter — it's a cumulative measure. Divergence detection requires a lookback window (20 bars is typical). Some traders smooth OBV with a 20-period SMA to filter noise.
Common mistakes
- Obsessing over OBV's absolute value. It's meaningless. Only slope and divergence matter.
- Using OBV on short timeframes. It's too crude for minute charts. Daily and weekly is where OBV earns its keep.
- Using OBV instead of looking at the tape. On intraday futures, volume profile and order flow give higher-resolution info than OBV. Use the better tool if you have it.
Frequently Asked Questions
Is OBV a leading or lagging indicator?
OBV is technically coincident — it updates every bar alongside price. Its value as a 'leading' signal comes from divergences: when OBV stops confirming price, it often signals exhaustion before price itself turns. So: coincident in construction, slightly leading in practice.
What's the best timeframe for OBV?
Daily and weekly charts. OBV's signal-to-noise ratio improves on longer timeframes. On 1-minute or 5-minute charts, OBV is too crude — use volume profile or order flow instead for intraday.
Does OBV work on futures?
Yes. OBV uses volume, which all liquid futures contracts report. On index futures (ES, NQ) daily charts, OBV divergences are meaningful signals — often preceding corrections by several sessions.