Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

ResultRetcodeDescription - MetaTrader 5 Library - MT4/MT5 Resources

author EAcpu | 2 reads | 0 comments |

This simple function returns the decrypted code string of the result of the trading operation . The MqlTradeCheck result is executed after the OrderCheck() function:

 MqlTradeCheck result view; //---- Check the correctness of the transaction request if (! Order check (request, check))
    {
print ( __Function__ , "(): Order Check():" , ResultRetcodeDescription(check.retcode));
return ( false );
   }

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

 MqlTradeCheck result viewing;

  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" , symbol (), "Open!" );
else print ( "Failed to establish a buy position for "" , symbol (), "!!!" );

The function uses the library ResultRetcodeDescription.mqh (to be copied to Terminal_data_directory\MQL5\Include), its content should be included in the developed code using the #include directive before using the function at the global level:


Attachment download

📎 resultretcodedescription.mqh (3.34 KB)

Source: MQL5 #960

Verification code Refresh