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が提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。