מעודכן
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.
הערות שחרור
Update: GatedStats engine, selectable smoothing, volume confirmationCalculation
- The rolling VWAP and its standard deviation now come from the GatedStats library (jabez4jc/GatedStats/1), replacing PineCoders/ConditionalAverages. One call returns both values.
- The standard deviation is now the true weighted standard deviation of the window: every sample is measured against the current window VWAP. The old version measured each bar against the VWAP at the time it arrived, so band widths will differ slightly from before.
Smoothing
- Smoothing now has its own settings group: choose the type (SMA, EMA, RMA, WMA, SWMA, VWMA) and the length. It replaces the fixed RMA(SWMA(6)) smoothing. Smoothing is still off by default.
- The default smoothing is EMA 6, which lags less than the old setup (roughly 2-3 bars instead of 6-7).
- SWMA always uses 4 samples, so the length input is disabled when it is selected.
- A single missing value no longer blanks the line for several bars. The smoothed value holds its last reading.
Signals
- Continuation signals: a buy now fires on the bar that crosses above the upper band and on later bars that stay above it while closing higher than the previous close. A sell works the same way below the lower band. Expect more signals than before.
- New filter, relative volume: the signal bar's volume must exceed its rolling 24-hour average by a chosen multiple (default 1.2x).
- New filter, directional volume dominance: for buys, up-bar volume must have exceeded down-bar volume over the last N bars (default 20), and the reverse for sells. The window ends one bar before the signal bar, so the signal bar's own volume cannot confirm itself. Up bar and down bar (close vs open) are only a rough proxy for buying and selling pressure, because volume is unsigned.
- Existing filters are unchanged: rising smoothed ATR and RVWAP trend alignment. Every filter has its own on/off toggle in the Signal Filters group.
Fixes
- The trend filter could never be true when the RVWAP timeframe was lower than the chart timeframe (for example a 1 minute RVWAP on a 5 minute chart). It now compares against the previous chart bar, so signals and the green/red line color work on any chart timeframe.
- Hiding the bands no longer disables the buy and sell signals and their alerts. Show Bands is now display-only.
- Calls to ta.crossover and ta.crossunder now run on every bar, which removes the compiler warning about conditionally executed functions.
Notes
- Requires the GatedStats library. The indicator imports a fixed version, so it keeps working if the library is updated later.
- The volume filters use the current bar's volume and close position, so signals on the live bar can appear and then disappear before the bar closes. Closed-bar signals do not change.
- The filters and the minimum of 10 bars (MIN_BARS) delay the first signals after the chart loads.
הערות שחרור
Update: new defaults- RVWAP timeframe: the chart timeframe.
- RVWAP period: 1 hour.
- Standard deviation multiplier: 1.0.
- Smoothing: on by default, with type SWMA. SWMA always uses 4 samples, so the length input is disabled while it is selected.
- Directional volume lookback: 34 bars.
Note
- The window never holds fewer than 10 bars. With the 1-hour default, the window is effectively 10 bars on chart timeframes of 15 minutes and above, because the hour spans fewer than 10 bars there.
הערות שחרור
Update notes- Band multiplier is now a Fibonacci ratio dropdown: the free-form Standard Deviation Multiplier is replaced by a list of 19 ratios, from 0.236 to 4.236 (0.236, 0.382, 0.5, 0.618, 0.707, 0.786, 0.886, 1.0, 1.13, 1.272, 1.414, 1.618, 2.0, 2.272, 2.414, 2.618, 3.141, 3.618, 4.236). Each entry shows a short note on how traders read that level, so you can pick a band width with a reason. Tighter ratios signal earlier and more often; wider ratios signal later, with fewer and stronger breakouts. The default is 1.13, the closest ratio to the previous 1.1.
- New "Require Narrow Band" signal filter: a signal now needs the band to have been narrow before the breakout. The previous bar's band width, as a fraction of price, must be at most "Max × avg width" times its rolling 24-hour average. The default is 0.8, and lower values demand a tighter squeeze. Untick it to get the previous behaviour back. The filter looks at the bar before the breakout, because the breakout itself widens the band.
Things to know
- The narrow-band filter is on by default, so you will see fewer signals than before.
- The multiplier range is now 0.236 to 4.236. Values below 0.236 and above 4.236 are no longer available.
- Ratios above 2 put the bands very far from the VWAP, so signals will be rare. They suit volatile symbols or long RVWAP windows.
- On higher timeframes the 24-hour window holds few bars, so the narrow filter may give no signals until enough bars exist. Untick it if that happens.
- The ratio notes describe common trading conventions, not guarantees.
הערות שחרור
Added VWAP Lookback touch for signals כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.