Page 1 of 1

Backtest with specific entry time

Posted: 09 Nov 2009
by raven
I would like to backtest an intraday system that allows no entries no later then 11 a.m.

The trigger signals are based on 1 day charts. Intrabar order generation as solution doesn't work. Meanwhile I tried to utilize a second data stream (data2) but with no success.

Does anybody know how to proceed? (For realtime trading it should be easy: "currenttime < 1100". But this and other functions don't work for backtesting.)

Many thanks in advance.

data2

Posted: 09 Nov 2009
by raven
Tried to reference data2 with functions like "barstatus", "entrytime", "lastcalcmmtime" or "sess1firstbartime".

data1 is 1 day bar, data 2 is 3 hour bar, session time is 08.00 a.m. to 6 p.m.

Whenever adding one of these functions to the code it's always the same: either no entries at all or entries as I hadn't added any additional function.

Simplified code example (applied to data1; 1 day bar):

condition1 = High > Low + 20;
if condition1 then buy 1 contract next bar at Open next bar;

So, how to reference data2 and what length of bar (1h, 3h, ...?) is appropriate to produce daily entries no later then 11.00 a.m. (sessions as above mentioned from 08.00 a.m. to 6 p.m.)?

Posted: 09 Nov 2009
by TJ
try this
var:
time2(0);

time2 = time data2;

if time2 <= 1100 then
begin

{... your trading instructions here}

end;

data2 is for the time trigger only,
therefore any intraday time frame that has a 1100 break should be ok.

Posted: 10 Nov 2009
by raven
Thank you, but didn't produce any entries. Reason might be that the entry related data1 can't use information about timestamps of data2 if - as I described above - data1 timeframe for a bar is greater then that of data2. Conversely it works (without your hint but completing the code a little bit):

condition1 = High data2 > Low data2 + 20 and time next bar = 1100;
if condition1 then buy 1 contract next bar at Open next bar;

Posted: 10 Nov 2009
by TJ
you have 2 issues here:

1. stop the trade after certain time
2. order triggering logic


your original question is on #1 issue.

I have not looked at your second issue.

you should separate the issues and tackle them separately.