I am using the bellow code.
and get an error of object reference is not set to an instance of an object
what am I not defining correctly ? do I need to specifically define the account ?
else if (State == State.Terminated)
{
foreach (Order order in Account.Orders)
{
if ( Position.MarketPosition == MarketPosition.Flat) CancelOrder(order);
}
}
for( int i = 0; i < Account.Orders.Count; i++ )
{
if ( Position.MarketPosition == MarketPosition.Flat) CancelOrder(Account.Orders[i]);
}

Comment