return value of 'OrderSelect' should be checked - warning error compiling in 600+ version

 
Request to solve warning error in the code please provide a solution of the error !!
 {
        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 2)
        {
            continue;
        }
        ordticket[orders][0] = OrderOpenTime();
        ordticket[orders][1] = OrderTicket();
        orders++;
    }
  {
        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        if (OrderType() != OP_SELL || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
        {
            continue;
        }
        ordticket[orders][0] = OrderOpenTime();
        ordticket[orders][1] = OrderTicket();
        orders++;
    }
 {
        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 2)
        {
            continue;
        }
        ordticket[orders][0] = OrderOpenTime();
        ordticket[orders][1] = OrderTicket();
        orders++;
    }
 {
        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
        {
            continue;
        }
        ordticket[orders][0] = OrderOpenTime();
        ordticket[orders][1] = OrderTicket();
        orders++;
    }
 {
        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        if (OrderType() != OP_BUY || OrderSymbol() != Symbol() || OrderMagicNumber() != 1)
        {
            continue;
        }
        ordticket[orders][0] = OrderOpenTime();
        ordticket[orders][1] = OrderTicket();
        orders++;
    }
 {
                        OrderSelect(ticket2, SELECT_BY_TICKET);
                        bool ret4 = OrderModify(OrderTicket(), OrderOpenPrice(), stoploss, takeprofit, 0, White);
                        if (ret4 == false)
                        Print("OrderModify() error - ", ErrorDescription(GetLastError()));
                    }
 {
                        OrderSelect(ticket, SELECT_BY_TICKET);
                        bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), stoploss, takeprofit, 0, White);
                        if (ret == false)
                        Print("OrderModify() error - ", ErrorDescription(GetLastError()));
                    }
 {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
          
 {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Red);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
  {
                        OrderSelect(ticket2, SELECT_BY_TICKET);
                        bool ret4 = OrderModify(OrderTicket(), OrderOpenPrice(), stoploss, takeprofit, 0, White);
                        if (ret4 == false)
                        Print("OrderModify() error - ", ErrorDescription(GetLastError()));
                    }
 {
                        OrderSelect(ticket, SELECT_BY_TICKET);
                        bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), stoploss, takeprofit, 0, White);
                        if (ret == false)
                        Print("OrderModify() error - ", ErrorDescription(GetLastError()));
                    }
   {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
  {
            OrderSelect(ticket, SELECT_BY_TICKET);
            bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
            if (ret == false)
            Print("OrderModify() error - ", ErrorDescription(GetLastError()));
        }
 
expertarts:
Request to solve warning error in the code please provide a solution of the error !!


You don't check if OrderSelect is successful, or not.

Replace:

OrderSelect(ticket, SELECT_BY_TICKET); 

by: 

if ( OrderSelect(OrderPosition, SELECT_BY_TICKET)){continue;} 

or by:  

if ( ! OrderSelect(OrderPosition, SELECT_BY_TICKET)){return;}  
 

Hi debar

I use software which use block diagrams to make EA !! It works fine with MT4 previous build but now I want to compile an EA for MT4 build 600+ n it doesn't recognise those errors so i have to edit in code,as I am not a programmer so even if its a minor error I am unable to solve,that must be fine.

Now please help with another error evolved after replacing with as you guided the error says

"empty controlled statement found"

{
if(OrderSelect(ticket, SELECT_BY_TICKET));
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}

 


{
if(OrderSelect(ticket, SELECT_BY_TICKET));
bool ret = OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0, Blue);
if (ret == false)
Print("OrderModify() error - ", ErrorDescription(GetLastError()));
}

 

expertarts:

 ow please help with another error evolved after replacing with as you guided the error says

"empty controlled statement found"


There is no code between the if( ) and the ;

That is the empty statement, remove the ; and you should be ok. 

 

if(OrderSelect(ticket, SELECT_BY_TICKET));
 
GumRai:

There is no code between the if( ) and the ;

That is the empty statement, remove the ; and you should be ok. 

 

 

Hi,Gumrai
Thank you very much !! error is resolved now;

Suggest any guide for updating code(ea) from MT4 previous builds to MT4 600+

 

Thanks once again!!!!!!!!!!!!!Cheers!!! 

 

hi every one.i got this error on this code,and it is not going away.when running the expert it orders continiously and only buy.please help me.


extern double      Lots=0.01;

int totals[];

void OnTick()

  {

      if (totals[OP_BUY]==0) 

      {OrderSend (_Symbol,OP_BUY,Lots,Ask,3,NULL,0,0,Green);

                         

      if (totals[OP_SELL]==0)

      {OrderSend (_Symbol,OP_SELL,Lots,Ask,3,NULL,0,0,Red);   

     

      }

      }

      }

 
Ali Pahlawan: i got this error on this code
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. So do it. Check your return codes for errors, and report them including GLE/LE, your variable values, and the market. That way we would know that at least you are calling your code.

    Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  3. You buy at the Ask and sell at the Bid.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

 
bool  OrderSelect( 
   int     index,            
   int     select,           
   int     pool=MODE_TRADES   
   );

bool OrdSelCh; //variable for write true or false

OrdSelCh=OrderSelect(index,select,MODE...)
 
int  OrderSend( 
   string   symbol,              // symbol 
   int      cmd,                 // operation 
   double   volume,              // volume 
   double   price,               // price 
   int      slippage,            // slippage 
   double   stoploss,            // stop loss 
   double   takeprofit,          // take profit 
   string   comment=NULL,        // comment 
   int      magic=0,             // magic number 
   datetime expiration=0,        // pending order expiration 
   color    arrow_color=clrNONE  // color 
   );

How does your order in any way relate to the documentation? Where is the SL and TP?

OrderSend (_Symbol,OP_BUY,Lots,Ask,3,NULL,0,0,Green);
Reason: