[Unsupported filling mode]

 
import MetaTrader5 as mt5
import time


account= 67602849
password = "fakepassword"
server = "mt5-demo01.pepperstone.com"
if not mt5.initialize(login=account, password=password, server=server):
    print("initialize() failed, error code =",mt5.last_error())
    quit()
authorized=mt5.login(account, password=password, server=server)

if authorized:
    print(mt5.account_info())
    print("Show account_info()._asdict():")
    account_info_dict = mt5.account_info()._asdict()
    for prop in account_info_dict:
        print("  {}={}".format(prop, account_info_dict[prop]))
else:
    print("failed to connect at account #{}, error code: {}".format(account, mt5.last_error()))

# prepare the buy request structure
symbol = "USDJPY"
symbol_info = mt5.symbol_info(symbol)
if symbol_info is None:
    print(symbol, "not found, can not call order_check()")
    mt5.shutdown()
    quit()

# if the symbol is unavailable in MarketWatch, add it
if not symbol_info.visible:
    print(symbol, "is not visible, trying to switch on")
    if not mt5.symbol_select(symbol, True):
        print("symbol_select({}}) failed, exit", symbol)
        mt5.shutdown()
        quit()

lot = 0.1
point = mt5.symbol_info(symbol).point
price = mt5.symbol_info_tick(symbol).ask
deviation = 20
request = {
    "action": mt5.TRADE_ACTION_DEAL,
    "symbol": symbol,
    "volume": lot,
    "type": mt5.ORDER_TYPE_BUY,
    "price": price,
    "sl": price - 100 * point,
    "tp": price + 100 * point,
    "deviation": deviation,
    "magic": 234000,
    "comment": "python script open",
    "type_time": mt5.ORDER_TIME_GTC,
    "type_filling": mt5.SYMBOL_FILLING_MODE,
}

# send a trading request
result = mt5.order_send(request)
# check the execution result
print("1. order_send(): by {} {} lots at {} with deviation={} points".format(symbol, lot, price, deviation));
if result.retcode != mt5.TRADE_RETCODE_DONE:
    print("2. order_send failed, retcode={}".format(result.retcode))
    # request the result as a dictionary and display it element by element
    result_dict = result._asdict()
    for field in result_dict.keys():
        print("   {}={}".format(field, result_dict[field]))
        # if this is a trading request structure, display it element by element as well
        if field == "request":
            traderequest_dict = result_dict[field]._asdict()
            for tradereq_filed in traderequest_dict:
                print("       traderequest: {}={}".format(tradereq_filed, traderequest_dict[tradereq_filed]))
    print("shutdown() and quit")
    mt5.shutdown()
    quit()

print("2. order_send done, ", result)
print("   opened position with POSITION_TICKET={}".format(result.order))
print("   sleep 2 seconds before closing position #{}".format(result.order))
time.sleep(2)

Hi guys, it is my code, i'm trying to open a long position using this code but i don't manage to, i'm desperated. I'm using a Pepperstone demo account with MT5 Api in Python but i get this error:

failed market buy 0.1 USDJPY sl: 115.001 tp: 115.201 [Unsupported filling mode]

Does anybody know how could i fix?? I'm desperated😭

 
Search the forum, someone else had a similar issue.
 
Er Faina:

Hi guys, it is my code, i'm trying to open a long position using this code but i don't manage to, i'm desperated. I'm using a Pepperstone demo account with MT5 Api in Python but i get this error:

failed market buy 0.1 USDJPY sl: 115.001 tp: 115.201 [Unsupported filling mode]

Does anybody know how could i fix?? I'm desperated😭

Have you tried to skip these lines:

    "type_time": mt5.ORDER_TIME_GTC,
    "type_filling": mt5.SYMBOL_FILLING_MODE,

They make no sense for a buy market order.

Just look at tzhe example here: https://www.mql5.com/de/docs/constants/tradingconstants/enum_trade_request_actions

Reason: