How to close buy or sell pending orders

Created at 29 Mar 2024, 20:06
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MI

mihlali700

Joined 22.12.2023

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);
                     
             }
            
        }

 

 


@mihlali700
Replies

firemyst
30 Mar 2024, 04:43

if (order.TradeType == TradeType.Buy)
{
}

@firemyst