I have the following code that returns cumulative volume during premarket hours for today.
How can I update it so I can calculate cumulative volume during premarket hours for any day in the past, in the 1 minute chart?
I think I have to start looking 390 * X days back? But I'm missing something and can't make it work.
How can I update it so I can calculate cumulative volume during premarket hours for any day in the past, in the 1 minute chart?
I think I have to start looking 390 * X days back? But I'm missing something and can't make it work.
Code:
input startTime = 0400;
input endTime = 0929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
# This is the cumulative volume for the current day
def totalVolume = if targetPeriod and !targetPeriod[1] then volume
else if targetPeriod then totalVolume[1] + volume
else totalVolume[1];
plot signal = totalVolume;