# OBV Divergence

A Volume & Order Flow concept (Cumulative flow lines) in the LuxAlgo Library, with 1 indicator implementation.

## What is OBV Divergence?

OBV divergence is a disagreement between price and [On-Balance Volume](https://www.luxalgo.com/library/concept/obv/), the running total that adds a bar's entire volume when it closes above the prior close and subtracts it when it closes below. Because the line compounds direction and participation into one series, a fresh price extreme is ordinarily expected to come with a fresh OBV extreme. When price makes a higher high while OBV makes a lower high, the advance attracted less cumulative volume support: bearish divergence. A lower price low against a higher OBV low is the bullish mirror, read as selling pressure failing to expand.

The idea traces to Joseph Granville, who popularized OBV in 1963 and argued that changes in volume tend to precede changes in price. Divergence is that thesis in visual form: distribution showing up beneath a rising tape, accumulation beneath a falling one. Two honest caveats apply. OBV's all-or-nothing signing means a huge-volume bar that closes marginally lower counts as fully negative, so one outsized bar can distort the line. And divergences can persist through several further price extremes before mattering, so standard practice is to treat them as a warning that is only traded once price structure confirms.

Grading separates the tradeable divergences from the wallpaper. Swing selection comes first: comparisons drawn on confirmed pivots mean something, while disagreements involving a still-forming high evaporate retroactively. Magnitude and repetition rank next, a deep OBV shortfall across three successive price extremes outranking a shallow miss across two. And composition auditing guards against the construction's known distortion: when a divergence traces to one outsized bar, a news print or index rebalance booked entirely one way by the close-to-close rule, checking that bar's actual composition, with [delta](https://www.luxalgo.com/library/concept/volume-delta/) where available, decides whether the line is testifying or malfunctioning.

The workflow around the signal is settled convention: divergence warns, structure confirms, entries follow the confirmation. Detector tools automate the pivot-matched comparisons and alerting; ribbon builds run OBV beside its intrabar-weighted cousins so single-line distortions stand out; and the [breakout](https://www.luxalgo.com/library/concept/volume-at-breakout/)-vetting application inverts the read, an advance into new highs on diverging OBV being the classic candidate false move. Across all of it the feed caveat stands: divergences computed on tick-count volume proxies inherit the proxy's looseness, and deserve proportionate skepticism.

## How to identify OBV Divergence

OBV divergence is a swing-to-swing comparison, identified the same way as oscillator divergence.

1. Plot OBV beneath price; its absolute value is meaningless, so only the line's swings and slope matter.
2. Mark two successive swing highs on price in an advance, or two successive swing lows in a decline.
3. Compare OBV at those same swing points: a price higher high with an OBV lower high is bearish divergence, and a price lower low with an OBV higher low is bullish.
4. Require price confirmation, such as a reversal bar or a break of a swing point, before trading it, and apply extra caution when the feed reports tick volume rather than actual traded volume.
5. Prefer multi-point divergences on confirmed pivots: a shortfall repeated across three extremes is evidence, while a single-swing disagreement on an unconfirmed high is usually noise.

## How it's calculated

Compares the direction of price swings with the direction of On Balance Volume swings to flag moves that volume does not confirm.

```
OBV_t = OBV_(t-1) + V_t when C_t > C_(t-1)
OBV_t = OBV_(t-1) - V_t when C_t < C_(t-1)
OBV_t = OBV_(t-1) when C_t = C_(t-1)
Pivots: a swing high is a bar whose H_t is the highest within k bars on either side; a swing low is a bar whose L_t is the lowest within k bars on either side
Let h1, h2 be the bars of the last two confirmed swing highs and l1, l2 those of the last two swing lows (h2 and l2 the newer)
Regular bearish divergence: H_h2 > H_h1 and OBV_h2 < OBV_h1
Regular bullish divergence: L_l2 < L_l1 and OBV_l2 > OBV_l1

  C_t: close of bar t
  V_t: traded volume of bar t
  t: bar index (t-1 is the prior bar)
  OBV_t: On Balance Volume, a running total seeded arbitrarily (commonly 0)
  H_t: high of bar t
  L_t: low of bar t
  k: pivot width, bars required on each side for confirmation (commonly 5)
  h1: bar index of the older confirmed swing high
  h2: bar index of the newer confirmed swing high
  l1: bar index of the older confirmed swing low
  l2: bar index of the newer confirmed swing low
```

OBV's absolute level depends on the seed and history length, so only its swings are compared, never its level.

Hidden divergences flip the price leg: a higher low in price with a lower low in OBV is hidden bullish, a lower high in price with a higher high in OBV is hidden bearish.

Pivot detection confirms k bars after the swing, so signals appear with delay and flagged divergences vary with the pivot settings.

## How traders use it

- As a reversal warning at swing extremes: bearish OBV divergence into resistance, or bullish divergence into support, flags a move to distrust, with entries taken on price confirmation rather than on the divergence itself.
- As a trend-confirmation filter: while OBV keeps printing new extremes alongside price, the trend is treated as supported and continuation setups get the benefit of the doubt.
- To vet breakouts: OBV pushing to new highs ahead of or alongside a price breakout suggests accumulation behind the move, while a breakout on diverging OBV is a candidate [false breakout](https://www.luxalgo.com/library/concept/false-breakout/).
- Cross-checked against other volume-based measures such as the [Accumulation/Distribution Line](https://www.luxalgo.com/library/concept/accumulation-distribution-line/) or [Money Flow Index](https://www.luxalgo.com/library/concept/money-flow-index/), since each treats volume differently and agreement across them is the stronger read.
- Automated: pivot-matched detector scripts flag qualifying divergences and fire alerts, moving the labor from staring at panes to auditing the flagged candidates for swing quality and bar composition.

## OBV Divergence vs related concepts

- **OBV** (https://www.luxalgo.com/library/concept/obv/): OBV is the indicator, a cumulative volume line. OBV divergence is one specific pattern read on it against price swings; the line has other uses, such as trend confirmation and breakout vetting, beyond divergence.
- **Volume Divergence** (https://www.luxalgo.com/library/concept/volume-divergence/): Raw volume divergence compares price with unsigned volume magnitudes. OBV divergence compares price with a line that already encodes close direction, so it blends the two and can fire when raw volume looks unremarkable.
- **Regular Bullish/bearish Divergence** (https://www.luxalgo.com/library/concept/regular-bullish-bearish-divergence/): The swing logic is identical to oscillator divergence, but OBV is unbounded and cumulative, with no overbought or oversold zone, so divergence is essentially the only swing signal the line produces.

## FAQ

### How reliable is OBV divergence?

There is no fixed reliability figure, and divergences can persist while the trend extends. Data sensitivity matters too: OBV built on tick counts, common in forex and some crypto feeds, behaves differently from OBV on reported share or contract volume. Most traders require price confirmation before treating a divergence as actionable.

### What is the difference between OBV divergence and A/D line divergence?

OBV signs a bar's full volume by close-to-close direction, while the Accumulation/Distribution Line weights volume by where the close sits within the bar's range. A bar that closes down but near its high counts fully negative for OBV yet nearly positive for the A/D line, so the two lines can diverge from price at different times.

### Does hidden divergence work with OBV?

Yes, the same swing comparisons apply. [Hidden divergence](https://www.luxalgo.com/library/concept/hidden-divergence/), where price holds a higher low while OBV makes a lower low, or the bearish mirror, is read as trend continuation rather than reversal. It is screened for less often on OBV than on oscillators, but the construction is identical.

### How many swing points should a divergence span?

Two is the definition's minimum, three or more is the trader's preference. A shortfall repeated across successive extremes shows participation failing persistently rather than once, and each additional confirming swing point raises the read's weight while the trend it questions ages further. The tension is real: multi-point divergences are more trustworthy and later, which is one more reason the framework hands final authority to price confirmation.

### Can a single bar create a false divergence?

Easily, and it is the construction's known artifact: OBV books a bar's entire volume by its close-to-close sign, so one enormous print, an index rebalance, a news candle closing marginally the wrong way, can bend the line into a divergence no genuine flow produced. The audit is composition: inspect the outlier bar, check its intrabar delta where data allows, and discount divergences that vanish when one bar is mentally removed.

### What timeframes suit OBV divergence?

Swing scales wear it best: daily and multi-hour charts, where cumulative participation across weeks has room to disagree with price meaningfully. Intraday divergences print constantly and mean proportionally less, since a few session bars of volume rarely represent campaign behavior. The general rule of divergence work applies, higher-timeframe disagreements outrank lower ones, and OBV's cumulative construction amplifies that hierarchy.

## Implementations in the Library

- OBV Divergence (LuxAlgo): https://www.luxalgo.com/library/indicator/obv-divergence/

## Related concepts

- Money Flow Index: https://www.luxalgo.com/library/concept/money-flow-index/
- Weis Wave Volume: https://www.luxalgo.com/library/concept/weis-wave-volume/
- OBV: https://www.luxalgo.com/library/concept/obv/
- Accumulation/Distribution Line: https://www.luxalgo.com/library/concept/accumulation-distribution-line/
- Chaikin Oscillator: https://www.luxalgo.com/library/concept/chaikin-oscillator/
- Chaikin Money Flow: https://www.luxalgo.com/library/concept/chaikin-money-flow/
- Twiggs Money Flow: https://www.luxalgo.com/library/concept/twiggs-money-flow/
- Williams A/D: https://www.luxalgo.com/library/concept/williams-a-d/
- Price Volume Trend: https://www.luxalgo.com/library/concept/price-volume-trend/
- Negative Volume Index: https://www.luxalgo.com/library/concept/negative-volume-index/

---

Source: https://www.luxalgo.com/library/concept/obv-divergence/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/