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

Re: code problem using 24hr data



PureBytes Links

Trading Reference Links

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

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

If you're really just trying to block the first RTH bar, you  
could use the "if Time <> Sess1FirstBarTime" test regardless of  
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: 

  if Time <= Sess1FirstBarTime OR Time > Sess1EndTime then 

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

You could write your code to work for either case: 

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

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

Gary