When i backtest the strategy every pair trade is perfectly synchronized and simoultaneous.
Unfortunately when i do a Foward Testing things the positions are unsinchronized for the duration of an entire bar or sometimes 2 bars and sometimes they don't even re-synchronize at all.
Actually the unsinchronized operations outnumber the others wich are correct.
The problem persist also when i automate the order execution with a demo account on IB.
So i am wondering why and i have attached my strategy settings and the data resolution with 2 futures on crude oil both master and slave in 1 minute resolution.
Any Help? thank you very much in advance..
The only thing that i have modified in the code is the exit criteria that goes like this:
Code: Select all
if ratio < AvgRatio and cur_pos = -1 then begin
cur_pos = 0;
buytocover this bar c;
end;
if ratio > AvgRatio and cur_pos = 1 then begin
cur_pos = 0;
sell this bar c;
end;