Download MetaTrader 5
To add comments, please log in or register
Publish your task in Freelance service and developers will execute your order.
Lukáš
18
Lukáš 2014.07.31 20:42 

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 2014.07.31 20:51  
Keith Watford
Moderator
7959
Keith Watford 2014.07.31 21:00  

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áš 2014.07.31 22:58  
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 2014.07.31 23:50  

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 2014.08.01 01:14  
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
13627
whroeder1 2014.08.01 12:04  
Lukáš
18
Lukáš 2014.08.01 20:29  
thank you a lot :) you are great people here :)
/
To add comments, please log in or register