The problem:
When the strat submits the first OCA order to TWS, it works fine. All subsequent OCA orders are rejected by TWS, however, with the error message displayed in TWS as "Cancelled by system: OCA group already filled".
Nothing gets written to the NT output window even when TraceOrders = true when the orders are cancelled. The strat works perefectly with a SIM account too.
The cause:
It finally dawned on me that I was using the same OCA string for every trade. TWS was then rejecting the orders as the OCA string was the same as the previous order which had already been filled.
The solution:
Give each OCA bracket order a unique string. I use CurrentBar, as long as the OCA trade is initiated in the same bar. It works perfectly.
if ( longOrder == null )
longOrder = SubmitOrder(0, OrderAction.Buy, OrderType.StopLimit, 1, High[1] + 2 * TickSize, High[1] + TickSize, "Entry" + CurrentBar.ToString(), "Long Limit");
if ( shortOrder == null )
shortOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.StopLimit, 1, Low[1] - 2 * TickSize, Low[1] - TickSize, "Entry" + CurrentBar.ToString(), "Short Limit");
Ninjascript Consultant

Comment