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:
Needs: close and volume
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 = 0Joe 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
- Start at 0 on the first candle. Day 1: OBV = 0.
- 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.
- Add the volume on an up close. Day 3 closed higher (1,009.15): −2,36,500 + 2,41,800 = 5,300.
- 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.
Latest values
| Day | Close | Volume | OBV |
|---|---|---|---|
| Day 1 | 1,001.15 | 2,33,600 | 0 |
| Day 2 | 987.95 | 2,36,500 | −2,36,500 |
| Day 3 | 1,009.15 | 2,41,800 | 5,300 |
| Day 4 | 1,012.60 | 1,00,000 | 1,05,300 |
| Day 5 | 993.25 | 2,91,400 | −1,86,100 |
| Day 6 | 1,008.60 | 1,76,400 | −9,700 |
| Day 7 | 1,013.60 | 1,28,000 | 1,18,300 |
| Day 8 | 1,001.55 | 2,36,400 | −1,18,100 |
| Day 9 | 1,031.55 | 2,21,900 | 1,03,800 |
| Day 10 | 1,040.05 | 2,12,400 | 3,16,200 |
| Day 11 | 1,033.15 | 1,71,700 | 1,44,500 |
| Day 12 | 1,064.80 | 3,12,900 | 4,57,400 |
| Day 13 | 1,083.55 | 1,63,000 | 6,20,400 |
| Day 14 | 1,067.95 | 2,03,000 | 4,17,400 |
| Day 15 | 1,063.50 | 2,40,100 | 1,77,300 |
| Day 16 | 1,030.20 | 2,70,500 | −93,200 |
| Day 17 | 1,012.20 | 2,04,600 | −2,97,800 |
| Day 18 | 981.60 | 1,35,800 | −4,33,600 |
| Day 19 | 970.55 | 1,00,100 | −5,33,700 |
| Day 20 | 960.90 | 2,25,500 | −7,59,200 |
| Day 21 | 978.30 | 2,07,300 | −5,51,900 |
| Day 22 | 958.85 | 1,42,100 | −6,94,000 |
| Day 23 | 946.75 | 1,26,400 | −8,20,400 |
| Day 24 | 937.95 | 1,06,700 | −9,27,100 |
| Day 25 | 927.85 | 1,79,300 | −11,06,400 |
| Day 26 | 911.20 | 2,40,500 | −13,46,900 |
| Day 27 | 905.15 | 2,22,200 | −15,69,100 |
| Day 28 | 885.95 | 1,37,900 | −17,07,000 |
| Day 29 | 874.70 | 1,51,200 | −18,58,200 |
| Day 30 | 855.80 | 2,18,700 | −20,76,900 |
| Day 31 | 862.15 | 1,94,800 | −18,82,100 |
| Day 32 | 866.45 | 1,33,500 | −17,48,600 |
| Day 33 | 845.10 | 1,84,600 | −19,33,200 |
| Day 34 | 851.55 | 1,39,400 | −17,93,800 |
| Day 35 | 860.20 | 1,68,400 | −16,25,400 |
| Day 36 | 854.80 | 1,23,700 | −17,49,100 |
| Day 37 | 877.20 | 3,54,900 | −13,94,200 |
| Day 38 | 888.45 | 2,59,000 | −11,35,200 |
| Day 39 | 905.40 | 1,81,300 | −9,53,900 |
| Day 40 | 896.80 | 1,79,300 | −11,33,200 |
| Day 41 | 889.60 | 93,200 | −12,26,400 |
| Day 42 | 895.30 | 1,54,100 | −10,72,300 |
| Day 43 | 919.00 | 3,03,800 | −7,68,500 |
| Day 44 | 918.35 | 1,76,000 | −9,44,500 |
| Day 45 | 906.25 | 2,57,500 | −12,02,000 |
| Day 46 | 932.10 | 2,18,000 | −9,84,000 |
| Day 47 | 944.35 | 2,34,400 | −7,49,600 |
| Day 48 | 948.70 | 1,34,900 | −6,14,700 |
| Day 49 | 966.35 | 2,43,100 | −3,71,600 |
| Day 50 | 955.60 | 1,04,900 | −4,76,500 |
| Day 51 | 969.10 | 1,82,100 | −2,94,400 |
| Day 52 | 984.35 | 3,17,100 | 22,700 |
| Day 53 | 980.90 | 2,57,200 | −2,34,500 |
| Day 54 | 962.50 | 1,74,000 | −4,08,500 |
| Day 55 | 960.20 | 1,21,200 | −5,29,700 |
| Day 56 | 967.35 | 2,44,200 | −2,85,500 |
| Day 57 | 971.00 | 2,45,900 | −39,600 |
| Day 58 | 981.75 | 1,56,300 | 1,16,700 |
| Day 59 | 994.85 | 2,24,800 | 3,41,500 |
| Day 60 | 1,012.35 | 1,95,400 | 5,36,900 |
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:
- A
Day
A2 downwards: your dates, oldest at the top.
- B
Close
B2 downwards: the closing prices, oldest at the top.
- C
Volume
C2 downwards: the volumes, oldest at the top.
- 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.
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.