FIFO rules in closing pending order after time

 

Hi,

 

I'am a beginner in programming ea's. I start with strategy which open few pending order but after while are too much not actually pendings orders. For now I using a scripts like :

--------------------- 

for(int i=OrdersTotal()-1; i>=0; i--)

   {

      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

      {

         if (JustCurrentSymbol && Symbol()!=OrderSymbol()) continue;

         

         //

         //

         //

         //

         //

         

         int cmd=OrderType();

            if(cmd!=OP_BUY && cmd!=OP_SELL && OrderOpenTime()+timeElapsed<=TimeCurrent())

            {

               int result=OrderDelete(OrderTicket());

                  if(result!=TRUE) Print("LastError = ", GetLastError());

                  break;

            }

      }

   }

return(0); 

 

------------- 

but this scripts delete only newest order and hold the most older. How to change this code that before OrderDelete put a FIFO rules?

Thanks for help! 

 

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


Reason: