I also use the TV rolling VWAP, primarily a 50 period on 5M chart.
ChatGPT helped me with this one, and it is identical to the TV 50/5. I didn't play with any other periods or timeframes, so YMMV.
Hope it helps someone.......
Code:
# VWAP ThinkScript Example with True Rolling VWAP
# Calculates the VWAP for a given symbol using a true rolling VWAP
# Define Inputs
input price = close;
input volume = volume;
input rollingPeriod = 50;
# Define Variables
def cumPV =
if BarNumber() == 1 then price * volume else
if BarNumber() <= rollingPeriod then cumPV[1] + price * volume else cumPV[1] + price * volume - price[rollingPeriod] * volume[rollingPeriod];
def cumVol = if BarNumber() == 1 then volume else if BarNumber() <= rollingPeriod then cumVol[1] + volume else cumVol[1] + volume - volume[rollingPeriod];
# Calculate True Rolling VWAP
def rollingVWAP = cumPV / cumVol;
# Plot True Rolling VWAP on Chart
plot vwapLine = rollingVWAP;
vwapLine.SetDefaultColor(color.yellow);
vwapLine.SetLineWeight(2);