I am trying to implement a pair strategy. And it works fine on backtesting but when I start testing it with Sim account or use market reply it has big differences with backtesting. And I don't understand where those problems come from.
The logic is simple. I have main 1 minute bar which works like clocks. And two tick series.
I have a code like this:
if (this.BarsInProgress != 0)
{
return;
}
var close1 = this.Closes[1][0];
var close2 = this.Closes[2][0];
// Use some indicator to calculate if I need to open or close positions based on close1 and close2 prices.
I have COBC=true for main bar.
It would be good to have results as close as posible to backtesting.
I have made some test with this code:
I have main bar "APA" with with 1 minute period type.
and two additional instruments:
this.Add("APA", PeriodType.Tick, 1);
this.Add("APC", PeriodType.Tick, 1);
protected override void OnBarUpdate()
{
this.PrintWithTimeStamp(this.BarsInProgress + " " + this.Times[0][0] + " " + this.Times[1][0] + " " + this.Times[2][0]);
}
And have this result for market reply:
31/05/2012 8:09:48 AM 2 31/05/2012 8:09:00 AM 31/05/2012 8:09:45 AM 31/05/2012 8:09:48 AM
31/05/2012 8:09:49 AM 2 31/05/2012 8:09:00 AM 31/05/2012 8:09:45 AM 31/05/2012 8:09:49 AM
31/05/2012 8:09:45 AM 1 31/05/2012 8:09:00 AM 31/05/2012 8:09:45 AM 31/05/2012 8:09:49 AM
31/05/2012 8:09:50 AM 1 31/05/2012 8:09:00 AM 31/05/2012 8:09:50 AM 31/05/2012 8:09:49 AM
31/05/2012 8:09:50 AM 1 31/05/2012 8:09:00 AM 31/05/2012 8:09:50 AM 31/05/2012 8:09:49 AM
This never happens on backtesting. And I don't understand why it happens on real testing.
I can't undertand why tick with time 8:09:45 comes after tick with timestamp 8:09:49.
I use Kinetick data. My clocks are syncronized.
Thanks

Comment