On Balance Volume (OBV): Complete Guide for Algorithmic Trading

On Balance Volume (OBV) is a volume indicator that keeps a running total of trading volume: it adds a period’s volume when price closes higher than the previous close and subtracts it when price closes lower. In trading, OBV answers one question: is volume flowing into an asset (accumulation) or out of it (distribution)? A rising OBV line means more volume is trading on up closes than on down closes; a falling line means the opposite.
Developed by Joe Granville in the 1960s, OBV is based on the premise that volume precedes price. When OBV and price move together, the trend is backed by volume. When they disagree, the move may be running out of fuel. This makes OBV a valuable tool for traders who want to confirm trends or anticipate reversals.
OBV is particularly useful for algorithmic traders because it provides a quantitative measure of buying and selling pressure. By incorporating volume data, OBV offers insights that price-based indicators alone cannot provide, which makes it an excellent complement to other technical analysis tools in automated trading systems. Its ability to detect divergences between price and volume makes it especially valuable for building robust, multi-factor decision-making models.
How OBV Is Calculated
OBV Formula
OBV is a running total of volume:
- If the closing price > previous closing price: OBV = Previous OBV + Current Volume
- If the closing price < previous closing price: OBV = Previous OBV - Current Volume
- If the closing price = previous closing price: OBV = Previous OBV (no change)
Calculation Process
- Choose a starting point (usually the beginning of the available data).
- Set the initial OBV value (often zero).
- For each subsequent period, compare the current closing price to the previous closing price.
- Add the full volume if price increased, subtract it if price decreased, or leave OBV unchanged if price was flat.
- The result is a running cumulative total.
Worked Example
| Day | Close | Volume | OBV |
|---|---|---|---|
| 1 | $50 | 100 | 0 (starting value) |
| 2 | $55 | 150 | 150 (0 + 150, price rose) |
| 3 | $52 | 120 | 30 (150 - 120, price fell) |
| 4 | $58 | 200 | 230 (30 + 200, price rose) |
Notice that the size of the price move does not matter: a 1% rise and a 10% rise both add the full volume. Because the starting point is arbitrary, the absolute OBV number is meaningless. What matters is the direction and slope of the line, and how it compares with price.
Visual Representation
On a chart, OBV appears as a single line plotted below the price chart. The line trends upwards when volume on up periods outpaces volume on down periods, and trends downwards in the opposite scenario.
Key Parameters
- Timeframe: The candle interval OBV is calculated on (e.g., daily, hourly).
- Smoothing: Some traders apply a moving average to the OBV line to reduce noise.
Interpretation & Signals
Reading the Indicator
- A rising OBV line generally indicates that volume is flowing into the asset (accumulation).
- A falling OBV line suggests volume is flowing out of the asset (distribution).
- The slope and direction of the OBV line are more important than its absolute value.
Common Trading Signals
- Trend Confirmation: If OBV is moving in the same direction as the price, it confirms the trend.
- Potential Reversal: If OBV moves contrary to the price trend, it may signal a potential reversal. For example, if price keeps rising while OBV flattens or declines, buying interest is weakening.
- Breakouts: A significant OBV move can precede a price breakout.
Divergences
- Bullish Divergence: Price makes a lower low, but OBV makes a higher low.
- Bearish Divergence: Price makes a higher high, but OBV makes a lower high.
For a full rules-based build of this signal, see our OBV divergence strategy.
Signal Strength
The strength of an OBV signal can be gauged by: - The duration of the trend in the OBV line - The angle or slope of the OBV line - The magnitude of divergence between OBV and price
Trading Strategies
1. OBV Trend Following Strategy
This strategy aims to capture strong trends by aligning with both price and volume momentum. Entry Rules: - Price is above a 50-period moving average - OBV line is trending upwards (for long positions) - OBV makes a new 20-period high Exit Rules: - Price closes below the 50-period moving average - OBV line starts trending downwards - OBV makes a new 20-period low
2. OBV Divergence Strategy
This strategy seeks to identify potential reversals by spotting divergences between price and OBV. Entry Rules for Long Position: - Price makes a lower low - OBV makes a higher low (bullish divergence) - Wait for price to close above the previous swing high for confirmation Exit Rules: - Price reaches a predetermined profit target - OBV starts trending downwards - A bearish divergence forms
The OBV divergence strategy guide walks through building this setup step by step in Arrow Algo.
3. OBV Breakout Confirmation Strategy
This strategy uses OBV to confirm price breakouts, potentially reducing false signals. Entry Rules: - Price breaks above a key resistance level - OBV is trending upwards and also breaks above its recent high - Enter long when both price and OBV confirm the breakout Exit Rules: - Price falls back below the breakout level - OBV turns downwards - Trailing stop based on ATR (Average True Range)
4. Using OBV as a Trend Filter
OBV is also useful as a filter that keeps a strategy out of the market when volume isn’t supporting the move. Two simple ways to check that volume is confirming a rising market:
Method 1: OBV is above its own longer-term average. In the example below, the 8-hour OBV value is higher than its 14-period Simple Moving Average.

Method 2: A short-term average of OBV is above a longer-term average of OBV. In the example below, the 15-minute OBV 10-period Simple Moving Average is above the 15-minute OBV 30-period Simple Moving Average.

Both methods confirm that volume is backing rising conditions. Adding either one as a condition to a long-only (spot) strategy filters out entries that would otherwise trigger while volume is flowing out of the market.
Combining with Other Indicators
OBV works well when combined with: - Moving Averages: For trend identification - RSI (Relative Strength Index): For overbought/oversold conditions - MACD (Moving Average Convergence Divergence): For momentum confirmation - Bollinger Bands: For volatility context
For a broader look at pairing volume, trend, momentum and volatility indicators, see The Best Indicator to Use in Trading.
Best Timeframes
OBV is versatile and can be applied to various timeframes: - Daily charts: For swing trading and longer-term trend analysis - 4-hour and 1-hour charts: For short-term trading and intraday analysis - 15-minute charts: For day trading, especially around key market events
Strengths and Limitations of OBV
Strengths:
- Simple to understand: the calculation is a running total, so traders of any experience level can follow it.
- Adds volume information: most indicators use price alone; OBV shows whether volume supports the move.
- Can lead price: divergences between OBV and price often appear before a trend turns.
Limitations:
- False signals in thin or choppy markets: in very low volume conditions, small trades can skew the indicator, and in sideways ranges OBV tends to whipsaw.
- All-or-nothing volume: the full period’s volume is added or subtracted regardless of how far price moved, so one abnormal volume spike (e.g., a news event) can shift the line for a long time.
- Depends on volume quality: in markets where volume data is unreliable, incomplete or manipulated, OBV inherits those problems.
- Not a timing tool on its own: OBV shows pressure, not precise entry and exit points. Combine it with price action.
Implementation in Algo Trading
Integration into Algorithmic Strategies
You can build a strategy that incorporates OBV by: 1. Calculating the OBV values for each period 2. Comparing current OBV to historical values or a smoothed OBV line 3. Generating signals based on OBV trends, divergences, or breakouts 4. Combining OBV signals with price action rules and other indicators
Automated Decision-Making
You can create decision rules such as: - Enter long when OBV crosses above its 20-period moving average - Exit when OBV drops below a certain threshold - Adjust position sizing based on the strength of the OBV trend
Backtesting Considerations
When backtesting OBV strategies, pay attention to: - The impact of different timeframes on performance - How OBV performs in various market conditions (trending vs. ranging) - The effect of applying smoothing techniques to the OBV line
Common Pitfalls
- Over-reliance on OBV without considering price action
- Ignoring the broader market context
- Failing to account for abnormal volume spikes (e.g., due to news events)
Optimization Tips
- Experiment with different OBV smoothing periods
- Test various lookback periods for identifying highs and lows
- Combine OBV with volatility filters to avoid false signals in choppy markets
Building with Arrow Algo’s Block Builder
Arrow Algo’s NO-CODE block builder makes it easy to implement OBV-based strategies without writing a single line of code. Here’s how you can use the platform to create your OBV strategy:
- Add the OBV Indicator: Drag and drop the OBV indicator block from the indicator library into your strategy workspace.
- Configure Parameters: Use the visual interface to set OBV parameters such as the calculation period and any smoothing options.
- Create Trading Logic: Drag logic blocks to define your entry and exit conditions.
- For example: IF OBV is greater than OBV[1] (previous period’s OBV)
- AND Price is above 50-period moving average
- THEN trigger a long entry
- Set Position Sizing: Use position sizing blocks to determine how much to trade based on your account size and risk tolerance.
- Add Risk Management: Incorporate stop-loss and take-profit blocks to manage risk and lock in gains.
- Backtest and Optimize: Use Arrow Algo’s built-in backtesting tools to evaluate your strategy’s performance across different market conditions and timeframes.
- Refine Your Strategy: Easily adjust your strategy by dragging blocks, changing parameters, or adding new conditions without any coding required.
Conclusion
On Balance Volume (OBV) is a simple running total of volume that tells you whether buying or selling pressure is behind a price move. Its ability to confirm trends, flag potential reversals through divergence, and filter out low-conviction entries makes it a valuable addition to any trading system. Key takeaways: - OBV means cumulative volume flow: rising OBV is accumulation, falling OBV is distribution - Use OBV to confirm price trends and spot potential reversals - Look for divergences between OBV and price for early warning signals - Use OBV as a filter so strategies only trade when volume supports the move - Be aware of OBV’s limitations, especially in low-volume or manipulated markets Best practices include backtesting thoroughly, optimizing parameters for your specific trading instruments and timeframes, and always considering OBV in conjunction with price action and overall market conditions. Ready to build your own strategies using On Balance Volume (OBV)? Visit https://www.arrowalgo.com to start creating custom indicator-based strategies with Arrow Algo’s NO-CODE block builder platform.
Disclaimer: Algorithmic trading involves substantial risk. Past performance is not indicative of future results. This content is for educational purposes only and should not be considered financial advice. Always do your own research and consider consulting with a financial advisor before making trading decisions.
Educational disclaimer: This content is for educational purposes only and does not constitute financial advice. Trading involves significant risk and you should only trade with capital you can afford to lose. Past performance is not indicative of future results.