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

Re: 1 trade per session help



PureBytes Links

Trading Reference Links

> How would I limit a strategy to only placing 1 trade per session? I
> want to take the first trade in the session and then no more that
> day. 

If you're using RTH-only data, you can use this:

if EntriesToday(Date) = 0 
  or Time = Sess1EndTime then begin ...

The Time = Sess1EndTime allows orders to be placed on the last 
bar of the day, which are active for the first bar of the next 
day.

If you have 24hr data, it gets a little messier.  You'd use 
something like this:

if EntriesToday(Date) = 0 
  or Time = Sess1StartTime then begin ...

Time = Sess1StartTime on the last bar before RTH starts, since 
the first bar of RTH has Time = calctime(Sess1StartTime, 
BarInterval).  Unfortunately this won't work right if there is no 
bar with Time = Sess1StartTime.  If that's important -- if, for 
example, you're running 1min bars and sometimes there's no data 
in the minute before the open, and you don't want to miss any 
orders on the first bar -- then you could do something like

if EntriesToday(Date) = 0
  or Time of next bar crosses over Sess1StartTime then begin ...

That way you know the next bar will be the first bar in RTH.  But 
you will be limited to the things you can do in your system 
because EL won't let you do certain things (such as use multiple 
data streams) when you refer to the next bar in your system.

Gary