[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: code problem using 24hr data



PureBytes Links

Trading Reference Links

Hello Gary,
Thanks for the pointer that my code was blocking the first bar of the
day, I hadn't noticed that before,
if Time = Sess1FirstBarTime works fine but
if Time crosses over Sess2EndTime does not ?

and to David who suggested using session2 this was the main fix here
Changing Sess1 8:00pm - 4:00pm Sun to Fri
To       Sess1 8:00pm - 12:00pm Sun to Thurs
         Sess2 12:01pm - 4:00pm Mon to Fri
         
GF> What exactly are you trying to do?  With RTH-only data (Regular
GF> Trading Hours, not including the overnight session), that test  
GF> blocks the first bar of the day.  It's equivalent to  
GF>   if Time > Sess1FirstBarTime 

I was using that code to define each days data and to reset variables
for the next day, an example is, when using a variable tracking the
highest high of the day, resetting it from the highesthigh yesterday
to the high of Sess1FirstBar

GF> What data are you using?

The data is CBOT a/c/e financial data which does start at 8:00pm till
4:00pm the next day.
Like the SP and ES, the ZB symbol trades through, and at the same time
as the US (regular trading hours) symbol trades, the CBOT appear to
treat this as all one session, but TS needs 2 sessions to handle the
date change.

best regards,
foolsgold



>> I have been using this code successfully with intraday data 
>>  if time > Sess1FirstBarTime and time <= Sess1EndTime then 

GF> What exactly are you trying to do?  With RTH-only data (Regular  
GF> Trading Hours, not including the overnight session), that test  
GF> blocks the first bar of the day.  It's equivalent to  
GF>   if Time > Sess1FirstBarTime 
GF> or 
GF>   if Time <> Sess1FirstBarTime 
GF> since (with RTH-only data) all bars are <= Sess1EndTime. 

GF> If you're really just trying to block the first RTH bar, you  
GF> could use the "if Time <> Sess1FirstBarTime" test regardless of  
GF> whether you have overnight data or not.  

>> but now when trying to use it on 24hr data where the StartTime is 
>> 8:00pm and the EndTime is 4:00pm the next day, that code doesn't 
>> work as TS appears to think the end time is before the start time  

If StartTime >> EndTime like this, you need to change your test: 

GF>   if Time <= Sess1FirstBarTime OR Time > Sess1EndTime then 

GF> That's true for all bars after the first one at 8pm, and for all  
GF> bars before the last one at 4pm.  

GF> You could write your code to work for either case: 

GF> if Sess1FirstBarTime < Sess1EndTime  
GF>  then OKbar = (Time > Sess1FirstBarTime and Time <= Sess1EndTime) 
GF>  else OKbar = (Time <= Sess1FirstBarTime OR  Time > Sess1EndTime) 
GF> if OKbar then ... 

GF> What data are you using?  For 24hour e-mini data,  
GF> Sess1FirstBarTime is 835 (Chicago time).  Session 1 is normally  
GF> the Regular Trading Hours session, and Session 2 is normally the  
GF> overnight session.  Are you sure Sess1FirstBarTime is 2000 (8pm),  
GF> and are you sure it should be?  

GF> Gary