I have finally found a strategy that I think can work for me, but there is one issue I need to resolve in order to complete the code. I would need to be able to search for any pre-existing stop orders that the user might have sent before the strategy was turned on, and take control of them and cancel them, but my attempt to do so produced an error message saying that I couldn't convert an Order object into an IOrder object. Here's an example of the code:
if(Account.Orders!= null)
{
OrderCollection acctOrders = Account.Orders;
foreach (Order ord in acctOrders)
{
if(ord.Instrument.MasterInstrument.Name == Instrument.MasterInstrument.Name && ord.OrderType == OrderType.Stop && ord.OrderState == OrderState.Accepted)
{
IOrder orderToCancel = ord; <- This line here won't be accepted because it's converting Order to IOrder implicitly
CancelOrder(orderToCancel);
}
}
}
Once I can know a way to grab and cancel orders that were not created by the strategy I will be ready to roll. Does anyone know what I'm missing? Thank you!

Comment