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 อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน