The following Pine script does not always reset VWAP at midnight. This is especially a problem when looking at bonds in the sub 1 minute scale.
I see it most on ZF in the 30 second scale. Seems to work fine most times on the 1 minute and higher bars.
================================ ` //@version=5 indicator('VWAP Midnight', overlay=true)
var float vwapsum = na
var float volumesum = na
//------------------------------------------------
Midnight = timestamp("UTC-5:00",year, month, dayofmonth, 00, 00, 00)
newSession = Midnight == time ? 1 : 0
//------------------------------------------------
vwapsum := newSession ? hl2 * volume : hl2 * volume + vwapsum[1]
volumesum := newSession ? volume : volume + volumesum[1]
myvwap = vwapsum / volumesum
coloring = color.aqua
av = myvwap
A = plot(av, style=plot.style_circles, color=color.new(coloring, 0))`
=======================================
Also, if I change the "UTC-5:00" to "UTC+3:00" it works fine. Even "UTC-4:00" does not work. I am located in San Diego (PST), but my graph is set to New York Time (EST). I posted some screenshots of the graph and the code and how it was showing VWAP on the graph. On one of the screenshots, you can clearly see a break in the VWAP line at the coded time based on UTC.
I tried to reach out to TradingView support, but they said it was working fine.
Let me know if you can not replicate the issue.
I tried to have VWAP reset at midnight NYC time, instead of 6pm NYC time as is the VWAP default.