TradingView
TradingView
Mar 29, 2022 2:55 PM

Rolling VWAP 

U.S. Dollar/Canadian DollarFXCM

Description

█  OVERVIEW


This indicator displays a Rolling Volume-Weighted Average Price. Contrary to VWAP indicators which reset at the beginning of a new time segment, RVWAP calculates using a moving window defined by a time period (not a simple number of bars), so it never resets.



█  CONCEPTS


If you are not already familiar with ​VWAP, our Help Center will get you started.

The typical VWAP is designed to be used on intraday charts, as it resets at the beginning of the day. Such VWAPs cannot be used on daily, weekly or monthly charts. Instead, this rolling VWAP uses a time period that automatically adjusts to the chart's timeframe. You can thus use RVWAP on any chart that includes ​volume information in its data feed.

Because RVWAP uses a moving window, it does not exhibit the jumpiness of VWAP plots that reset. You can see the more jagged VWAP on the chart above. We think both can be useful to traders; up to you to decide which flavor works for you.



█  HOW TO USE IT


Load the indicator on an active chart (see the Help Center if you don't know how).


Time period

By default, the script uses an auto-stepping mechanism to adjust the time period of its moving window to the chart's timeframe. The following table shows chart timeframes and the corresponding time period used by the script. When the chart's timeframe is less than or equal to the timeframe in the first column, the second column's time period is used to calculate RVWAP:

Chart Time timeframe period 1min 🠆 1H 5min 🠆 4H 1H 🠆 1D 4H 🠆 3D 12H 🠆 1W 1D 🠆 1M 1W 🠆 ​3M


You can use the script's inputs to specify a fixed time period, which you can express in any combination of days, hours and minutes.

By default, the time period currently used is displayed in the lower-right corner of the chart. The script's inputs allow you to hide the display or change its size and location.


Minimum Window Size

This input field determines the minimum number of values to keep in the moving window, even if these values are outside the prescribed time period. This mitigates situations where a large time gap between two bars would cause the time window to be empty, which can occur in non-24x7 markets where large time gaps may separate contiguous chart bars, namely across holidays or trading sessions. For example, if you were using a 1D time period and there is a two-day gap between two bars, then no chart bars would fit in the moving window after the gap. The default value is 10 bars.



█  NOTES


If you are interested in VWAP indicators, you may find the VWAP Auto Anchored built-in indicator worth a try.


For Pine Script™ coders

The heart of this script's calculations uses the `totalForTimeWhen()` function from the ConditionalAverages library published by PineCoders. It works by maintaining an array of values included in a time period, but without a for loop requiring a lookback from the current bar, so it is much more efficient.

We write our Pine Script™ code using the recommendations in the User Manual's Style Guide.


Look first. Then leap.

Release Notes

v2
Updated to include standard deviation bands adjustable from the input menu.

Release Notes

v3

Updated to include 2 more sets of standard deviation bands.
Comments
Vibranium_Capital
Thanks for this, I may try out it! Looks promising
PineCoders
@Vibranium_Capital, Thank you for your continued support!
Vibranium_Capital
@PineCoders, I will always support, this is by far the best platform for traders. Love TV
MaydayDave
This is one of the best indicators on TradingView. Please look into adding a "Rolling TWAP" script - I think TWAP can be more useful than VWAP in certain cases.
PineCoders
@MaydayDave, Thanks for the kind words and support. Thanks as well for the suggestion. We may consider it in future versions.
WicktatorFX
Brilliant! Looking forward to trying this out
PineCoders
@WicktatorFX, Thank you, and hope you enjoy!
theheirophant
love it!!! windowed vwap is something I have been using as well!
PineCoders
@theheirophant, Glad you like it and thank you for taking the time to comment!
ballis13
This has been super helpful. Thanks for the work on this.
More