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

Re: EL question



PureBytes Links

Trading Reference Links

> there is a problem...
> I think Sess1Endtime take the end time from Globalserver; the
> problem is: the market I follow recently change his end time (from
> 1730 to 1740); so in Global server now it's 1740; historical data
> to test ends at 1730; so 
> If (time=Sess1Endtime) then
> doesn't work..
> How can I keep anyway the last trading session bar?

That *is* tricky.

To trade on the first bar of the day, you must place the order on the 
last bar of the previous day.  But the normal way of detecting the 
last bar of the day (Sess1EndTime) doesn't work very well in your 
case because it's changed.  (It also doesn't work for short days, 
i.e. days that don't have a bar at Sess1EndTime, but usually those 
are infrequent enough that you can ignore them.)

I can think of two solutions:

* Place the orders if Time >= Sess1EndTime - X.  So for example if 
you're trading 30min bars, your data used to end on the 1730 bar but 
now there's a 10-minute-long bar ending at 1740.  You could try 
placing the order if Time >= 1730.  This means the order will 
sometimes be hit on the 1740 bar, and that might not be acceptable 
for your testing.

* If you can do it, there's a better answer.  Check the date of the 
NEXT BAR.  For example,

   if Date of next bar > Date then ((place 1st-bar order));

You can even refer to the open of the next day's bar:

   if Date of next bar > Date then buy at open of next bar + X stop;

EL allows you to check the next bar in certain conditions.  You can't 
use a "buy/sell at close" order if you're referring to the next bar.  
So, for example, EL prohibits you from doing this:

   if Open of next bar > Close then
     buy at close;
     sell next bar at open;
   end;

Obviously that's not legal!  

I don't think there's any kind of illicit games you can play just by 
looking at the *Date* of the next bar.  But EL won't allow you to 
"buy at close" even if you just look at the Date.

So if you don't have to do any "buy at close" type of orders, you can 
issue your first-bar order only when "Date of next bar > Date".  If 
not, you'll have to kludge a less elegant solution.

Gary