# On Balance Volume

On Balance Volume is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

On Balance Volume keeps a cumulative running total of volume, adding each bar's volume when the close is higher than the prior close and subtracting it when the close is lower, plotted as a single line used to compare volume flow with price movement. The build is cumulative from the first available bar and includes an optional smoothing moving average overlay. It is Joe Granville's indicator in its standard unmodified form.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Apr 13, 2020.
- Access: free.
- Concepts: [OBV](https://www.luxalgo.com/library/concept/obv/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=eqivp3n7bo3vtu9yqfgvsytf
- Page: https://www.luxalgo.com/library/indicator/on-balance-volume/

The **On Balance Volume** indicator keeps a cumulative running total of volume: each bar's volume is added when the close is higher than the prior close, subtracted when it is lower, and skipped when unchanged. The result is a single line traders read against price to judge whether volume is flowing with advances or with declines: Joe Granville's indicator in its standard unmodified form, cumulative from the first available bar, with an optional smoothing moving average overlay. Since the running total depends on where the loaded history starts, the printed level carries no meaning: direction, swing structure, and agreement with price do all the work.

## How to Trade the On Balance Volume?

- **OBV rising with price**: the advance is carrying participation: volume flow confirms the move.
- **OBV refusing to confirm a price extreme**: the classic divergence read; a new price high without a new OBV high suggests the push ran on thinner volume.
- **OBV breaking its own prior swing while price still ranges**: volume flow resolving ahead of price, worth watching for the move it may precede.
- **OBV crossing its Smoothing MA** (when enabled): an objective trigger for the line's own trend turning, useful precisely because raw OBV has no fixed scale.

## On Balance Volume Settings

- **Smoothing MA** (default disabled): displays a moving average of OBV to act as a smoothing/signal line.
- **MA Type** (default SMA): moving average type used for the smoothing line; options are SMA, EMA, WMA, and RMA (SMMA).
- **MA Length** (default 20): bars in the smoothing MA. Longer confines crosses to sustained flow shifts.

## Frequently Asked Questions

### How does OBV differ from the Money Flow Index?

OBV is cumulative and unbounded: it compounds signed volume indefinitely and is read through slope, swings, and divergence. MFI is a bounded 0-100 oscillator that weights flow by typical price and volume over a fixed window, offering overbought and oversold zones OBV cannot provide.

### Why does my OBV value differ between charts?

Because the total accumulates from the first available bar, the printed value depends on how much history the chart has loaded: different starting point, different number. Nothing is wrong: the level was never the signal, and slope, swings, and divergences are unaffected by where the count begins.

### What alerts does this build include?

The script declares Bullish MA Cross and Bearish MA Cross conditions, firing when OBV crosses above or below its smoothing moving average. They evaluate against the configured MA Type and MA Length even if the Smoothing MA display toggle is off, so the crosses can drive alerts without cluttering the pane.

## Related indicators

- [Oscillator Matrix](https://www.luxalgo.com/library/indicator/luxalgo-oscillator-matrix/) (Money Flow Index): markdown at https://www.luxalgo.com/library/indicator/luxalgo-oscillator-matrix.md
- [LuxAlgo - Screener (OSC)](https://www.luxalgo.com/library/indicator/luxalgo-screener-osc/) (Money Flow Index): markdown at https://www.luxalgo.com/library/indicator/luxalgo-screener-osc.md
- [Delta ZigZag](https://www.luxalgo.com/library/indicator/delta-zigzag/) (Weis Wave Volume): markdown at https://www.luxalgo.com/library/indicator/delta-zigzag.md
- [Price Zone Oscillator](https://www.luxalgo.com/library/indicator/price-zone-oscillator/) (Volume & Order Flow): markdown at https://www.luxalgo.com/library/indicator/price-zone-oscillator.md
- [OBV Divergence](https://www.luxalgo.com/library/indicator/obv-divergence/) (Volume & Order Flow): markdown at https://www.luxalgo.com/library/indicator/obv-divergence.md
- [Smart Money Index](https://www.luxalgo.com/library/indicator/smart-money-index/) (Volume & Order Flow): markdown at https://www.luxalgo.com/library/indicator/smart-money-index.md
- [Trade Volume Index](https://www.luxalgo.com/library/indicator/trade-volume-index/) (Volume & Order Flow): markdown at https://www.luxalgo.com/library/indicator/trade-volume-index.md
- [Volume Flow Indicator](https://www.luxalgo.com/library/indicator/volume-flow-indicator/) (Volume & Order Flow): markdown at https://www.luxalgo.com/library/indicator/volume-flow-indicator.md

---

Source: https://www.luxalgo.com/library/indicator/on-balance-volume/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
