How to close buy or sell pending orders
Created at 29 Mar 2024, 20:06
MI
How to close buy or sell pending orders
29 Mar 2024, 20:06
Hello I need help closing buy or sell pending orders , I know there's 3 types of pending orders but I'm struggling on how to tell which pending order is a buy or sell to close them.
private void Close(TradeType tradeType)
{
foreach (var position in Positions.FindAll(null, SymbolName, tradeType))
ClosePosition(position);
foreach (var order in PendingOrders)
{
if(order.OrderType == PendingOrderType.Limit)
CancelPendingOrder(order);
if(order.OrderType == PendingOrderType.Stop)
CancelPendingOrder(order);
if(order.OrderType == PendingOrderType.StopLimit)
CancelPendingOrder(order);
}
}
firemyst
30 Mar 2024, 04:43
@firemyst