The code below successfully cancels the buyOrder immediately after it is placed. However if I place a.Cancel(new[] { buyOrder }); into a new method for a new button, it doesn't work.
How can I reference the correct buyOrder in the new method?
Alternatively, is it possible to loop through all existing purple pending orders and cancel them?
Order buyOrder = a.CreateOrder(Instrument, OrderAction.Buy, OrderType.StopLimit, TimeInForce.Day, quantitySelector.Value, high + .25, high + .25, string.Empty, "Entry", null); NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy("1", buyOrder); Print(buyOrder.Id); a.Cancel(new[] { buyOrder });
Comment