Download MetaTrader 5

"return value of 'OrderSend' should be checked"

To add comments, please log in or register
Do you have Mac OS? Find out how to install MetaTrader on it!
vanuatu
656
vanuatu 2014.05.13 11:33 

Helou,

I would like to ask for help, the compiler is screaming at me : "return value of 'OrderSend' should be checked"

      request.action=TRADE_ACTION_DEAL;
      request.type=ORDER_TYPE_SELL;
      request.symbol=_Symbol;
      request.volume=ShortTradeVolume + currentVolume;
      request.type_filling=ORDER_FILLING_FOK;
      request.price=SymbolInfoDouble(_Symbol,SYMBOL_BID); /// cenu musím určit podle close usečky ???
      request.sl=0;
      request.tp=0;
      
      
      OrderSend(request,result);

Could you pleas write a simple line to check it?? Should I check all the variables in result?? or is Print() function sufficient??

I have no idea how to check it.........

Rodrigo Malacarne
Moderator
9904
Rodrigo Malacarne 2014.05.13 15:36  
vanuatu:

Helou,

I would like to ask for help, the compiler is screaming at me : "return value of 'OrderSend' should be checked"

Could you pleas write a simple line to check it?? Should I check all the variables in result?? or is Print() function sufficient??

I have no idea how to check it.........

Please take a look at this post. I think it may help you.
Jose Miguel Soriano
4963
Jose Miguel Soriano 2014.05.15 17:56  
vanuatu:

Helou,

I would like to ask for help, the compiler is screaming at me : "return value of 'OrderSend' should be checked"

Could you pleas write a simple line to check it?? Should I check all the variables in result?? or is Print() function sufficient??

I have no idea how to check it.........

bool enviaOrden(MqlTradeRequest &solicitud, MqlTradeResult &resultado, MqlTradeCheckResult &comprueba, int desliza= 3, bool informa= true, bool modoAsincr= false)
{
   bool exito= false;
   string simb= solicitud.symbol;
   int nDig= digitosSimb(simb), reintento= 5;
   ResetLastError();
   exito= OrderCheck(solicitud, comprueba);
   if(exito)
   {
      exito= false;
      while(!exito && reintento>0)
      {
         if (!modoAsincr)  exito= OrderSend(solicitud, resultado);
         else              exito= OrderSendAsync(solicitud, resultado);
         reintento--;
         solicitud.deviation= solicitud.deviation+desliza;
         if(exito && resultado.retcode==TRADE_RETCODE_DONE_PARTIAL)
         {
            reintento= 5;
            exito= false;
            solicitud.volume= solicitud.volume-resultado.volume;
            solicitud.deviation= 3;
         }
      }
      Sleep(500);
      if(resultado.retcode!=TRADE_RETCODE_DONE)
         infoRetCode(resultado.retcode, __FUNCTION__+": "+resultado.comment, informa);
   }
   else
   {
      infoRetCode(comprueba.retcode, __FUNCTION__+": "+": "+comprueba.comment, informa);
      infoError(_LastError, __FUNCTION__, informa);
   }
   return(exito);
}
Rogerio Figurelli
Moderator
39669
Rogerio Figurelli 2014.05.16 05:30  
josemiguel1812:

Hi Jose, good code, however checking all else {  } states, if you are using OrderSendAsync(), don't you have to test TRADE_RETCODE_PLACED return too?

Anyway, this is a good case to explain what I mean as test all if { } else { } conditions in general or for any function, like OrderSend and/or OrderSendAsync for instance.

To add comments, please log in or register