example
if(targetShort_Unmanaged != null && targetShort_Unmanaged == order)
{
if(order.OrderState == OrderState.Cancelled && order.Filled == 0 )
{
targetShort_Unmanaged = null;
}
}
List<string> OrdersToNull = new List<string>();
foreach(Order o in Orders)
{
if( o != null && o.OrderState == OrderState.Cancelled && order.Filled == 0 )
{
OrdersToNull.Add(order.Name);
}
}
for(int i =0; i > OrdersToNull.Count; i++)
{
OrdersToNull[i] = null;
}
Also, just because you set the order objects to null doesn't cancel the orders right? Wouldnt you need to use "CancelOrder(Order);" to cancel your protective orders?
The below code is part of the unmanaged template.
//sets all targets and stops to null if one of them is canceled
//PLEASE NOTE: setting IOrders to null ***DOES NOT*** cancel them
if ((targetLong != null && targetLong == order)
||(stopLossLong != null && stopLossLong == order)
||(targetShort != null && targetShort == order)
||(stopLossShort != null && stopLossShort == order)
)
{
if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
{
targetLong = stopLossLong = targetShort = stopLossShort = null;
}
}
Comment