Here is my strategy:
protected override void Initialize()
{
SetProfitTarget( CalculationMode.Ticks, profitTarget );
SetStopLoss( CalculationMode.Ticks, loseTarget , true);
CalculateOnBarClose = true;
}
protected override void OnBarUpdate()
{
if(condition1 && condition2){ EnterLong();}
if(condition3){ ExitLong(); }
if(condition3 && condition2){ EnterShort();}
if(condition1){ ExitShort(); }
}
when condition1 && condition2 is true, I will have EnterLong and ExitShort at the same time. And when condition3 && condition2 is true, I will have EnterShort and ExitLong orders at the same time.
In the above situation, There should be only 2 orders filled(1 exit and 1 entry), my AT works well in history data.
Here is the problem, in real-time, it will have 3 orders filled instead of 2. There are 2 BuyToCover orders(should be 1), I don't know why, but the it only happen at real-time.
If I let the AT keep running it will add 6 additional entries after 5 trades. and get the overfill msg popup sometimes.
Comment