# OBV Divergence

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

Detects regular and hidden divergences between price and On-Balance Volume at confirmed swing points, using 5-bar pivots on both sides and a 60-bar cap between compared swings. Divergence lines draw in the OBV pane and on the price chart, Bull and Bear labels mark the confirming swing, and drawn signals do not repaint once printed.

- Indicator in the LuxAlgo Library, by LuxAlgo, published May 17, 2026.
- Access: free.
- Concepts: [OBV Divergence](https://www.luxalgo.com/library/concept/obv-divergence/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=nph6se80xmmju1vnuirl71fw
- Page: https://www.luxalgo.com/library/indicator/obv-divergence/

**OBV Divergence** watches for the moments when price and cumulative volume stop telling the same story. It plots On-Balance Volume (the running total adding a bar's volume on up closes and subtracting it on down closes) and compares its swings against price swings at confirmed pivots, flagging every [OBV divergence](https://www.luxalgo.com/library/concept/obv-divergence/) with paired lines in the pane and on the price chart. A higher price high met by a lower OBV high shows an advance drawing thinner volume backing; a price low undercutting the prior one while OBV holds higher shows sellers losing force.

## How to Trade the OBV Divergence?

- **Bear label**: price higher high, OBV lower high: a warning over the advance, traded once price structure breaks rather than on the label alone.
- **Bull label**: price lower low, OBV higher low: the accumulation-flavored counterpart, same discipline.
- **Hidden divergences** (optional, dashed): price holding a higher low while OBV prints a fresh low, and the bearish inverse: continuation reads rather than reversals.
- **Audit both panes**: the paired lines show exactly which two swings produced each signal, a habit worth keeping across the [volume tools](https://www.luxalgo.com/library/family/volume-orderflow/).

All four divergence types carry dedicated alerts.

## OBV Divergence Settings

- **Left Bars** (default 5) and **Right Bars** (default 5): bars required on each side of a price swing; the right side sets the confirmation delay.
- **Max Bars Between Swings** (default 60): swings further apart are not treated as part of the same move and are never compared.
- **Detect Hidden Divergences** (default off): add the continuation variants, a comparison more familiar from oscillators than from OBV.
- Style inputs toggle the OBV-pane lines, the price-chart lines, and the signal labels, plus the bullish, bearish, and OBV line colors.

## Frequently Asked Questions

### How is this different from a plain OBV plot?

The [On-Balance Volume](https://www.luxalgo.com/library/indicator/on-balance-volume/) line only shows the running total; spotting disagreements is left to the eye. This build formalizes the comparison (confirmed pivots, a maximum gap, explicit regular and hidden definitions) so a divergence becomes a discrete, alertable event.

### Does it repaint?

Drawn signals do not. A swing needs 5 bars of right-hand confirmation before it exists, so divergences appear with that delay, the trade-off for comparisons that stay put once made.

### Why do some divergences fail?

Because a bar's entire volume is signed by its close direction, one huge print that closes marginally lower can bend the line and produce a disagreement with no economic meaning. Divergences can also repeat across several new extremes before price finally turns, hence the demand for confirmation.

## 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
- [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
- [Demand Index](https://www.luxalgo.com/library/indicator/demand-index/) (Volume & Order Flow): markdown at https://www.luxalgo.com/library/indicator/demand-index.md

---

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