Need Help Closing All Open Orders

 
When my EA closes my trades on live trading mode, I get FIFO violation messages because my older orders are not being closed first. Is there a way to close all open orders in one trade instead of one at a time? It seems time consuming when only one order is closed at a time. I would like to be able to close all my open orders at one price level instead of one at a time which results in multiple price levels. If its not possible to close all open orders in one trade, would fixing the order closing process, older orders being closed first in order to avoid the FIFO violation messages, speed up the closing process? Even though I get the FIFO violation messages, the orders do get closed. Any advice would be great. Here is the closing criteria from my EA:
  
  // closing LONG

int total=OrdersTotal();
for(int cnt=total-1;cnt>=0;cnt--)

     {
      OrderSelect(cnt, SELECT_BY_POS);
      if(   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // LONG position is opened
           {
            // should it be closed?
            if(RSI>SellPoint)
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                  // exit
                }
            // check for trailing stop
            
           }
         else // go to SHORT position
           {
            // should it be closed?
            if(RSI<BuyPoint)
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
                // exit
              }
            // check for trailing stop
            
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
 
fxtrader86:
When my EA closes my trades on live trading mode, I get FIFO violation messages because my older orders are not being closed first. Is there a way to close all open orders in one trade instead of one at a time? It seems time consuming when only one order is closed at a time. I would like to be able to close all my open orders at one price level instead of one at a time which results in multiple price levels. If its not possible to close all open orders in one trade, would fixing the order closing process, older orders being closed first in order to avoid the FIFO violation messages, speed up the closing process? Even though I get the FIFO violation messages, the orders do get closed. Any advice would be great. Here is the closing criteria from my EA:
No, you have to close them one at a time and you have to close the oldest first, find the oldest by OrderOpenTime() and close it, then find the next, etc.
 

I have never heard of this rule, so I googled it.

Is this just with American brokers?

From what I see, with open orders of the same size on the same currency pair, oldest must be closed first.

Not clear whether longs and shorts are considered separately .

This could really mess things up when running an EA in different time-frames with the same pair.

 

Yes that's with American traders. Some brokers took the change literally. Some forced the SL/TP to be most restrictive of the oldest. Some implemented the FIFO rule in their back office accounting and did not break the MT4 model.

American traders can not hedge either - there are no "longs and shorts"