how to fix it ? return value of 'OrderSelect' should be checked

 
1 int BreakEven(int MN){
2 int Ticket=0;
4  
5  for(int i = OrdersTotal() - 1; i >= 0; i--) {
6    OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
8    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MN){
9      Ticket = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
10      if(Ticket < 0) Print("Error in Break Even : ", GetLastError());
11        break;
12      }
13    }
14
15  return (Ticket);

16 }


** Result compile : description = return value of 'OrderSelect' should be checked  Line 6

 
var select = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

Check the return value of orderselect look in the reference for the description;

 
Marco vd Heijden:

Check the return value of orderselect look in the reference for the description;

result 3 error(s) description & stilll warning return value of 'OrderSelect' should be checked, as bellow

'var' - undeclared identifier line 6

'select' - undeclared identifier line 6

'select' - some operator expected line 6

return value of 'OrderSelect' should be checked coba2.mq4 line 6


how to declare it ?

MQL5 forum
MQL5 forum
  • www.mql5.com
MQL5: Forum on automated trading systems and strategy testing
 
priyoleksono:

result 3 error(s) description & stilll warning return value of 'OrderSelect' should be checked, as bellow

'var' - undeclared identifier line 6

'select' - undeclared identifier line 6

'select' - some operator expected line 6

return value of 'OrderSelect' should be checked coba2.mq4 line 6


how to declare it ?

try this....

1 int BreakEven(int MN){
2 int Ticket=0;
3 
4  
5  for(int i = OrdersTotal() - 1; i >= 0; i--) {
6    if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))break;
7    if(OrderSymbol() != Symbol() && OrderMagicNumber() != MN){continue;}
8    if(OrderSymbol() == Symbol() && OrderMagicNumber() == MN){
9      Ticket = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
10      if(Ticket < 0) Print("Error in Break Even : ", GetLastError());
11        break;
12      }
13    }
14
15  return (Ticket);
16 }
 
Kenneth Parling:

try this....

ok thanks a lot its running without error/warning desc.....
 
priyoleksono:
ok thanks a lot its running without error/warning desc.....

you are welcome ;)

 
  1. Kenneth Parling #: try this....

    Try simplifying your code

    for(int i = OrdersTotal() - 1; i >= 0; i--)  if(
       OrderSelect(i, SELECT_BY_POS, MODE_TRADES)
    && OrderMagicNumber() == MN
    && OrderSymbol() == Symbol()
    ){
  2. Ticket = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
    if(Ticket < 0) Print("Error in Break Even : ", GetLastError());

    Perhaps you should read the manual, or press F1 in the editor. OrderModify does not return a ticket; it does not return an int. The if is wrong.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.