OPEN-SOURCE SCRIPT
Rolling VWAP with Signals

Rolling VWAP with Signals
Overview
Rolling VWAP with Signals plots a time-window ("rolling") VWAP with standard deviation bands, and generates filtered buy/sell signals on band breakouts. Unlike a session VWAP, which resets at a fixed anchor such as the start of day or week, this VWAP recalculates continuously over a trailing window that you define, for example the last 10 hours or the last 2 minutes of 3-minute bars. This keeps it adapting on any chart, in any session, in any market, including markets that trade around the clock.
This script is an original extension built on the rolling VWAP concept from Rolling VWAP. It adds standard deviation bands, trend-state coloring, crossover based buy/sell signals, an ATR rising filter, and a VWAP trend-alignment filter, none of which are present in the original.
How It Works
The rolling VWAP is computed by summing price times volume and volume over a trailing time window, then dividing, the standard VWAP formula applied to a moving window instead of a fixed session. The calculation runs on an independent timeframe set by the RVWAP Timeframe input, evaluated with request.security().
Standard deviation bands sit above and below the VWAP at a configurable multiple of the rolling standard deviation, computed with the direct weighted squared deviation method rather than the E[x^2] minus E[x]^2 shortcut, which avoids precision loss on high-priced instruments.
Pine Script®
Trend state is bullish when the VWAP is higher than it was one higher-timeframe bar ago and price is above the upper band, and bearish under the mirrored condition. The VWAP line is colored accordingly.
Buy and sell signals fire once, on the bar where price crosses a band, not on every bar price remains outside it:
Two optional filters narrow signals to higher-conviction setups:
Four alert conditions are available: price above the upper band, price below the lower band, a buy signal, and a sell signal.
Inputs
Usage Notes
Credits
Disclaimer
This script is provided for educational and informational purposes only and does not constitute financial advice. Past performance is not indicative of future results. Always do your own research and apply proper risk management before trading.
Overview
Rolling VWAP with Signals plots a time-window ("rolling") VWAP with standard deviation bands, and generates filtered buy/sell signals on band breakouts. Unlike a session VWAP, which resets at a fixed anchor such as the start of day or week, this VWAP recalculates continuously over a trailing window that you define, for example the last 10 hours or the last 2 minutes of 3-minute bars. This keeps it adapting on any chart, in any session, in any market, including markets that trade around the clock.
This script is an original extension built on the rolling VWAP concept from Rolling VWAP. It adds standard deviation bands, trend-state coloring, crossover based buy/sell signals, an ATR rising filter, and a VWAP trend-alignment filter, none of which are present in the original.
How It Works
The rolling VWAP is computed by summing price times volume and volume over a trailing time window, then dividing, the standard VWAP formula applied to a moving window instead of a fixed session. The calculation runs on an independent timeframe set by the RVWAP Timeframe input, evaluated with request.security().
Standard deviation bands sit above and below the VWAP at a configurable multiple of the rolling standard deviation, computed with the direct weighted squared deviation method rather than the E[x^2] minus E[x]^2 shortcut, which avoids precision loss on high-priced instruments.
Trend state is bullish when the VWAP is higher than it was one higher-timeframe bar ago and price is above the upper band, and bearish under the mirrored condition. The VWAP line is colored accordingly.
Buy and sell signals fire once, on the bar where price crosses a band, not on every bar price remains outside it:
- Buy — close crosses over the upper band
- Sell — close crosses under the lower band
Two optional filters narrow signals to higher-conviction setups:
- Rising ATR — requires an SWMA-smoothed ATR to be higher than the prior bar, filtering out breakouts occurring while volatility is contracting
- RVWAP trend alignment — requires the bullish or bearish trend state described above, so buy only fires in an established uptrend and sell only in an established downtrend
Four alert conditions are available: price above the upper band, price below the lower band, a buy signal, and a sell signal.
Inputs
- RVWAP Timeframe — Timeframe the rolling VWAP and standard deviation calculation runs on, independent of the chart timeframe. Default: 1 minute.
- RVWAP Time Period (Hours / Minutes) — Length of the trailing window used for the rolling calculation. Shorter windows track faster; longer windows behave more like a session VWAP. Default: 0 hours, 1 minute.
- Standard Deviation Multiplier — Distance of the bands from the VWAP, in standard deviations. Lower values give tighter bands and more signals; higher values give wider bands and fewer, stronger signals. Default: 1.618.
- Show Standard Deviation Bands — Toggles the band plots and disables buy/sell signals when off, since signals require a band cross. Default: on.
- Show Fill Between Bands — Toggles the shaded fill between the upper and lower bands. Default: on.
- Smooth VWAP/StdDev — Applies additional smoothing to the VWAP and standard deviation lines for a less-lagged appearance when off, or a smoother, laggier line when on. Default: off.
- Require Rising ATR for Signals — Gates buy and sell signals on a rising smoothed ATR. Default: on.
- Length — ATR length used by the rising-ATR filter. Default: 14.
- Require RVWAP Trend Alignment for Signals — Gates buy signals on a bullish RVWAP trend and sell signals on a bearish RVWAP trend. Default: on.
- Upper Band, Lower Band, Fill — Colors for the band lines and the fill between them.
Usage Notes
- Requires a data feed that provides volume; the script raises a runtime error if none is available.
- The rolling calculation needs a minimum of 10 bars within the window to produce a value; very short windows on sparse data may show gaps.
- Rising ATR means the current SWMA-smoothed ATR value is strictly greater than the previous bar's value, a one-bar comparison rather than a multi-bar slope.
- Values inside the current, still-forming RVWAP Timeframe bar can update intrabar, as with any request.security() call without a fixed historical offset. Confirmed bars do not repaint.
- Disable both signal filters to see every raw band-crossing signal, or enable them independently to trade off signal frequency against signal quality.
Credits
- Rolling VWAP methodology adapted from the original Rolling VWAP.
- Uses the open-source PineCoders ConditionalAverages library for the windowed total calculations.
Disclaimer
This script is provided for educational and informational purposes only and does not constitute financial advice. Past performance is not indicative of future results. Always do your own research and apply proper risk management before trading.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.