Download MetaTrader 5
To add comments, please log in or register
Order the development and track its status via your mobile phone.
Gordon Gekko
666
Gordon Gekko 2014.05.17 10:51 

Hi Gurus!

Please, tell me which version is the faster (or is there any faster than these)?

Version 1:

int NumberOfOrders=OrdersTotal();
   for(int h=0;h<NumberOfOrders;h++)
     {
      if(OrderSelect(h,SELECT_BY_POS))
        {
         for(k=0;k<NUMBER_OF_PAIRS;k++)
           {
            if(OrderMagicNumber()==Magic_Number_1 && OrderSymbol()==Pairs[k])
              {
               EnabledPairs_1[k]=false;
               switch(OrderType())
                 {
                  case OP_BUY:  Type_1[k]=1; break;
                  case OP_SELL: Type_1[k]=2;
                 }
              }
            else if(OrderMagicNumber()==Magic_Number_2 && OrderSymbol()==Pairs[k])
              {
               EnabledPairs_2[k]=false;
               switch(OrderType())
                 {
                  case OP_BUY:  Type_2[k]=1; break;
                  case OP_SELL: Type_2[k]=2;
                 }
              }
            else if(OrderMagicNumber()==Magic_Number_3 && OrderSymbol()==Pairs[k])
              {
               EnabledPairs_3[k]=false;
               switch(OrderType())
                 {
                  case OP_BUY:  Type_3[k]=1; break;
                  case OP_SELL: Type_3[k]=2;
                 }
              }
           }
        }
      else Print("OrderSelect error ",GetLastError());
     }

Version 2:

int NumberOfOrders=OrdersTotal();
   for(int h=0;h<NumberOfOrders;h++)
     {
      if(OrderSelect(h,SELECT_BY_POS))
        {
         for(k=0;k<NUMBER_OF_PAIRS;k++)
           {
            if(OrderSymbol()==Pairs[k])
              {
               switch(OrderMagicNumber())
                 {
                  case Magic_Number_1:
                    {
                     EnabledPairs_1[k]=false;
                     switch(OrderType())
                       {
                        case OP_BUY:  Type_1[k]=1; break;
                        case OP_SELL: Type_1[k]=2;
                       }
                    }
                  case Magic_Number_2:
                    {
                     EnabledPairs_2[k]=false;
                     switch(OrderType())
                       {
                        case OP_BUY:  Type_2[k]=1; break;
                        case OP_SELL: Type_2[k]=2;
                       }
                    }
                  case Magic_Number_3:
                    {
                     EnabledPairs_3[k]=false;
                     switch(OrderType())
                       {
                        case OP_BUY:  Type_3[k]=1; break;
                        case OP_SELL: Type_3[k]=2;
                       }
                    }
                 }
              }
           }
        }
      else Print("OrderSelect error ",GetLastError());
     }

Thanx in advance!

Bambang Sugianto
9831
Bambang Sugianto 2014.05.17 12:12  

you can try your self

   int begin=GetTickCount();
   
  PLACE YOUR FUNCTION HERE.......


 int miliseconds=GetTickCount()-begin;
 Alert(miliseconds);
Gordon Gekko
666
Gordon Gekko 2014.05.17 13:09  
OK, thanx, but what about principles?
whroeder1
13644
whroeder1 2014.05.17 13:40  
ggekko: OK, thanx, but what about principles?
Premature Optimization
/
To add comments, please log in or register