MyAlgoMate
// INDICATOR FORMULA

OBV formula: how to calculate On-Balance Volume (with Excel)

How On-Balance Volume is worked out — a running total that adds the volume on an up close and subtracts it on a down close. With a worked example, the Excel formula, a free Excel sheet and a box to calculate OBV from your own closes and volumes.

Last updated:

The OBV formula

OBV today = OBV yesterday + Volume,  if Close > previous Close
          = OBV yesterday − Volume,  if Close < previous Close
          = OBV yesterday,           if Close = previous Close

First candle: OBV = 0

Joe Granville introduced OBV in 1963. Only the direction of the close matters, not the size of the move, and the starting value of 0 is arbitrary.

How to calculate OBV step by step

  1. Start at 0 on the first candle. Day 1: OBV = 0.
  2. Compare each close with the previous one. Day 2 closed lower (987.95 vs 1,001.15), so its volume is subtracted: 0 − 2,36,500 = −2,36,500.
  3. Add the volume on an up close. Day 3 closed higher (1,009.15): −2,36,500 + 2,41,800 = 5,300.
  4. Repeat for every candle. By Day 60 the example's OBV is 5,36,900.

Worked example — and calculate OBV from your own prices

The table works through 60 daily candles of an imaginary stock, column by column — the same columns as the Excel sheet. To calculate OBV for your own stock, clear the box and paste your close and volume from Excel or your broker's download.

One row per candle, oldest first. Paste straight from Excel or your broker's download; a date or time column becomes the row label. Filled with our example prices.

Latest values

OBV: 5,36,900
OBV calculated from the example prices
DayCloseVolumeOBV
Day 11,001.152,33,6000
Day 2987.952,36,500−2,36,500
Day 31,009.152,41,8005,300
Day 41,012.601,00,0001,05,300
Day 5993.252,91,400−1,86,100
Day 61,008.601,76,400−9,700
Day 71,013.601,28,0001,18,300
Day 81,001.552,36,400−1,18,100
Day 91,031.552,21,9001,03,800
Day 101,040.052,12,4003,16,200
Day 111,033.151,71,7001,44,500
Day 121,064.803,12,9004,57,400
Day 131,083.551,63,0006,20,400
Day 141,067.952,03,0004,17,400
Day 151,063.502,40,1001,77,300
Day 161,030.202,70,500−93,200
Day 171,012.202,04,600−2,97,800
Day 18981.601,35,800−4,33,600
Day 19970.551,00,100−5,33,700
Day 20960.902,25,500−7,59,200
Day 21978.302,07,300−5,51,900
Day 22958.851,42,100−6,94,000
Day 23946.751,26,400−8,20,400
Day 24937.951,06,700−9,27,100
Day 25927.851,79,300−11,06,400
Day 26911.202,40,500−13,46,900
Day 27905.152,22,200−15,69,100
Day 28885.951,37,900−17,07,000
Day 29874.701,51,200−18,58,200
Day 30855.802,18,700−20,76,900
Day 31862.151,94,800−18,82,100
Day 32866.451,33,500−17,48,600
Day 33845.101,84,600−19,33,200
Day 34851.551,39,400−17,93,800
Day 35860.201,68,400−16,25,400
Day 36854.801,23,700−17,49,100
Day 37877.203,54,900−13,94,200
Day 38888.452,59,000−11,35,200
Day 39905.401,81,300−9,53,900
Day 40896.801,79,300−11,33,200
Day 41889.6093,200−12,26,400
Day 42895.301,54,100−10,72,300
Day 43919.003,03,800−7,68,500
Day 44918.351,76,000−9,44,500
Day 45906.252,57,500−12,02,000
Day 46932.102,18,000−9,84,000
Day 47944.352,34,400−7,49,600
Day 48948.701,34,900−6,14,700
Day 49966.352,43,100−3,71,600
Day 50955.601,04,900−4,76,500
Day 51969.101,82,100−2,94,400
Day 52984.353,17,10022,700
Day 53980.902,57,200−2,34,500
Day 54962.501,74,000−4,08,500
Day 55960.201,21,200−5,29,700
Day 56967.352,44,200−2,85,500
Day 57971.002,45,900−39,600
Day 58981.751,56,3001,16,700
Day 59994.852,24,8003,41,500
Day 601,012.351,95,4005,36,900
Everything is worked out in your browser. Nothing you paste is stored or sent.

The example prices are made up for this page — they are not real market data. OBV is a calculation from past prices, not a forecast, a signal or advice to buy or sell. MyAlgoMate provides trading technology, not investment advice.

How to calculate OBV in Excel

Put the headings in row 1 and the first candle in row 2, oldest at the top. Then type these formulas — each column uses the ones to its left:

  1. A

    Day

    A2 downwards: your dates, oldest at the top.

  2. B

    Close

    B2 downwards: the closing prices, oldest at the top.

  3. C

    Volume

    C2 downwards: the volumes, oldest at the top.

  4. D

    OBV

    D2 0 — this cell only (the starting value).

    D3 =IF(B3>B2,D2+C3,IF(B3<B2,D2-C3,D2)) — then copy it down to the last row.

Prefer not to type them? The free sheet has every formula filled in for the example prices — replace the prices with yours and extend the rows. It opens in Microsoft Excel (we checked every value against the table above), and you can import it into Google Sheets or LibreOffice.

Download the free OBV Excel sheet (.xlsx)

What OBV shows

OBV keeps a running count of volume on up closes minus volume on down closes. Its slope — rising, falling or flat — is what people look at, because the level depends on the starting date. It is a calculation from past prices and volumes, not a forecast or advice.

// FAQ

OBV calculation — questions, answered.

Start at 0. On every candle that closes higher than the previous one, add that candle's volume; when it closes lower, subtract the volume; when the close is unchanged, OBV stays the same.

Closes in column B and volumes in column C from row 2. Put 0 in D2, then in D3: =IF(B3>B2,D2+C3,IF(B3<B2,D2-C3,D2)) and copy it down.

Because OBV is a running total, its level depends entirely on where it started — a chart that starts years earlier shows a very different number. Only the changes in OBV can be compared, not the level itself. Volume data (spot vs futures, which exchange) also has to match.

No — only whether the close went up, down or stayed the same. A one-paisa rise adds the whole day's volume, exactly like a big rise.

Yes, the formula is the same on any timeframe; use each candle's volume. Some charts restart intraday OBV every day and some don't, which changes the level but not the candle-to-candle changes.

More indicator formulas, with Excel sheets

Turn your own rules into automated orders.

Already use OBV in your own rules? MyAlgoMate's algo trading software places the orders your rules call for at 150+ Indian brokers — and TradeBridge turns your own TradingView or Chartink alerts into live orders. You decide the rules; we provide the technology.

Share this page