MQL5-Python : order_send failed, retcode=10004, comment=Requote

 

Hello,


I have been struggling for some time now with this problem. It happens randomly and I tried almost everything I know to get through it.

basically, my script predicts a certain direction (with python) and then trigger (Buy or Sell). However, I keep getting randomly "Requote" error!

I increased the Slippage to 60 and the problem still exists:


def Buy(Symbol):

    SL = SLFunc()
    TP = TPFunc()


    lot = lot_calculator()
    point = mt5.symbol_info(Symbol).point
    price = mt5.symbol_info_tick(Symbol).ask
    deviation = 60
    request = {
        "action": mt5.TRADE_ACTION_DEAL,
        "symbol": Symbol,
        "volume": float(lot),
        "type": mt5.ORDER_TYPE_BUY,
        "price": price,
        "sl": price - SL * point,
        "tp": price + TP * point,
        "deviation": deviation,
        "magic": 121211,
        "comment": "Python: Buy",
        "type_time": mt5.ORDER_TIME_GTC,
        "type_filling": mt5.ORDER_FILLING_RETURN,
    }

and I get this in terminal:

2020.11.24 13:00:01.039	Trades	'37307382': instant buy 4.05 EURUSD at 1.18741 sl: 1.18330 tp: 1.18950 (deviation: 60)

2020.11.24 13:00:29.537 Trades  '37307382': requote 1.18734 / 1.18736 (instant buy 4.05 EURUSD at 1.18741 sl: 1.18330 tp: 1.18950 (deviation: 60))

and I get this in my Python module:

>>print(mt5.last_error())
 (1, 'Success')

>>result.retcode
order_send failed, retcode=10004
   retcode=10004
   deal=0
   order=0
   volume=0.0
   price=0.0
   bid=1.18734
   ask=1.18736
   comment=Requote
   request_id=4179
   retcode_external=0
   request=TradeRequest(action=1, magic=666666, order=0, symbol='EURUSD', volume=4.05, price=1.18741, stoplimit=0.0, sl=1.1833, tp=1.1895, deviation=60, type=0, type_filling=2, type_time=0, expiration=0, comment='UniMod: Buy', position=0, position_by=0)


Any Idea how to solve this ?


Thanks,

 
Dr.GM:

Hello,


I have been struggling for some time now with this problem. It happens randomly and I tried almost everything I know to get through it.

basically, my script predicts a certain direction (with python) and then trigger (Buy or Sell). However, I keep getting randomly "Requote" error!

I increased the Slippage to 60 and the problem still exists:


and I get this in terminal:

and I get this in my Python module:


Any Idea how to solve this ?


Thanks,

The "Requote" error (retcode=10004) happens when the requested price is no longer available, meaning the market moved before your order was processed. Here’s how your friend can fix it:

 Use Market Execution Instead of Instant Execution

  • In instant execution, the order is only executed at the requested price, causing requotes if the price changes.

  • Market execution will fill at the best available price.

Solution:

  • Check mt5.symbol_info(Symbol).filling_mode to see if market execution is supported.

  • Change type_filling from mt5.ORDER_FILLING_RETURN to mt5.ORDER_FILLING_IOC or mt5.ORDER_FILLING_FOK (depending on the broker).

request["type_filling"] = mt5.ORDER_FILLING_IOC  # Immediate or Cancel


 Hope it solves your problem.