Calculation on a intraday indicator with repeated values

I calculate first hour volume like following :

endbar=Timenum()==103000;
NewDay = Day()!= Ref(Day(), -1) OR BarIndex()==0;
vol_1hr=ValueWhen(endbar,SumSince(Newday,Volume));

Now i actually want to compare this with previous 10 days 1st hour volume. Since vol_1hr array contains repeated data points. How should i get this value ?
For ex: vol_1hr=[10,10,10,10,10,20,20,20,20,20,20,30,30,30,30,30]
But actually i want to take average vol_1hr , such that it can be compressed to daily, such that 3 bar average give average of 10,20 and 30 instead of 30,30,30.

1 Like

This topic has been addressed many times. For example, please see this post: Accessing Previous Days data of Particular Time Interval

1 Like

So i tried using SparseCompress:

close_time=SparseCompress(TimeNum()==103000,C);
ma_close=MA(close_time,3);
ma_indicator = SparseExpand(TimeNum()==103000,ma_close);

When i try to plot this in 5 min chart, its empty.

If you plot the condition, do you see the histogram at 10:30:00 ?

Plot(TimeNum()==103000, "TN", colordefault, stylehistogram | styleownscale);

Actually yes it plots a histogram at 1030, i was trying to plot by line all the while. Thanks