On Balance Volume: What OBV Does With a Tied Close
On balance volume is a running total. Sign each bar's volume by whether the close rose or fell against the previous close, add it to what came before, and the accumulated figure is the whole indicator. Vike computes it as batch_obv, and unlike most of the indicator family it lives in the engine's base module rather than its volume module.
Every explanation covers the two obvious arms. Almost none cover the third, which is what happens when a close matches the one before it exactly — and on a 24/7 venue that is not a hypothetical. This page walks the source, measures that arm on 356,886 real daily bars, then scores the classic divergence trade against the base rate it has to beat.
What on balance volume actually adds up
Volume by itself has no direction. A hundred million dollars changed hands; the tape does not say whether buyers or sellers were the impatient side, because every trade has one of each.
So the indicator borrows a direction from price. Closed higher than yesterday? Count the whole bar as buying. Closed lower? Count it as selling. Then keep a running sum, which is why the line drifts a long way from zero and why its absolute level means nothing at all — only its shape carries information.
That crude attribution is the entire mechanism, and it deserves to be stated plainly rather than dressed up. A bar that opened weak, sold off hard for twenty hours and then rallied one tick into the close is counted as pure accumulation. The rule cannot see any of that. It sees two closes.
The exact OBV formula our engine runs
batch_obv evaluates per bar. The middle one is the arm most write-ups omit — the volume is not halved or carried with a sign, it is dropped.Three branches, evaluated per bar, and the third is where implementations quietly disagree.
How Vike computes it.batch_obvseedsout[0] = 0.0, then for every later bar addsvolume[i]whenclose[i] > close[i-1], subtractsvolume[i]whenclose[i] < close[i-1], and otherwise adds nothing. Both comparisons are strict. The streaming form holds aprev_close: Option<f64>and an accumulator, and it emits the same zero on its first bar rather than a partial value, so a live chart and a backfilled one agree bar for bar.
I ported that rule from the crate source and then checked it against the Python original the crate itself was ported from, across 292 symbols and 356,886 daily bars. Maximum absolute difference: zero, with no position where one series was defined and the other was not. That agreement is the only reason the measurements below are worth your attention.
Note what the arithmetic never touches. Nothing here reads the open, the high or the low. A bar can travel fifteen percent intraday and close unchanged, and OBV records it as identical to a bar that never moved.
The third arm: a close that did not move
Here is the branch textbooks skip, and skipping it costs real information.
When close[i] equals close[i-1] exactly, the bar's volume is not halved, not split between the sides, not carried forward with a sign. It is discarded whole. A billion dollars of turnover on a bar that finished where it started leaves the line perfectly flat.
How often does that fire? On daily candles across the tape, 2,805 bars out of 356,886 — roughly one bar in 127, and the median symbol surrenders 0.335% of its lifetime volume to them. Small. Now shorten the bars. Four-hour candles tie on 2.151% of bars, and hourly candles on 4.188%, where the typical symbol loses 1.632% of its volume to the zero arm. Scalpers are running an indicator that ignores one bar in twenty-four.
Gold-backed and low-volatility tokens sit worst: PAXG ties on 3.2% of its daily bars, more than four times the tape-wide rate, because a token pinned to a slow-moving metal simply closes at the same price often.
How to trade OBV divergence
Divergence is the trade OBV is famous for, so I stated it tightly enough to be proven wrong and then ran it.
Bearish: price closes at a fresh twenty-bar high while the line does not reach its own twenty-bar high. Bullish: the mirror, price at a twenty-bar low with the line holding above its own. Each signal resolves first-touch over the following ten bars inside a symmetric eight percent bracket, so break-even sits at exactly 50% before fees, and a bar tagging both levels counts as a loss. Then the identical bracket runs on every bar in the same sample, because a hit rate quoted without its base rate is not evidence of anything.
The rule fired 26,852 times. Bullish divergence resolved 47.6% winners; an arbitrary long entry on the same bars managed 49.4%. Bearish divergence resolved 44.1%, where a random short reached 48.9%.
Both numbers sit below the base rate. Not below by a rounding error either — the bearish side gives up 4.8 percentage points, on 7,806 signals, which is far too many for chance to explain comfortably. The classic reading of this indicator is worse than no reading.
Where on balance volume fails
I have watched people treat that bearish result as merely disappointing, which undersells what it is saying and is worth sitting with for a moment.
A signal landing 4.8 points under the base rate is not neutral information badly used. Price at a twenty-bar high with the volume line lagging is, on this sample, a mildly bullish configuration — the continuation happens more often than the reversal the textbook promises. My own mistake for years was reading the lag as exhaustion, when the simpler explanation fits better: strong trends make new highs on thinning participation all the time, and thinning participation is what a breakout into empty air looks like.
Failure number two is mechanical. Because attribution comes from the close alone, a single tick decides how a bar's entire volume is signed. Two bars with identical ranges and identical turnover land on opposite sides of the ledger over a difference of one cent, and the accumulated line carries that coin flip forever.
OBV next to the rest of the volume family
batch_obv seeds at zero; batch_ad seeds at the first bar’s own contribution. Neither level means anything on its own, which is why both are read as slopes.Three volume indicators, three different ways of splitting the same column, and comparing them is more instructive than any of them alone.
The accumulation distribution line weights each bar by where the close landed inside its own range rather than against the previous close, so it can call a bar half-accumulation. Run both across the tape and they point opposite ways on 18.1% of bars — nearly one bar in five where two respectable volume indicators disagree about who was buying.
A third route belongs to the money flow index, which weights by typical price and bounds the result between zero and a hundred. It ties less often than OBV does, because an average of three prices matches its predecessor far less readily than a single close does.
Pick one and know why. Stacking all three gives you one opinion with three coats of paint, and the RSI page makes the same argument about momentum.
Frequently asked questions
What does a rising OBV line mean? More volume has printed on up-closes than down-closes since whatever bar your chart happens to start on. It is a summary of the past, and the level is arbitrary — only the slope and the shape can be read.
Does OBV predict breakouts? Not on this evidence. Both divergence directions underperformed a random entry over 26,852 signals, and the bearish version underperformed badly.
What is the best OBV setting? There is no setting. The detector takes no parameters at all, which makes it one of the very few indicators nobody can overfit by tuning — you can only overfit the rule you wrap around it.
Why does my OBV value differ between platforms? Three reasons, in order of size: where your history starts, whether your feed reports the same volume, and how the platform handles a tied close. Some implementations carry the previous value, some add zero, and those are the same thing — but a few add the volume to the up-side anyway, which is not.
Should I use OBV with candlestick patterns? That pairing is more defensible than stacking volume indicators. A hammer reads one bar's shape and OBV reads accumulated participation, so when they agree you have two independent claims rather than one claim twice.
This is educational material, not financial advice. Every figure here is measured on bars that have already closed, past behavior generalizes poorly, and trading carries real risk of loss — size any position so that being wrong stays affordable.