how can i check the pending orders become market orders or not in mql5?

 

Hi, how can i check the pending orders become market orders or not in mql5?

i run the below function to see it has triggered or not. But i find that it always print "Have Pend Orders" even when the orders become buy or sell. 

anyone can help?

bool OrderSearch(){
   total_p=false;

   int  total = OrdersTotal();
   
   for(int i=0; i<=total; i++){
      if(my_order.Select(OrderGetTicket(i))){
         if(my_order.Magic()==MagicNumber && my_order.Symbol()==Symbol()){
            if(my_order.OrderType()>=ORDER_TYPE_BUY_STOP){
               total_p=true;
               printf("Have Pend Orders");
            }
            else{
               total_p=false;
               printf("No pend order in market");
            }
         }
      }
   }
   return (total_p);
}
 
Yip Sin Hang:

Hi, how can i check the pending orders become market orders or not in mql5?

i run the below function to see it has triggered or not. But i find that it always print "Have Pend Orders" even when the orders become buy or sell. 

anyone can help?

Look to the OnTradeTransaction() event.

https://www.mql5.com/en/docs/basis/function/events


OnTradeTransaction

When performing some definite actions on a trade account, its state changes. Such actions include:

  • Sending a trade request from any MQL5 application in the client terminal using OrderSend and OrderSendAsync functions and its further execution;
  • Sending a trade request via the terminal graphical interface and its further execution;
  • Pending orders and stop orders activation on the server;
  • Performing operations on a trade server side.
 
Yip Sin Hang:

Hi, how can i check the pending orders become market orders or not in mql5?

i run the below function to see it has triggered or not. But i find that it always print "Have Pend Orders" even when the orders become buy or sell. 

anyone can help?

#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006

bool OrderSearch(){
   total_p=false;

   int  total = OrdersTotal();
   
   for(int i=0; i<=total; i++){
//      if(my_order.Select(OrderGetTicket(i))){
//         if(my_order.Magic()==MagicNumber && my_order.Symbol()==Symbol()){
//            if(my_order.OrderType()>=ORDER_TYPE_BUY_STOP){
      if(OrderSelect(i, SELECT_BY_POS)){
         if(OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol()){
            if(OrderType()>OP_SELL){
               total_p=true;
               printf("Have Pend Orders");
            }
            else{
               total_p=false;
               printf("No pend order in market");
            }
         }
      }
   }
   return (total_p);
}
Reason: