I got a situation here, which I've tried to discover the cause but still.
It's a simple rutine of exit a long position and cancelling its StopLoss. The script uses the unmanaged approach.
The order of exitLong:
xlEntryOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Limit, Qty, priceEntry, 0, "", "Exit Long");
protected override void OnExecution(IExecution execution) { if (xlEntryOrder != null && xlEntryOrder== execution.Order ) { if ( xlEntryOrder.OrderState == OrderState.Filled) { CancelOrder(slEntryOrder); // Cancel the stop order xlEntryOrder = null; } if ( xlEntryOrder.OrderState == OrderState.PartFilled ) { ChangeOrder(slEntryOrder, Position.Quantity-xlEntryOrder.Filled, 0, (Position.AvgPrice-stop)); // Change the Stop order accordingly } if ( xlEntryOrder.OrderState == OrderState.Cancelled && xlEntryOrder.Filled > 0) { ChangeOrder(slEntryOrder, Position.Quantity-xlEntryOrder.Filled, 0, (Position.AvgPrice-stop)); xlEntryOrder = null; } } }
if I add the others PartFilled or Part.Filled and Cancelled, it just simple doesn't run, NT give the typical Run time error.
So any ideas why this?
Comment