OPEN-SOURCE SCRIPT
Zaktualizowano VWAP Deviation Divergence Oscillator

VWAP Deviation Divergence Oscillator
## Overview
The VWAP Deviation Divergence Oscillator turns the **deviation of price from its session-anchored Volume-Weighted Average Price (VWAP)** into a standardized, bounded oscillator, and then looks for **divergence between price and that deviation**. The idea it tests: when price makes a new extreme but sits less far from VWAP than before, the volume-weighted average is no longer confirming the move.
It is a single-pane oscillator. It requires real traded volume (use a futures contract; cash indices report none, in which case the dashboard shows "no volume"). Every data input is user-configurable, so it runs on any symbol that reports volume, in any market and on any timeframe. Defaults target NSE NIFTY index futures on intraday charts.
## What it plots
- A z-scored **VWAP deviation oscillator** (stretched above VWAP = up, stretched below = down), with a glow line and sigma-based overbought/oversold levels.
- **Extreme-zone bands** (default +/-3 sigma) with a gradient fill that deepens toward the edge.
- **Divergence lines and labels** on the oscillator - regular (reversal) and hidden (continuation), in two colors.
- **In-band reversal dots** where the oscillator turns inside an extreme zone.
- Optional **price-pane marks** at the confirmation bar (all generated by this one indicator).
- A **background-adaptive status dashboard** (oscillator value in sigma, zone, last divergence, last reversal, live distance to VWAP).
## Why these components are combined (mashup rationale)
This script combines a **derived measure**, a **normalization stage**, a **divergence engine** and a **reversal read**, because each answers a question the others cannot and none is useful here alone:
1. **VWAP deviation (price + volume).** VWAP is the volume-weighted "fair value" the session has actually transacted at - it blends price and traded volume, which a price-only oscillator does not. How far price sits from VWAP, in standardized terms, is a mean-reversion read: the deviation = price - session VWAP.
2. **Standardization (rolling z-score).** VWAP deviation differs in scale across instruments. The z-score expresses it in standard-deviation units, so "overbought/oversold" and the extreme bands mean the same thing on NIFTY, on a commodity future, or on a crypto instrument. Without this step the divergence thresholds would not transfer between symbols.
3. **Divergence engine.** The original payload is reading **price-versus-VWAP deviation disagreement at confirmed pivots**. The engine pairs each new price pivot with the oscillator value, then requires: a genuine new price extreme; the measure failing to confirm it; a minimum oscillator gap scaled to the oscillator own stdev; the two pivots within a maximum bar distance; and optionally an overbought/oversold reading at the pivot. These gates make the combination produce signal rather than noise.
4. **Reversal read.** Independently, the engine flags oscillator turns that occur inside the extreme bands - a complementary exhaustion cue.
Together the components form one pipeline: **build the signal -> make it comparable (z-score) -> surface where price and that signal disagree (divergence) and where it exhausts (reversal).** Each is incomplete alone.
## How it works (method)
deviation = price - session-anchored VWAP (which resets each session and requires real volume); this is standardized with a rolling z-score to the oscillator.
Regular and hidden divergence are detected from confirmed pivothigh/pivotlow pivots and filtered by the gates above; reversals are oscillator pivots that print inside the extreme bands. Pivots confirm a few bars after they occur, so a printed signal does not repaint. The confirmation lag equals the pivot length.
## How to use it
1. Add the indicator on a volume-bearing instrument (a futures contract); on a cash index it will read "no volume".
2. Read divergence as **context, not a trigger**: a bearish divergence (price higher high, deviation lower high) says price is less extended above VWAP than at the prior high; a bullish divergence says the opposite at lows. Confirm with your own structure, levels and risk process.
3. Tune the **pivot length**, **max gap** and **min oscillator gap** to your timeframe; raise them for fewer, cleaner signals.
## Originality
This is an original implementation - not a VWAP deviation line and not a generic divergence script, but the specific combination of VWAP deviation, sigma-standardization that makes the read portable across markets, a multi-gate divergence engine (magnitude + distance + extreme-zone), hidden-divergence and in-band reversal detection, and a background-adaptive dashboard. The code is written from scratch; helper functions use only their arguments and built-ins.
## Credits
The **Volume-Weighted Average Price (VWAP)** and **price/oscillator divergence** are standard, publicly documented techniques. This script is not affiliated with, nor endorsed by, any third party.
## Notes / limitations
- VWAP deviation needs real volume and is session-relative; it resets each session and is undefined without a volume feed.
- Divergence is descriptive context, never a guarantee of reversal.
- Confirmation lags each pivot by the pivot length.
## Disclaimer
Research and educational tool only. NOT financial advice and no guarantee of profitability or accuracy. Indicators describe past behaviour; they do not predict the future. Trading carries risk of loss. Test out-of-sample and make your own decisions. The author accepts no liability for any use of this script.
## Overview
The VWAP Deviation Divergence Oscillator turns the **deviation of price from its session-anchored Volume-Weighted Average Price (VWAP)** into a standardized, bounded oscillator, and then looks for **divergence between price and that deviation**. The idea it tests: when price makes a new extreme but sits less far from VWAP than before, the volume-weighted average is no longer confirming the move.
It is a single-pane oscillator. It requires real traded volume (use a futures contract; cash indices report none, in which case the dashboard shows "no volume"). Every data input is user-configurable, so it runs on any symbol that reports volume, in any market and on any timeframe. Defaults target NSE NIFTY index futures on intraday charts.
## What it plots
- A z-scored **VWAP deviation oscillator** (stretched above VWAP = up, stretched below = down), with a glow line and sigma-based overbought/oversold levels.
- **Extreme-zone bands** (default +/-3 sigma) with a gradient fill that deepens toward the edge.
- **Divergence lines and labels** on the oscillator - regular (reversal) and hidden (continuation), in two colors.
- **In-band reversal dots** where the oscillator turns inside an extreme zone.
- Optional **price-pane marks** at the confirmation bar (all generated by this one indicator).
- A **background-adaptive status dashboard** (oscillator value in sigma, zone, last divergence, last reversal, live distance to VWAP).
## Why these components are combined (mashup rationale)
This script combines a **derived measure**, a **normalization stage**, a **divergence engine** and a **reversal read**, because each answers a question the others cannot and none is useful here alone:
1. **VWAP deviation (price + volume).** VWAP is the volume-weighted "fair value" the session has actually transacted at - it blends price and traded volume, which a price-only oscillator does not. How far price sits from VWAP, in standardized terms, is a mean-reversion read: the deviation = price - session VWAP.
2. **Standardization (rolling z-score).** VWAP deviation differs in scale across instruments. The z-score expresses it in standard-deviation units, so "overbought/oversold" and the extreme bands mean the same thing on NIFTY, on a commodity future, or on a crypto instrument. Without this step the divergence thresholds would not transfer between symbols.
3. **Divergence engine.** The original payload is reading **price-versus-VWAP deviation disagreement at confirmed pivots**. The engine pairs each new price pivot with the oscillator value, then requires: a genuine new price extreme; the measure failing to confirm it; a minimum oscillator gap scaled to the oscillator own stdev; the two pivots within a maximum bar distance; and optionally an overbought/oversold reading at the pivot. These gates make the combination produce signal rather than noise.
4. **Reversal read.** Independently, the engine flags oscillator turns that occur inside the extreme bands - a complementary exhaustion cue.
Together the components form one pipeline: **build the signal -> make it comparable (z-score) -> surface where price and that signal disagree (divergence) and where it exhausts (reversal).** Each is incomplete alone.
## How it works (method)
deviation = price - session-anchored VWAP (which resets each session and requires real volume); this is standardized with a rolling z-score to the oscillator.
Regular and hidden divergence are detected from confirmed pivothigh/pivotlow pivots and filtered by the gates above; reversals are oscillator pivots that print inside the extreme bands. Pivots confirm a few bars after they occur, so a printed signal does not repaint. The confirmation lag equals the pivot length.
## How to use it
1. Add the indicator on a volume-bearing instrument (a futures contract); on a cash index it will read "no volume".
2. Read divergence as **context, not a trigger**: a bearish divergence (price higher high, deviation lower high) says price is less extended above VWAP than at the prior high; a bullish divergence says the opposite at lows. Confirm with your own structure, levels and risk process.
3. Tune the **pivot length**, **max gap** and **min oscillator gap** to your timeframe; raise them for fewer, cleaner signals.
## Originality
This is an original implementation - not a VWAP deviation line and not a generic divergence script, but the specific combination of VWAP deviation, sigma-standardization that makes the read portable across markets, a multi-gate divergence engine (magnitude + distance + extreme-zone), hidden-divergence and in-band reversal detection, and a background-adaptive dashboard. The code is written from scratch; helper functions use only their arguments and built-ins.
## Credits
The **Volume-Weighted Average Price (VWAP)** and **price/oscillator divergence** are standard, publicly documented techniques. This script is not affiliated with, nor endorsed by, any third party.
## Notes / limitations
- VWAP deviation needs real volume and is session-relative; it resets each session and is undefined without a volume feed.
- Divergence is descriptive context, never a guarantee of reversal.
- Confirmation lags each pivot by the pivot length.
## Disclaimer
Research and educational tool only. NOT financial advice and no guarantee of profitability or accuracy. Indicators describe past behaviour; they do not predict the future. Trading carries risk of loss. Test out-of-sample and make your own decisions. The author accepts no liability for any use of this script.
Informacje o Wersji
VWAP Deviation Divergence Oscillator — update notesForward calibration added. Each divergence and reversal class (Reg Bull/Bear, Hidden Bull/Bear, Rev +/−) is resolved by a triple-barrier outcome, uniqueness-weighted and recency-decayed, reported as an edge over a zone-matched base rate with a Wilson interval and a multiple-testing-corrected significance star — so you can see which VWAP-deviation divergences actually pay.
Configurable volume (any market). A volume-source input plus a borrow symbol and a manual session VWAP that honours them let the oscillator run on instruments that report no native volume.
Identity strip showing name · symbol · timeframe on the chart (theme-adaptive).
Exports bus: EXP_Osc, EXP_OscZ, EXP_Zone, EXP_Bias, EXP_RegDiv, EXP_HidDiv, EXP_Reversal, EXP_BullEdge, EXP_BearEdge, plus EXP_VWAPDist and EXP_DataLive.
Pro dashboard adds the per-class calibration table; settings reorganized into 7 groups; all toggles default-on; NIFTY/intraday defaults retained; VWAP credit kept in the header, out of the UI.
Educational only — not financial advice. VWAP deviation needs real volume and is session-relative; calibration is in-sample, forward-measured. Validate out-of-sample.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.