Timeout Error 10012 MT5

 

Hi guys

I receive quite often from broker the timeout error when I use my MT5 EA - it is on LIVE account

and it happens like this:

the order is sent to market , after 3 min I receive a Timeout Error, and then my EA tries again  - it could try 5 times

after 5 timeout tries it will stop trying, and suddenly after 30 min I can see all 5 orders filled in market. Before it tries to place again the order it checks is there is a new order on account - but no, there is none, they all somehow magically appear after 30-40 minutes.

Attached you have the image from live account how orders are being filled after 30 min, all at once and the code for sending orders.

If anyone can help me figure this out would appreciate a lot - is it from My EA or from broker?


Broker does not want to answer to my requests, it could happen on ICMarkets/Vantage and others as well

It could happen when I try to open trade and sometimes when I try to change SL/TP


//+------------------------------------------------------------------+
//|    SendOrder                   |
//+------------------------------------------------------------------+

int SendOrder(const string sSymbol, const ENUM_ORDER_TYPE eType, const double fLot, double &prices, const uint nSlippage = 1000, const double fSL = 0, const double fTP = 0, const string nComment = "", const ulong nMagic = 0, datetime expiration=0)
{
        int RetVal = 0;

   string position_symbol = sSymbol;

        MqlTradeRequest trade_request; ZeroMemory(trade_request);
        MqlTradeResult   trade_result; ZeroMemory(trade_result);
        
   if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)==SYMBOL_FILLING_FOK) trade_request.type_filling = ORDER_FILLING_FOK;
   else if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)==SYMBOL_FILLING_IOC) trade_request.type_filling = ORDER_FILLING_IOC;
   else if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)==0) trade_request.type_filling = ORDER_FILLING_RETURN;
   else if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)>2)
   {
      int FillingCheck_ = (int)FillingCheck(position_symbol);
      if(FillingCheck_ > 0) return(-FillingCheck_);
   }
        
        double fPoint = SymbolInfoDouble(sSymbol, SYMBOL_POINT);
        
        int nDigits     = (int) SymbolInfoInteger(sSymbol, SYMBOL_DIGITS);
        
   if(eType < 2) trade_request.action = TRADE_ACTION_DEAL;
   else trade_request.action =TRADE_ACTION_PENDING;
   
        trade_request.symbol            = sSymbol;
        trade_request.volume            = fLot;
        trade_request.stoplimit = 0;
        trade_request.deviation = nSlippage;
        trade_request.comment   = nComment;
        if (TradeComment!="") trade_request.comment = nComment+" "+TradeComment;
           
        trade_request.type              = eType;
        trade_request.sl = NormalizeDouble(fSL, nDigits);
   trade_request.tp = NormalizeDouble(fTP, nDigits);
        trade_request.magic     = nMagic;
        if (expiration > 0)
        {
           trade_request.type_time = ORDER_TIME_SPECIFIED;
           trade_request.expiration = expiration;
        }
        if(eType == ORDER_TYPE_BUY) trade_request.price = NormalizeDouble(SymbolInfoDouble(sSymbol, SYMBOL_ASK), nDigits);
        else if(eType == ORDER_TYPE_SELL) trade_request.price = NormalizeDouble(SymbolInfoDouble(sSymbol, SYMBOL_BID), nDigits);
        else trade_request.price                = NormalizeDouble(prices, nDigits);
        
        if (StopLoss>0)
        {
           if (eType == ORDER_TYPE_BUY) trade_request.sl = NormalizeDouble(trade_request.price-StopLoss*point, nDigits);
              else if(eType == ORDER_TYPE_SELL) trade_request.sl = NormalizeDouble(trade_request.price+StopLoss*point, nDigits);
        }
        
                        
        MqlTradeCheckResult oCheckResult; ZeroMemory(oCheckResult);
        
        bool bCheck = OrderCheck(trade_request, oCheckResult);
        
        if(bCheck == true && oCheckResult.retcode == 0)
        {
                bool bResult = false;
                
                
                {
                        bResult = OrderSend(trade_request, trade_result);

                        if(bResult == true && (trade_result.retcode == TRADE_RETCODE_DONE || trade_result.retcode == TRADE_RETCODE_PLACED))
                        {
                 RetVal = (int)trade_result.order;               
              if (eType < 2 && PositionSelectByTicket(RetVal)) prices = PositionGetDouble(POSITION_PRICE_OPEN);
            else if (eType >= 2 && OrderSelect(RetVal)) prices = OrderGetDouble(ORDER_PRICE_OPEN);
            
                                break;
                        } else Print("Error Sending Order "+IntegerToString(trade_result.retcode)); // !!! !!! error 10012 comes here
                                                
                        Sleep(1000);
                }
        }
        else 
        {
           RetVal = -(int)oCheckResult.retcode;
        Print("Error Checking for Order "+IntegerToString(oCheckResult.retcode));
        
        if(oCheckResult.retcode == TRADE_RETCODE_NO_MONEY)
        {               
                Print("Expert Removed due to not enough money!");
                ExpertRemove();
        }
        }
        
        return(RetVal);

}  


Is this broker issue?

Thank you

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Is this happening on XAUUSD only ?

The code is not much useful without the values used to call this function. What filling mode is used ? In general what are the value of the MqlTradeRequest structure ?

What is the code used with when modify a position ?

An error 10012 seems to be a broker issue but you need to check what request is sent to the server before confirming it.

Why not using the CTrade class from the Standard Library ? At least we would know if it comes from the code or from the broker.

 
Alain Verleyen #:

Is this happening on XAUUSD only ?

The code is not much useful without the values used to call this function. What filling mode is used ? In general what are the value of the MqlTradeRequest structure ?

What is the code used with when modify a position ?

An error 10012 seems to be a broker issue but you need to check what request is sent to the server before confirming it.

Why not using the CTrade class from the Standard Library ? At least we would know if it comes from the code or from the broker.

this EA trades mostly XAUUSD

this is the code to call the SendOrder

ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
int Ticket = SendOrder(Symbol(), ORDER_TYPE_BUY, dNextLot, ask, 100, 0, 0, "5", magic_number);
           


for filling mode we check in code before sending order


if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)==SYMBOL_FILLING_FOK) trade_request.type_filling = ORDER_FILLING_FOK;
   else if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)==SYMBOL_FILLING_IOC) trade_request.type_filling = ORDER_FILLING_IOC;
   else if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)==0) trade_request.type_filling = ORDER_FILLING_RETURN;
   else if((int) SymbolInfoInteger(position_symbol, SYMBOL_FILLING_MODE)>2)
   {
      int FillingCheck_ = (int)FillingCheck(position_symbol);
      if(FillingCheck_ > 0) return(-FillingCheck_);
   }


about Ctrade - yes - this could be a good idea to test it and see if there will be any changes


the issue is that sometimes it happens sometimes not - it's like sometimes when server is loaded on broker side it will give this timeout.


How can we explain this:

- we receive timeout error for like 5 tries of orders to be sent(each new try is done after 3 min - the timeout response comes after 3 minutes  check the time on image) and then suddenly after 20-30 minutes the orders appear in account? all at once (check the image with red highlight at bottom), till the moment when timeout orders come on account there are no new trades present when checked all positions from account.



Reason: