Download MetaTrader 5

order select should be checked

To add comments, please log in or register
Lukáš
18
Lukáš  

Hello, I didnt trade about 1 year and now my old EA doesnt work beucase warning "order select should be checked"

It's on the line with orderselect. How can I repair it? Any good ideas for "warnings with checking"? thank you :))



  bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
          
         }
      }
   }

qjol
3243
qjol  
Keith Watford
Moderator
9996
Keith Watford  

That is a warning and will not prevent your EA from "working"

It may not "work" as intended if there is an error with the OrderSelect for some reason, so check that the OrderSelect was successful and only execute the following code if it was. 

Lukáš
18
Lukáš  
thank you but not answer which I want :/ I only need function begining of code from anywhere. Is it anywhere some good tutorials for this? for create good EAs (not need strategies, I have my own) ?
qjol
3243
qjol  

i don't get it

at first you asked a question about

augino:

 

order select should be checked


and i brought you the solution

 


 next you are talking about 

augino:

 

[...] now my old EA doesnt work beucase warning "order select should be checked"

It's on the line with orderselect. How can I repair it? Any good ideas for "warnings with checking"? thank you :))


and GumRai  answered you

GumRai:

That is a warning and will not prevent your EA from "working"

It may not "work" as intended if there is an error with the OrderSelect for some reason, so check that the OrderSelect was successful and only execute the following code if it was. 


now you are telling us you don't understand programming at all

augino:
thank you but not answer which I want :/ I only need function begining of code from anywhere. Is it anywhere some good tutorials for this? for create good EAs (not need strategies, I have my own) ?

which incidentally doesn't add up with what you wrote above


augino:

 

Hello, I didnt trade about 1 year and now my old EA doesnt work beucase warning "order select should be checked"

Daniel Petrovai
440
Daniel Petrovai  
augino:

Hello, I didnt trade about 1 year and now my old EA doesnt work beucase warning "order select should be checked"

It's on the line with orderselect. How can I repair it? Any good ideas for "warnings with checking"? thank you :))



  bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
          
         }
      }
   }

It's no big deal to check it. Here is how I do it :

   for(cnt=OrdersTotal()-1;cnt>=0;cnt--)
     {
      if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))//if order select fails
        {
         newError=GetLastError();
         Print("Order select failed in FindLastOrderPlaced() with error : "+(string)newError+ErrorDescription(newError));//tell me the error
         break;
        }
      // else if order select didn't fail
      else
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
           {
            if(OrderType()==OP_BUY || OrderType()==OP_SELL)
              {
               if(OrderOpenTime()>lastOrderTime)
                 {

 Or you can just say

   for(cnt=OrdersTotal()-1;cnt>=0;cnt--)
     {
      if(!OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))//if order select fails
        {
         Print("Order select failed with error : "+(string)GetLastError());//tell me the error
         break;
        }
      // else if order select didn't fail
      else
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
         //..... your code here

 You get the idea.

Hope it helps 

whroeder1
15023
whroeder1  
Lukáš
18
Lukáš  
thank you a lot :) you are great people here :)
To add comments, please log in or register