How can I know average volume over a certain period of time


If I am looking at 5 min chart or if I want to backtest a stock with 5 min bar intervals, then how can I find average volume of last 5 days (not just last 5 bars)? Does following give the average volume for last 5 days on a chart with 5 min bar interval?


(each trading has 6 hours & 15 min of trading. That makes 63 bars of 5 min interval each. 63 x 5 = 315)

Please advise. Thanks!

NaMasTe TraDeR,

The logic is right, provided you set sufficient backfill data on the backtest engine. But this tradescript code averaging 315 candles will fail the backtest engine.