Session VWAP: Uses the change in time("D") to detect a new day and resets the cumulative price‐volume and volume totals. The VWAP is then the cumulative price × volume divided by the cumulative volume.
2‑Day VWAP: Maintains separate accumulators for the current day and the previous day. On a new day, the previous day’s totals are saved and then added to the current day’s running totals to compute a VWAP spanning the two most recent days.
Weekly VWAP: Uses ta.change(time("W")) to reset the weekly accumulators at the start of a new week.
Anchored VWAP: Begins accumulation when the current bar’s time exceeds the user‐defined anchor time. Once started, it continues to accumulate indefinitely.
Feel free to modify the inputs and styling to suit your preferences.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publications is governed by House rules. You can favorite it to use it on a chart.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.