Download MetaTrader 5

Which is the faster?

To add comments, please log in or register
Gordon Gekko
622
Gordon Gekko  

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
10475
Bambang Sugianto  

you can try your self

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


 int miliseconds=GetTickCount()-begin;
 Alert(miliseconds);
Gordon Gekko
622
Gordon Gekko  
OK, thanx, but what about principles?
whroeder1
15581
whroeder1  
ggekko: OK, thanx, but what about principles?
Premature Optimization
To add comments, please log in or register