pythonmql5metatrader5

'Unsupported Filling Mode' error while sending order from Python API to Meta Trader 5


I am developing a Python program. When I try to send an order from Python to Meta Trader 5 (Alpari broker), I get an error:

Unsupported Filling Mode

I tried the following code:

# Import the libraries
import MetaTrader5 as mt5
from datetime import datetime
 
# Create the bound between MT5 and Python
mt5.initialize()
 
# Place buy order

# Initialization value
symbol = "EURUSD"
lot = 0.01
 
# Choose the deviation
deviation = 10

# Find the filling mode of symbol
filling_type = mt5.symbol_info(symbol).filling_mode
 
# Create dictionary request
request = {
     "action": mt5.TRADE_ACTION_DEAL,
     "symbol": symbol,
     "volume": lot,
     "type": mt5.ORDER_TYPE_SELL,
     "price": mt5.symbol_info_tick(symbol).bid,
     "deviation": deviation,
     "type_filling": filling_type,
     "type_time": mt5.ORDER_TIME_GTC
}
 
mt5.order_check(request)

The result was as below:

 OrderCheckResult(retcode=10030, balance=0.0, equity=0.0, profit=0.0,
 margin=0.0, margin_free=0.0, margin_level=0.0, comment='Unsupported
 filling mode', request=TradeRequest(action=1, magic=0, order=0,
 symbol='EURUSD', volume=0.01, price=1.0793, stoplimit=0.0, sl=0.0,
 tp=0.0, deviation=10, type=1, type_filling=1, type_time=0,
 expiration=0, comment='', position=0, position_by=0))

Can anyone help me to make this problem fixed? How I can translate the SYMBOL_FILLING_MODE to the ENUM_ORDER_TYPE_FILLING value?

Thanks in advance!


Solution

  • I've experienced the same issue just now, and I realized I haven't allow the Algo Trading option in MT5 terminal

    You need to configure the MT5 terminal to allow automated trading. Here are the steps:

    Hope it helps :)