On-Balance Volume

Introduction

On-Balance Volume (OBV) is a momentum indicator that uses volume flow to predict changes in stock price. Developed by Joseph Granville in the 1960s, OBV assigns a cumulative total of volume that reflects the buying and selling pressure of a security, helping traders to confirm price trends or anticipate price reversals.

Calculation of OBV

The calculation of OBV is straightforward and based on the daily closing price movement:

  • If the current closing price is higher than the previous closing price:
mathematical expression or equation
  • If the current closing price is lower than the previous closing price:
mathematical expression or equation
  • If the closing price is unchanged:
mathematical expression or equation

Example Calculation

Assume we have the following closing prices and volumes for the last five days:

DayClosing PriceVolume
1$201000
2$221500
3$211200
4$232000
5$241700

On Day 1, since this is the first day, we will start with an OBV of 0:

mathematical expression or equation

On Day 2:

mathematical expression or equation

On Day 3:

mathematical expression or equation

On Day 4:

mathematical expression or equation

On Day 5:

mathematical expression or equation

After 5 days, the OBV is 4000.

Python Code

import pandas as pd

df = pd.read_csv([YOUR_DATASET])

df['OBV'] = 0

for i in range(len(df)):
    if df['Close'].iloc[i] > df['Close'].iloc[i - 1]:  # Price increased
        df.at[df.index[i], 'OBV'] = df.at[df.index[i - 1], 'OBV'] + df['Volume'].iloc[i]

    elif df['Close'].iloc[i] < df['Close'].iloc[i - 1]:  # Price decreased
        df.at[df.index[i], 'OBV'] = df.at[df.index[i - 1], 'OBV'] - df['Volume'].iloc[i]

    else:  # Price remained the same
        df.at[df.index[i], 'OBV'] = df.at[df.index[i - 1], 'OBV']

Interpretation of OBV

Trend Confirmation

  • Rising OBV: Indicates that volume is increasing on up days, suggesting strong buying pressure and potentially bullish price movement.
  • Falling OBV: Indicates that volume is increasing on down days, suggesting selling pressure and potentially bearish price movement.

Divergence

  • Bullish Divergence: Occurs when the price is making new lows but OBV is making higher lows, indicating that accumulated volume is not supporting the price decrease.
  • Bearish Divergence: Occurs when the price is making new highs but OBV is making lower highs, indicating that lack of volume may lead to price weakness.

Analogy

Think of OBV like a flowing river. If the river (OBV) is flowing consistently and rising, it indicates a strong current of water (buying interest) pushing forward. Conversely, if the river starts to dry up or flow backward, it suggests reduced momentum (selling interest) against the direction of the current. Just as the strength of a river can affect the landscape over time, OBV helps predict how price trends may develop based on volume flows.

Conclusion

On-Balance Volume is a valuable tool for traders looking to analyze volume trends relative to price movements. By understanding the cumulative nature of OBV, traders can better assess market sentiment, confirm trends, and identify potential reversals.


References