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.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.