retcode=10021 comment='No prices' - page 2

 
>>> lot = 0.01
>>> point = mt5.symbol_info(symbol).point
>>> price = mt5.symbol_info_tick(symbol).ask
>>> point
1e-05
>>> price
1.13445
>>> deviation = 20
>>> request = {
...     "action": mt5.TRADE_ACTION_DEAL,
...     "symbol": symbol,
...     "volume": lot,
...     "type": mt5.ORDER_TYPE_BUY,
...     "price": price,
...     "sl": price - 50000 * point,
...     "tp": price + 50000 * point,
...     "deviation": deviation,
...     "magic": 234000,
...     "comment": "python script open",
...     "type_time": mt5.ORDER_TIME_GTC,
... }
>>> request
{'action': 1, 'symbol': 'EURUSD', 'volume': 0.01, 'type': 0, 'price': 1.13445, 'sl': 0.63445, 'tp': 1.63445, 'deviation': 20, 'magic': 234000, 'comment': 'python script open', 'type_time': 0}
>>> # send a trading request
>>> result = mt5.order_send(request)
>>> result
OrderSendResult(retcode=10030, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Unsupported filling mode', request_id=0, retcode_external=0, request=TradeRequest(action=1, magic=234000, order=0, symbol='EURUSD', volume=0.01, price=1.13445, stoplimit=0.0, sl=0.63445, tp=1.63445, deviation=20, type=0, type_filling=0, type_time=0, expiration=0, comment='python script open', position=0, position_by=0))
>>>
 

This error:

10030

TRADE_RETCODE_INVALID_FILL

Invalid order filling type

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Rob_Gent #:

This error:

10030

TRADE_RETCODE_INVALID_FILL

Invalid order filling type

so check you are using the correct filling mode for that broker.

 
Thanks, the correct is"type_filling": mt5.ORDER_FILLING_IOC
 
    # Determine the appropriate order type
    if order_type == mt5.ORDER_TYPE_BUY:
        price = mt5.symbol_info_tick(symbol).ask  # Use ask price for buy order
    elif order_type == mt5.ORDER_TYPE_SELL:
        price = mt5.symbol_info_tick(symbol).bid  # Use bid price for sell order
    else:
        print("Invalid order type specified.")
        return