Hello, 

I am looking for a way to find the average volume over ~14 trading days for any given 5 min bar. So if it is 10:05, I want to know what the average volume of 10-10:05 would be for the last 14 days. Is there an efficient way to do this?

The only solution I've thought of so far would be to create a rolling window of 192 blocks per day (960 Min in a trading day including extended market hours / 5) and then create a variable for the last 14 trading days in increments of 192 for the rolling window and take an average. 

This seems like a fairly inefficient way to get to the answer. Any thoughts on a better approach?

Thanks!

Author