Download MetaTrader 5

FIFO rules in closing pending order after time

To add comments, please log in or register
Install apps from the library right in MetaTrader. It is easy!
Slawomir Dziegielewski
246
Slawomir Dziegielewski 2015.08.12 21:28 

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! 

Alain Verleyen
Moderator
30742
Alain Verleyen 2015.08.13 08:50  

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.


To add comments, please log in or register