Aggregating Studies Starting at RTH


Category:
0
0

Hello,

Trying to figure out how to force studies to aggregate data only using real trading hours. I cannot find a clear answer on this site or in the Google-verse. Everytime I try the below script, which looks like it should work it only plots the value BEFORE market open. See script below… What am I doing wrong? I am about to rip my hair out. Would like for the VolumeSum variable to start plotting at 9:30 EST with only data for that day. Thanks in advance.

 

input Market_Open_Time = 0930;
input Market_Close_Time = 1600;
def pastOpen = If((SecondsTillTime(Market_Open_Time) > 0), 1, 0);
def BeforeOpen = If((SecondsFromTime(Market_Open_Time) < 0), 1, 0);
def pastClose = If((SecondsTillTime(Market_Close_Time) > 0), 0, 1);
def marketOpen = If(pastOpen and !pastClose, 1, 0);

def volumesum = if !marketOpen then 0 else volumesum[1] + volume;

Marked as spam
Posted by (Questions: 2, Answers: 0)
Asked on February 5, 2020 7:04 pm
55 views
0
Private answer

What you are requesting is to compute the total value for the regular session only, yes? Your question title seems to indicate something about aggregation periods. But this is nothing more than the time frame assigned to the chart.

I believe we have already addressed this question here:

https://www.hahn-tech.com/ans/volume-for-specific-time-frame/

Simply adjust the start and end time to fit the time span you are targeting. HINT: in the above solution the default start time is 4:00 and the end time is 9:29. So you will just change those times to 9:30 (930) and 15:59 (1559).

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on February 6, 2020 9:18 am