OPEN-SOURCE SCRIPT
VWAP Deviation Oscillator [BackQuant]

VWAP Deviation Oscillator [BackQuant]
Introduction
The VWAP Deviation Oscillator turns VWAP context into a clean, tradeable oscillator that works across assets and sessions. It adapts to your workflow with four VWAP regimes plus two rolling modes, and three deviation metrics: Percent, Absolute, and Z-Score. Colored zones, optional standard deviation rails, and flexible plot styles make it fast to read for both trend following and mean reversion.
What it does
This tool measures how far price is from a chosen VWAP and expresses that gap as an oscillator. You can view the deviation as raw price units, percent, or standardized Z-Score. The plot can be a histogram or a line with optional fills and sigma bands, so you can quickly spot polarity shifts, overbought and oversold conditions, and strength of extension.
Why this works
VWAP is a high signal anchor used by institutions to gauge fair participation. Deviations around VWAP cluster in regimes: mild oscillations within a band, decisive pushes that signal imbalance, and standardized extremes that often precede either continuation or snapback. Expressing that distance as a single time series adds clarity: bias is the oscillator’s sign, risk context is its magnitude, and regime is the way it behaves around sigma lines.
How to use it
Key settings
VWAP computation
Deviation measurement
Volatility controls
Visualization
Reading the zones
The oscillator’s color and height map deviation to nine graded buckets on each side of zero, with deeper greens above and deeper reds below. In Percent and Absolute modes, those buckets are scaled by their mode-specific sigma. In Z-Score mode the bucket edges are fixed at 0.5, 1.0, 2.0, and 2.8.
Suggested workflows
Trend continuation checklist
Mean reversion checklist
Notes on the three modes
Percent is easy to reason about when you care about proportional stretch. It is well suited to intraday and multi-asset dashboards.
Absolute tracks cash distance from VWAP. This is useful when instruments have tight ticks and you plan risk in price units.
Z-Score standardizes the residual and is best for quant studies, cross-asset comparisons, and threshold research that must be scale invariant.
What the alerts can tell you
Troubleshooting and edge cases
Final thoughts
VWAP is the anchor. The deviation oscillator is the narrative. By separating bias, magnitude, and regime into a simple stream you can execute faster and review cleaner. Pick the VWAP mode that matches your horizon, choose the deviation lens that matches your risk framework, and let the color graded zones guide your decisions.
Introduction
The VWAP Deviation Oscillator turns VWAP context into a clean, tradeable oscillator that works across assets and sessions. It adapts to your workflow with four VWAP regimes plus two rolling modes, and three deviation metrics: Percent, Absolute, and Z-Score. Colored zones, optional standard deviation rails, and flexible plot styles make it fast to read for both trend following and mean reversion.
What it does
This tool measures how far price is from a chosen VWAP and expresses that gap as an oscillator. You can view the deviation as raw price units, percent, or standardized Z-Score. The plot can be a histogram or a line with optional fills and sigma bands, so you can quickly spot polarity shifts, overbought and oversold conditions, and strength of extension.
- VWAP modes track a session VWAP that resets (4H, Daily, Weekly) or a rolling VWAP that updates continuously over a fixed number of bars or days.
- Deviation modes let you choose the lens: Percent, Absolute, or Z-Score. Each highlights different aspects of stretch and mean pressure.
- Visual encoding uses a 10-zone color palette to grade the magnitude of deviation on both sides of zero.
- Volatility guards compute mode-specific sigma so thresholds are stable even when volatility compresses.
Why this works
VWAP is a high signal anchor used by institutions to gauge fair participation. Deviations around VWAP cluster in regimes: mild oscillations within a band, decisive pushes that signal imbalance, and standardized extremes that often precede either continuation or snapback. Expressing that distance as a single time series adds clarity: bias is the oscillator’s sign, risk context is its magnitude, and regime is the way it behaves around sigma lines.
How to use it
- Trend following
Favor the side of the zero line. Bullish when the oscillator is above zero and making higher swing highs. Bearish when below zero and making lower swing lows. Use +1 sigma and +2 sigma in your mode as strength tiers. Pullbacks that hold above zero in uptrends, or below zero in downtrends, are often continuation entries.
- Mean reversion
Fade stretched readings when structure supports it. Look for tests of +2 sigma to +3 sigma that fail to progress and roll back toward zero, or the mirror on the downside. Z-Score mode is best when you want standardized gates across assets. Percent mode is intuitive for intraday scalps where a given percent stretch tends to mean revert.
- Session playbook
Use Daily or Weekly VWAP for intraday or swing context. Rolling modes help when the asset lacks clean session boundaries or when you want a continuous anchor that adapts to liquidity shifts.
Key settings
VWAP computation
- VWAP Mode = 4 Hours, Daily, Weekly, Rolling (Bars), Rolling (Days). Session modes reset the VWAP when a new session begins. Rolling modes compute VWAP over a fixed trailing window.
- Rolling (Lookback: Bars) controls the trailing bar count when using Rolling (Bars).
- Rolling (Lookback: Days) converts days to bars at runtime and uses that trailing span.
- Use Close instead of HLC3 switches the price reference. HLC3 is smoother. Close makes the anchor track settlement more tightly.
Deviation measurement
- Deviation ModePercent: 100 * (Price / VWAP - 1). Good for uniform scaling across instruments.
Absolute: Price - VWAP. Good when price units themselves matter.
Z-Score: Standardizes the absolute residual by its own mean and standard deviation over Z/Std Window. Ideal for cross-asset comparability and regime studies.
- Z/Std Window sets the mean and standard deviation window for Z-Score mode.
Volatility controls
- Percent Mode Volatility Lookback estimates sigma for percent deviations.
- Absolute Mode Volatility Lookback estimates sigma for absolute deviations.
- Minimum Sigma Guard (pct pts) prevents the percent sigma from collapsing to near zero in extremely quiet markets.
Visualization
- Plot Type = Histogram or Line. Histogram emphasizes impulse and polarity changes. Line emphasizes trend waves and divergences.
- Positive Color / Negative Color define the palette for line mode. Histogram uses a 10-bucket gradient automatically.
- Show Standard Deviations plots symmetric rails at ±1, ±2, ±3 sigma in the current mode’s units.
- Fill Line Oscillator and Fill Opacity add a soft bias band around zero for line mode.
- Line Width affects both the oscillator and the sigma rails.
Reading the zones
The oscillator’s color and height map deviation to nine graded buckets on each side of zero, with deeper greens above and deeper reds below. In Percent and Absolute modes, those buckets are scaled by their mode-specific sigma. In Z-Score mode the bucket edges are fixed at 0.5, 1.0, 2.0, and 2.8.
- 0 to +1 sigma weak positive bias, usually rotational.
- +1 to +2 sigma constructive impulse. Pullbacks that hold above zero often continue.
- +2 to +3 sigma strong expansion. Watch for either trend continuation or exhaustion tells.
- Beyond +3 sigma statistical extreme. Requires structure to avoid fading too soon.
- Mirror logic applies on the negative side.
Suggested workflows
Trend continuation checklist
- Pick a session VWAP that matches your timeframe, for example Daily for intraday or Weekly for position trades.
- Wait for the oscillator to hold the correct side of zero and for a sequence of higher swing lows in the oscillator (uptrend) or lower swing highs (downtrend).
- Buy pullbacks that stabilize between zero and +1 sigma in an uptrend. Sell rallies that stabilize between zero and -1 sigma in a downtrend.
- Use the next sigma band or a prior price swing as your target reference.
Mean reversion checklist
- Switch to Z-Score mode for standardized thresholds.
- Identify tests of ±2 sigma to ±3 sigma that fail to extend while price meets support or resistance.
- Enter on a polarity change through the prior histogram bar or a small hook in line mode.
- Fade back to zero or to the opposite inner band, then reassess.
Notes on the three modes
Percent is easy to reason about when you care about proportional stretch. It is well suited to intraday and multi-asset dashboards.
Absolute tracks cash distance from VWAP. This is useful when instruments have tight ticks and you plan risk in price units.
Z-Score standardizes the residual and is best for quant studies, cross-asset comparisons, and threshold research that must be scale invariant.
What the alerts can tell you
- Polarity changes at zero can mark the start or end of a leg.
- Crosses of ±1 sigma identify overbought or oversold in the current mode’s units.
- Zone changes signal an upgrade or downgrade in deviation strength.
Troubleshooting and edge cases
- If your instrument has long flat periods, keep Minimum Sigma Guard above zero in Percent mode so the rails do not vanish.
- In Rolling modes, very short windows will respond quickly but can whip around. Session modes smooth this by resetting at well known boundaries.
- If Z-Score looks erratic, increase Z/Std Window to stabilize the estimate of mean and sigma for the residual.
Final thoughts
VWAP is the anchor. The deviation oscillator is the narrative. By separating bias, magnitude, and regime into a simple stream you can execute faster and review cleaner. Pick the VWAP mode that matches your horizon, choose the deviation lens that matches your risk framework, and let the color graded zones guide your decisions.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
Check out whop.com/signals-suite for Access to Invite Only Scripts!
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
Check out whop.com/signals-suite for Access to Invite Only Scripts!
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。