On-Balance Volume Oscillator: Calculation, TradingView Setup, and Limits
On-Balance Volume (OBV) adds a bar's volume when its close rises and subtracts volume when its close falls. It summarizes signed volume; it does not measure net money entering a market, identify institutions, or establish that a breakout will succeed. An “OBV oscillator” may transform that cumulative series, so check the exact formula before interpreting its zero line.
Raw OBV and an OBV Oscillator Are Different
Standard OBV is cumulative and unbounded. Its baseline is arbitrary, so a raw value above zero is not inherently bullish and values are not directly comparable across instruments. TradingView's OBV documentation describes the calculation and traditional trend and divergence interpretations.
An oscillator built from OBV needs an additional definition. For example, a developer might subtract a moving average from OBV, or take the change in OBV over a fixed number of bars. These are different signals. Record the smoothing method, length, and any normalization; the name “OBV oscillator” does not specify them.
For a moving-average difference, zero means that cumulative OBV equals its chosen average. It does not mean equal buying and selling volume. Every executed trade has a buyer and a seller, and OBV assigns the entire bar's volume according to one close-to-close price comparison.
Calculate OBV With a Worked Example
For each completed bar:
- If its close is above the previous close, add its volume.
- If its close is below the previous close, subtract its volume.
- If the closes are equal, leave OBV unchanged.
The following prices and volumes are invented for arithmetic demonstration, not Tesla data or a historical result. Start OBV at zero on the first row.
| Bar | Close | Volume | Change to OBV | OBV |
|---|---|---|---|---|
| 1 | $200 | 2,000,000 | Baseline | 0 |
| 2 | $205 | 3,000,000 | +3,000,000 | 3,000,000 |
| 3 | $202 | 1,500,000 | −1,500,000 | 1,500,000 |
| 4 | $208 | 2,500,000 | +2,500,000 | 4,000,000 |
| 5 | $208 | 1,000,000 | 0 | 4,000,000 |
For an illustrative three-bar simple-average oscillator at bar 5, the mean of the last three OBV values is (1,500,000 + 4,000,000 + 4,000,000) ÷ 3 = 3,166,666.67. OBV minus that mean is approximately +833,333.33 volume units. The length of three is chosen only to make the example inspectable.
Changing the initial OBV baseline shifts the raw line by a constant. Subtracting a simple moving average removes that constant once the same window is available. Neither operation adds information about trader identity or future returns.
Add OBV in TradingView
Open the chart's indicator search and look for On Balance Volume. Add the built-in indicator and keep it in a separate pane so its volume units are not confused with price. Confirm the symbol, exchange, timeframe, and whether the data feed supplies volume.
For a custom oscillator, inspect its description or source to identify the transformation. If you use Pineify to prepare a custom indicator, compare its raw OBV values with the built-in series before adding smoothing or signals. A visual difference can come from data history, initialization, volume treatment, or formula differences; it is not evidence that one version is more predictive.
For Pine Script setup instructions, see our guide to running Pine Script in TradingView. An indicator plots information; automated backtesting additionally requires explicit order rules in a strategy.
Interpret Patterns as Hypotheses
| Observation | What it establishes | Hypothesis to investigate |
|---|---|---|
| Price and OBV rise | More signed volume has accumulated on up-close bars | Whether this accompanies continued price strength |
| Price makes a lower low while OBV makes a higher low | Price and cumulative signed-volume swings disagree | Whether a defined later reversal condition improves outcomes |
| Price breaks a level while OBV does not | The selected price and OBV comparisons differ | Whether an OBV filter changes breakout performance |
| One large jump in OBV | A high-volume bar was assigned a positive or negative sign | Whether an event or data issue explains it |
A divergence has no fixed expiration date or guaranteed reversal. Define which swings are compared and how a swing becomes confirmed. If a pivot requires later bars on its right, the pivot is only known after those bars arrive. A backtest that enters at the earlier pivot timestamp uses information that was unavailable then.
Agreement with RSI or another indicator is not an independent confirmation by default. Both may reuse the same price information. Test the combined rule against the simpler rule rather than assuming extra conditions improve accuracy.
Choose Settings From the Question
Raw OBV has no conventional lookback length: it accumulates from its starting point. A smoothing overlay, oscillator, or swing detector introduces parameters that need separate explanations.
Choose a chart interval that matches the decision frequency and data quality. If a daily signal is used for intraday entries, state whether it uses the last completed daily bar or the still-forming one. Report that timing in both the chart and backtest.
Compare a small, predeclared set of smoothing lengths on development data. Check how much signals change with nearby values and whether the delay introduced by smoothing fits the intended trade. There is no universal best 10-, 21-, or 50-period setting.
Volume Is Specific to the Feed
The input called volume can represent different things. Spot forex is decentralized, and some feeds provide tick volume or no volume rather than centralized traded quantity. A crypto symbol's volume generally reflects its venue or data aggregation, not automatically the entire market. Futures rolls and equity corporate actions can also create discontinuities worth inspecting.
Identify the field's meaning for the selected symbol. Compare like-for-like feeds and units. Do not interpret a rising series as “whale accumulation” or “institutional buying” without separate evidence about who traded.
Build a Reproducible OBV Backtest
The following is a candidate rule specification for research, not an assertion that the rule has an edge:
- Evaluate after each bar closes using completed bars only.
- Define a price breakout as the close exceeding the highest high of the previous 20 completed bars, excluding the current bar.
- Define an OBV filter as current OBV exceeding its highest value over those same previous 20 bars.
- Compare the price-only version with a version requiring both conditions.
- Enter at the next bar's modeled execution price. Permit one position and exit after ten completed holding bars; define counting and final-bar treatment consistently.
- Use the same fixed exposure, dates, and costs for both versions, then repeat the unchanged comparison on later data.
The 20- and ten-bar choices are arbitrary demonstration inputs. They are not preferred settings. A fixed holding period makes the first comparison easier to audit; adding stops or targets requires more assumptions about within-bar price order.
For divergence research, first document the pivot confirmation delay and exact price trigger. Use the time the divergence becomes knowable as the earliest decision point. Avoid drawing an attractive historical divergence and treating its leftmost point as an entry.
Report What the Test Actually Shows
Report trade count, exposure, net returns after costs, drawdown, and average win and loss for both versions. If the filter reduces trade count, ask whether its apparent improvement comes from a few retained trades. Evaluate different periods using the same rules; do not set an expected bull-market or bear-market win rate in advance and present it as observed fact.
No target win rate, profit factor, or series of consecutive wins justifies increasing position size by itself. A sizing decision requires the full loss distribution, correlated exposure, and limits on possible capital loss. A historical stop or maximum drawdown does not cap a future loss.
TradingView's strategy documentation explains its broker emulator. Review those execution assumptions before interpreting a strategy report as evidence for an OBV rule. Keep the signal calculation separate from the assumptions about fills and costs.
Is OBV the same as an OBV oscillator?
Raw OBV is a cumulative signed-volume series. An oscillator may subtract an average or measure a change over a window. Check the formula because different transformations have different zero-line meanings.
Does rising OBV prove institutions are buying?
No. It means volume added on up-close bars exceeds volume subtracted on down-close bars over the interval. OBV does not identify participants or measure net cash flow.
Does a bullish OBV divergence predict a reversal?
It describes disagreement between selected price and OBV swings. A reversal is a hypothesis. Define swing confirmation, entry timing, exits, and costs before testing it.
What is the best timeframe or win rate for OBV?
There is no universal value. The appropriate interval depends on the trading question and volume data. Measure outcomes from a documented test rather than assuming a target win rate.
