the problem is After I cancel the order, The order will be keep on pending cancel forever. (see the image for reference, the unknown orders was with same problem but I restart the ninja)
my code is like this:
// subscribe
account.AccountItemUpdate += OnAccountItemUpdate;
account.PositionUpdate += OnPositionUpdate;
account.ExecutionUpdate += OnExecutionUpdate;
account.OrderUpdate += OnOrderUpdate;
.//
private void OnOrderUpdate(object sender, OrderEventArgs e)
{
Print ("On order update");
if (e.Order != null )
{
Print("Orden " + e.Order.Name + " orden id=" + e.Order.OrderId + " state =" + e.Order.OrderState);
if (account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar) <= Limit*(-1) && e.Order.OrderState == OrderState.Initialized)
{
Print("We are going to cancel the order.");
Order sa = null;
sa = e.Order;
account.Cancel(new[] { sa });
}
}
}
how I can cancel the new orders before they are sumitted to the broker, for market and limits orders?
Comment