Got "request canceled by timout" with order at market

 
Hi,

recently I experienced a curious error when sending an order at market. The calling code is:
Print(MagicNumber,": ID ",glCurrOp," POS: Attempting new sell operation at market");
                                
blockOnTickAll();
                                
if (!glTradeS.openNewPositionWithMarketOrder(ORDER_TYPE_SELL,
                  glVolInfo.getCurrSelVol(),
                  MaxDeviation,
                  "New market order"))
{
        Alert(MagicNumber,": Error sending new sell market order");
                                        
        returnToStart();
                                        
        unblockOnTickAll();
                                        
        return;
}

The function that sends the order is:

bool MTradeSimple::openNewPositionWithMarketOrder(const ENUM_ORDER_TYPE type, 
      const double volume,
      const ulong deviation,
      const string comment,
      const string symbol)
{
   //https://www.mql5.com/pt/forum/332500
   //https://www.mql5.com/pt/forum/216871

   ZeroMemory(tradeRequest);
   ZeroMemory(tradeResult);
   
   tradeRequest.action = TRADE_ACTION_DEAL; //Market order
   tradeRequest.magic = magicNumber;
   //tradeRequest.position = position;
   
   tradeRequest.type = type;
   tradeRequest.type_filling = ORDER_FILLING_FOK;
   tradeRequest.symbol = symbol == "" ? _Symbol : symbol;
   tradeRequest.volume = volume;
   
        if (type == ORDER_TYPE_BUY)
                tradeRequest.price = SymbolInfoDouble(tradeRequest.symbol,SYMBOL_ASK);
        else
                tradeRequest.price = SymbolInfoDouble(tradeRequest.symbol,SYMBOL_BID);
   
   tradeRequest.deviation = deviation;
   tradeRequest.comment = comment;
   
   const bool checkSendResult = checkOrderAndSend(tradeRequest,tradeResult,magicNumber);
   
   if (checkSendResult)
      Sleep(TRADE_SLEEP);
      
   return checkSendResult;
}

checkOrderAndSend:

bool checkOrderAndSend(MqlTradeRequest& tradeRequest, MqlTradeResult& tradeResult, const int magicNumber)
{
   MqlTradeCheckResult checkResult;
   
   if (!OrderCheck(tradeRequest,checkResult))
   {
      printOrderCheckErrorMsg(tradeRequest,checkResult,magicNumber);
      
      if (tradeRequest.action == TRADE_ACTION_MODIFY && checkResult.retcode == TRADE_RETCODE_NO_CHANGES)
      {
         Print(magicNumber,": Some programming error occurred: order modification with no difference. Ignoring problem");
         
         return true;
      }
      else
         return false;
   }
   
   if (!OrderSend(tradeRequest,tradeResult) || CheckReturnCode(tradeResult.retcode) != CHECK_RETCODE_OK)
   {
      printOrderSendErrorMsg(tradeRequest,tradeResult,magicNumber);
      
      return false;
   }
   
   return true;
}

The problem I experienced was that after 2 successfull market order send, in the 3rd case I got an EA freeze for about 3 minutes until error by timeout appeared:

Error

Funny fact: after returning the error, the MT5 terminal had the order actually processed! Or at least more or less:
Result

So, could someone help me find out why an innocent market order failed with a code with which two other previous orders were executed fine? And why an order returned with error of timeout was actually processed by MT5? (I confirmed in my broker's home broker and the sell operation was there) Any help appreciated.

 
Martin Bittencourt:
Hi,

recently I experienced a curious error when sending an order at market. The calling code is:

The function that sends the order is:

checkOrderAndSend:

The problem I experienced was that after 2 successfull market order send, in the 3rd case I got an EA freeze for about 3 minutes until error by timeout appeared:


Funny fact: after returning the error, the MT5 terminal had the order actually processed! Or at least more or less:

So, could someone help me find out why an innocent market order failed with a code with which two other previous orders were executed fine? And why an order returned with error of timeout was actually processed by MT5? (I confirmed in my broker's home broker and the sell operation was there) Any help appreciated.

No one have any idea about this? :(

 
Martin Bittencourt:

No one have any idea about this? :(

It's not a Terminal issue, it's a server side issue. Ask details to your broker, and don't let them push it to a third-party responsible.
 
did you find a solution for this martin? im having the same issue myself...

i get {{Request timeout}} error for orders, so the ea then tries to place the trade again, and then all of a sudden ill get loads of trades place at the same time!

yesterday i got the error 17 times. the ea 30 min later then placed 17 trades at the same time!

i have this issue on multiple brokers aswell, not just one.
Reason: