ResultRetcodeDescription – library MetaTrader 5

Real Author:

MetaQuotes

This simple function returns a string of decrypted code of the trade operation result from MqlTradeCheckResult after executing the OrderCheck() function:

   MqlTradeCheckResult check;

//---- Checking for correctness of trade request
   if(!OrderCheck(request,check))
     {
      Print(__FUNCTION__,"(): OrderCheck(): ",ResultRetcodeDescription(check.retcode));
      return(false);
     }

Alternatively, it can return a string from MqlTradeResult after executing the OrderSend() function: 

  MqlTradeCheckResult check;

  word=__FUNCTION__+"(): OrderSend(): ";

//---- Open a BUY position and check the trade request result
   if(!OrderSend(request,result) || result.retcode!=TRADE_RETCODE_DONE) Print(ResultRetcodeDescription(result.retcode));
   else if(result.retcode==TRADE_RETCODE_DONE) Print("Buy position for ",Symbol()," is open!");
   else Print("Failed to open a Buy position for ",Symbol(),"!!!");

 The function uses the library ResultRetcodeDescription.mqh (to be copied into the terminal_data_directory\MQL5\Include) the contents of which should be included in the developed code using the #include directive prior to using the function at the global level:

Alternative:  Hidden TP and SL - EA MetaTrader 4

 

#include <ResultRetcodeDescription.mqh>


📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks