Hello everyone, I want to calculate the average volume of the last 5 days in the following code.
However, in the chart, it does not differentiate when I choose a timeframe smaller than 1 Day. I can choose a 15 or 30-minute frame and it still gives accurate results. But in the scan, when choosing a timeframe smaller than 1 Day, it says "Secondary period not allowed: Day.". Does anyone know how to get the average volume value of the last 5 days when using the scan? Sincerely thank you.
Code:
def day1 = volume(period = AggregationPeriod.DAY)[1];
def day2 = volume(period = AggregationPeriod.DAY)[2];
def day3 = volume(period = AggregationPeriod.DAY)[3];
def day4 = volume(period = AggregationPeriod.DAY)[4];
def day5 = volume(period = AggregationPeriod.DAY)[5];
def Avg = Round((day1 + day2 + day3 + day4 + day5) / 5, 0); # tried to implement as a fold function but couldn't get it to work
AddLabel(yes, "Avg: " + Avg, Color.WHITE);
However, in the chart, it does not differentiate when I choose a timeframe smaller than 1 Day. I can choose a 15 or 30-minute frame and it still gives accurate results. But in the scan, when choosing a timeframe smaller than 1 Day, it says "Secondary period not allowed: Day.". Does anyone know how to get the average volume value of the last 5 days when using the scan? Sincerely thank you.