Compare pending orders

To add comments, please log in or register
RJang
53
RJang  

Can someone please help me with this? Very much appreciated.

How can I compare pending orders with defined price? Suppose I want to open pending order at 1.0590, 1.0580, 1.0570 and 1.0560, I want to compare and check if any pending order missing. Lets say 1.0570 already executed (market price hit) EA should compare, find missing level and open a pending order at 1.0570.

Thanks in advance. 

RJang
53
RJang  
Nobody?
Amir Yacoby
1223
Amir Yacoby  
You can keep the ticket numbers and check them with OrderSelect
Anton Nel
49616
Anton Nel  
int ordersTotal = OrdersTotal();

//--- search in all open positions
for (int i = ordersTotal - 1; i >= 0; i--)
{
   //--- if an error occurs at selecting of this position then go to the next one...
   if (!OrderSelect(i, SELECT_BY_POS)) continue;
      
   //--- if the position was opened not for the current symbol, skip it...
   if (OrderSymbol() != Symbol()) continue;

   //--- if the OrderMagicNumber() is not equal to MagicNumber skip this position...
   if (MagicNumber > 0 && OrderMagicNumber() != MagicNumber) continue;

   ... you can add your conditions here ...
}
Note: This is for MT4
Diane Minshew
363
Diane Minshew  
RJang:

Can someone please help me with this? Very much appreciated.

How can I compare pending orders with defined price? Suppose I want to open pending order at 1.0590, 1.0580, 1.0570 and 1.0560, I want to compare and check if any pending order missing. Lets say 1.0570 already executed (market price hit) EA should compare, find missing level and open a pending order at 1.0570.

Thanks in advance. 

Put all orders into a struct array as they are being passed and that way you have to reference. I do it all the time.

are you using MT4 or MT5?

To add comments, please log in or register