OPEN-SOURCE SCRIPT
Rolling VWAP with StdDev Bands

Rolling VWAP with StdDev Bands (RVWAP+SD)
This indicator calculates a Rolling Volume-Weighted Average Price (RVWAP) over a configurable rolling time window (default: 10 hours), with volume-weighted standard deviation bands overlaid above and below. Unlike session-anchored VWAP, this indicator never resets at session boundaries, making it equally effective on crypto, forex, and equity markets at any timeframe.
What it does
How to use
Inputs
Important notes
This indicator uses lookahead=barmerge.lookahead_off on all request.security() calls. The last bar may update as real-time volume changes — this is normal VWAP behaviour and not a repainting issue.
The SWMA + RMA smoothing introduces some lag and is not intended for tick-level scalping.
Works on all markets and timeframes. On very thin/illiquid instruments, VWAP reliability depends on volume data quality.
Credits
Rolling time-window aggregation uses the PineCoders/ConditionalAverages/2 library (PineCoders, public domain per TV House Rules). All other code — volume-weighted standard deviation, timeframe synchronisation, trend state logic, and smoothing pipeline — is original.
This indicator calculates a Rolling Volume-Weighted Average Price (RVWAP) over a configurable rolling time window (default: 10 hours), with volume-weighted standard deviation bands overlaid above and below. Unlike session-anchored VWAP, this indicator never resets at session boundaries, making it equally effective on crypto, forex, and equity markets at any timeframe.
What it does
- RVWAP: Volume-weighted average price computed over the last N hours of bars using the PineCoders ConditionalAverages library for time-based aggregation. Smoothed with SWMA + RMA(6) to reduce noise.
- StdDev Bands: Upper and lower bands at RVWAP +/- (multiplier x volumeWeightedStdDev). Bands are derived from: Variance = SUM((hlc3 - RVWAP)^2 * volume) / SUM(volume), giving true volume-weighted statistical envelopes.
- Trend Colouring: RVWAP turns GREEN when it is rising and close > upper band (strong trend up), RED when falling and close < lower band (strong trend down), and WHITE when price oscillates within the bands (neutral / mean-reversion environment). Trend lookback is automatically synchronised to the RVWAP timeframe.
How to use
- Trend following: Trade in the direction of a green or red RVWAP when price breaks and holds outside the bands.
- Mean reversion: When RVWAP is white (neutral), band tags are potential mean-reversion entries back toward the RVWAP.
- Alerts: Two built-in alert conditions are included for price crossing above the upper band or below the lower band.
Inputs
- RVWAP Timeframe — Resolution for VWAP aggregation (default: 3-minute). Should be >= your chart timeframe.
- RVWAP Time Period in Hours — Rolling window for VWAP calculation (default: 10 hours).
- Standard Deviation Multiplier — Band width in standard deviation units (default: 2.0).
- Show Bands / Show Fill — Toggle band lines and fill visibility independently.
Important notes
This indicator uses lookahead=barmerge.lookahead_off on all request.security() calls. The last bar may update as real-time volume changes — this is normal VWAP behaviour and not a repainting issue.
The SWMA + RMA smoothing introduces some lag and is not intended for tick-level scalping.
Works on all markets and timeframes. On very thin/illiquid instruments, VWAP reliability depends on volume data quality.
Credits
Rolling time-window aggregation uses the PineCoders/ConditionalAverages/2 library (PineCoders, public domain per TV House Rules). All other code — volume-weighted standard deviation, timeframe synchronisation, trend state logic, and smoothing pipeline — is original.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。