Ok, after getting some clarifications I will ignore the code that was provided. I see that you want to compute the total number of dollars traded. Which is simply the number of shares times the current price. The scan will be run on a daily time frame. So you will need to scan after the markets close in order to get the full day’s value. I am providing two types of scans. One for the total gross value and one for the daily average of that value.
def totalDollars = volume * close;
def averageTotalDollars = Average(totalDollars, 20);
# use this to scan for current day total dollars greater than 1 million
plot scan = totalDollars > 1000000;
# use this to scan for 20 day average of total dollars greater than 1 million
#plot scan = averageTotalDollars > 1000000;
This code does not produce a scan. This is not a stock scanner. Are you trying to do a custom watchlist column?
Aside from multiplying total volume times share value, what are you trying to achieve here? Honestly from the math used in your AddLabel() statement I am not sure what you are trying to compute. So what is wrong with using volume times close? And I guess you want the average value, rather than current values?
I’ll get you some solutions once you clarify things a bit more.