I am backtesting a multi-instrument strategy. All trades are done on the primary instrument. Below is a piece of my log file. I will explain what is happening.
The strategy is running on day bars and CalculateOnBarClose = true;
1: ================= START =================
2: OnBarUpdate: BarsInProgress 0 @ 2013-01-09 10:00:00 PM
3: OnBarUpdate: BarsInProgress 1 @ 2013-01-10 2:00:00 PM
4: Enter: XAU 2013-01-10 2:00:00 PM 160.55 159.84 163.61, GDX 2013-01-09 10:00:00 PM 44.48 44.65 44.36
5: Execute: Account Value = -103.49, Transaction = -10093.5, Direction = -1, Price = 44.86, Qty = 225, Time = 2013-01-10 10:00:00 PM
6: OnBarUpdate: BarsInProgress 0 @ 2013-01-10 10:00:00 PM
Please note that lines 4 and 5 are wrapped.
Line 1 is printed on entry to OnBarUpdate and shows BarsInProgress and Times[BarsInProgress][0] which should be the last bar close on the current data series.
Line 2 and 3 same.
Line 4 indicates the strategy has decided to go long in OnBarUpdate. The BarsInProgress = 1 but the order is being entered on series 0. The values given are series 1 symbol, Times[1[[0], Closes[1][2, 1, 0], series 0 simbol and the same data values for series 0. At this point, series 0 time is 2013-01-09 10:00:00 pm (1/9 close).
Line 5 comes from OnExecution. Ignoring the account values, it shows
-1 = this is a buy order
Price = 44.86
Qty = 225 shares
Time 2013-01-10 10pm
So the order was placed in the context of series 1 when the series 1 time is 1/10 2pm (1/10 close) and the order supposed was placed at the series 0 1/10 close. Fine so far.
Until I look at the GDX chart and observe that the order price above of 44.85 is the 1/10 bar open.
So effectively, the strategy makes a decision using the 1/10 close data, then enters at order executed at the 1/10 open. Time Travel.
Can someone please explain what is happening here?
Thanks,
++PLS

Comment