I have been running a simple testing strategy and am getting "order is already filled" message/error on some orders and sometimes ninja freezes and I have to restart.
The strategy is run on each tick not onbarclose. Here is the code. I am not sure why. Is there anything odd in this code that stands out and is there anything I can add to eliminate this issue? I have tried a number of things but to no avail. Thanks in advance.
if(Ematrendlong==true
&&Lastbarlong==true
&&Twobarlong==true
&&PriceaboveEma==true
&&timeGap1<Time1
&&Position.MarketPosition == MarketPosition.Flat
&&BarsSinceExitExecution() > 1 || BarsSinceExitExecution() == -1
)
{
EnterLongLimit(Convert.ToInt32(DefaultQuantity), Close[1]-Pullbackentry*TickSize, @"Long1");
EnterLongLimit(Convert.ToInt32(DefaultQuantity), Close[1]-Pullbackentry*TickSize, @"Long2");
EnterLongLimit(Convert.ToInt32(DefaultQuantity), Close[1]-Pullbackentry*TickSize, @"Long3");
}
if (timeGap>Time2&&Position.MarketPosition == MarketPosition.Long&&BarsSinceExitExecution() > 1 || BarsSinceExitExecution() == -1 )
{
ExitLong(Convert.ToInt32(DefaultQuantity), @"Long1", @"Long1");
ExitLong(Convert.ToInt32(DefaultQuantity), @"Long2", @"Long2");
ExitLong(Convert.ToInt32(DefaultQuantity), @"Long3", @"Long3");
}
Comment