Skip to content

Technical indicators

On Balance Volume (OBV)

A running total of volume, added on up closes and taken away on down closes.

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.

Traders watch for OBV to break out before the price does, and for it to disagree with the price’s direction.

OBV = OBV(previous bar) + volume if close > previous close
OBV = OBV(previous bar) − volume if close < previous close
OBV = OBV(previous bar) otherwise

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.

On Balance Volume (OBV) drawn by its own code on example prices

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.

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;
}