Warning of OrderSelect(), OrderSend()

 

Hello!

First, I'm new to MT5. I encountered OrderSelect and OrderSend on my sample code I try to study.

I have no idea how to fix it

it show "return value of 'OrderSend' should be checked"

   "return value of 'OrderSelect' should be checked"

Thankyou 

 


 

 OrderSelect

//OrderSelect warning

OrderSelect(pTicket);
        
        string errDesc = TradeServerReturnCodeDescription(result.retcode);
        Print("Modify pending order #",pTicket,": ",result.retcode," - ",errDesc,", Price: ",OrderGetDouble(ORDER_PRICE_OPEN),", SL: ",request.sl,", TP: ",request.tp,", Expiration: ",request.expiration);
        
        if(checkCode == CHECK_RETCODE_OK)
        {
                Comment("Pending order ",pTicket," modified,"," Price: ",OrderGetDouble(ORDER_PRICE_OPEN),", SL: ",request.sl,", TP: ",request.tp);
                return(true);
        }
        else return(false);
}

 OrderSend

//OrderSend warning

else if(posType == POSITION_TYPE_SELL)

                        {

                                ask = SymbolInfoDouble(pSymbol,SYMBOL_ASK);

                                breakEvenStop = openPrice - (pLockProfit * SymbolInfoDouble(pSymbol,SYMBOL_POINT));

                                currentProfit = openPrice - ask;

                                if((currentSL > breakEvenStop || currentSL == 0) && currentProfit >= pBreakEven * SymbolInfoDouble(pSymbol,SYMBOL_POINT))

                                {

                                        request.sl = breakEvenStop;

                                        OrderSend(request,result);

                                }

                                else return(false);

                        }
//OrderSend warning

do

        {

                if(pType == ORDER_TYPE_BUY) request.price = SymbolInfoDouble(pSymbol,SYMBOL_ASK);

                else if(pType == ORDER_TYPE_SELL) request.price = SymbolInfoDouble(pSymbol,SYMBOL_BID);

                

                OrderSend(request,result);

                

                checkCode = CheckReturnCode(result.retcode);

                

                if(checkCode == CHECK_RETCODE_OK) break;

                else if(checkCode == CHECK_RETCODE_ERROR)

                {

                        string errDesc = TradeServerReturnCodeDescription(result.retcode);

                        Alert("Open market order: Error ",result.retcode," - ",errDesc);

                        break;

                }

                else

                {

                        Print("Server error detected, retrying...");

                        Sleep(RETRY_DELAY);

                        retryCount++;

                }

        }

 

 

 
What are Function return values ? How do I use them ?
What are Function return values ? How do I use them ?
  • www.mql5.com
I see many, many people posting code and asking questions which can usually be answered by simply checking the return values from a few Functions a...
 

Thankyou, I really appreciate your reply. 

I understand that it's about the return value, which for MT5 should be "bool"

Still I don't know what is the proper solution for this code

for the OrderSend()

do

        {

                if(pType == ORDER_TYPE_BUY) request.price = SymbolInfoDouble(pSymbol,SYMBOL_ASK);

                else if(pType == ORDER_TYPE_SELL) request.price = SymbolInfoDouble(pSymbol,SYMBOL_BID);

                

                bool tic = OrderSend(request,result);

                

                checkCode = CheckReturnCode(result.retcode);

                

                if(checkCode == CHECK_RETCODE_OK) break;

                else if(checkCode == CHECK_RETCODE_ERROR)

                {

                        string errDesc = TradeServerReturnCodeDescription(result.retcode);

                        Alert("Open market order: Error ",result.retcode," - ",errDesc);

                        break;

                }

                else

                {

                        Print("Server error detected, retrying...");

                        Sleep(RETRY_DELAY);

                        retryCount++;

                }

        }

will this solve the warning properly?



 

Reason: