Return Code = 0. What does that mean?

 

As long as the Return Code is not 10009, I can safely assume its an error but looking up on the list of return code here: https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes I couldn't find anything for 0.


Here's a sample of the order check result:


OrderCheckResult(retcode=0, balance=84.74, equity=84.74, profit=0.0, margin=1.13, margin_free=83.61, margin_level=7499.115044247787, comment='Done', request=TradeRequest(action=1, magic=20210927, order=0, symbol='USDCAD#', volume=0.01, price=1.27509, stoplimit=0.0, sl=0.0, tp=1.2742049881867534, deviation=20, type=1, type_filling=1, type_time=1, expiration=0, comment='Trading Bot v8', position=0, position_by=0))
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
Trade Server Return Codes - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
I have the same question.... Can we take 0 as a successful result?
 
Qoyyuum Kadir:
10009

Forum on trading, automated trading systems and testing trading strategies

Trade Failed Due to retcode: 10009, with comment: Request executed

Vladimir Karputov, 2022.05.05 08:20

In MQL5 I use trading classes. In particular, I normalize Stop Loss and Take Profit with CSymbolInfo::NormalizePrice, and for volume normalization I use the following function:

//+------------------------------------------------------------------+
//| Lot Check                                                        |
//+------------------------------------------------------------------+
double LotCheck(double lots,CSymbolInfo &symbol)
  {
//--- calculate maximum volume
   double volume=NormalizeDouble(lots,2);
   double stepvol=symbol.LotsStep();
   if(stepvol>0.0)
      volume=stepvol*MathFloor(volume/stepvol);
//---
   double minvol=symbol.LotsMin();
   if(volume<minvol)
      volume=0.0;
//---
   double maxvol=symbol.LotsMax();
   if(volume>maxvol)
      volume=maxvol;
//---
   return(volume);
  }