On Balance Volume (OBV)
A running total of volume, added on up closes and taken away on down closes.
What it measures
Section titled “What it measures”Joe Granville’s OBV adds the bar’s whole volume when it closes above the previous close and subtracts it when it closes below. Like ADL, its level depends on where the run began. Volume here is the volume the price feed reports for each bar. For forex, brokers usually report the number of price updates in the bar, not an amount traded, so read it as activity rather than money.
How traders read it
Section titled “How traders read it”Traders watch for OBV to break out before the price does, and for it to disagree with the price’s direction.
Formula
Section titled “Formula”OBV = OBV(previous bar) + volume if close > previous closeOBV = OBV(previous bar) − volume if close < previous closeOBV = OBV(previous bar) otherwiseSettings and output
Section titled “Settings and output”Call: obv()
No settings.
What you get: a number.
Warm-up: with no settings, it asks for 2 bars of history and a run-up of 1, and its first value came on bar 3 of the example data.
The prices are made up, hourly, and the same on every page, so the chart shows how the indicator behaves, not how a market behaved.
In an algorithm
Section titled “In an algorithm”let previous;
function onIntervalClose() { const value = obv(); if (OPEN_POSITIONS_COUNT === 0 && previous !== undefined && value > previous && CLOSE > sma(20)) { openPosition("BUY", { quantity: 10000, stopLossPips: 25, takeProfitPips: 50 }); } previous = value;}