VWAP in multi timeframe

I have a fundamental issue in the code. I want to populate last value of 5 min VWAP to hourly and daily chart.
Following code has issue in BARSSINCE function in different time frame. Can someone help.

Below is my code to calculate VWAP:

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

//VWAP CODE

TimeFrameSet(in5Minute);
bars_filter=BarsSince( Day() != Ref(Day(), -1));
Bars_so_far_today = 1 +bars_filter ;
StartBar = ValueWhen(TimeNum() == 091500, BarIndex());
TodayVolume = Sum(V,Bars_so_far_today);
IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today ) / TodayVolume,0);
x1=TimeFrameExpand(VWAP,in5minute);
//y1=TimeFrameExpand(TimeFrameCompress(VWAP,in5minute),inDaily);
Plot (x1,"VWAP" +WriteVal(bars_filter),colorOrange, styleline);
TimeFrameRestore();
1 Like