Closed ViktorKnoben closed 4 years ago
Hi Victor,
This is a bug on their end because they are sending the wrong filling mode in the symbol info. You can, however, find the correct filing mode by right clicking the symbol in the terminal and looking up its specifications. In the case of USDJPY on XM
-- the filling mode is IOC
. Switch to that and a smaller position size to fit within your margin and it will work. Also a couple more tips:
quit()
and exit()
are for use in the python REPL only. If you need to exit a script you should use sys.exit()
import pprint
import pymt5adapter as mta
def main():
mysymbol = 'USDJPY'
symbol = mta.symbol_info(mysymbol)
tick = mta.symbol_info_tick(symbol.name)
request = {
"action" : mta.TRADE_ACTION_DEAL,
"symbol" : symbol.name,
"volume" : 0.01,
"type" : mta.ORDER_TYPE_BUY,
"price" : tick.ask,
"sl" : tick.ask - 100 * symbol.point,
"tp" : tick.ask + 100 * symbol.point,
"deviation" : 10,
"magic" : 234000,
"comment" : "python script",
"type_filling": mta.ORDER_FILLING_IOC,
}
res = mta.dictify(mta.order_send(request))
pprint.pp(res)
if __name__ == '__main__':
with mta.connected(raise_on_errors=True):
main()
Hi,
I've found a bug in both your adapter as well as the python api (native). But given the lack of reactions I'm desperately hoping you know the solution:
I get the error that my filling mode is unsupported despite using their own example from ttps://www.mql5.com/en/docs/integration/python_metatrader5/mt5ordersend_py.
The result is:
I find it very strange and makes me second guess the documentation or I've found a bug. Though to be honest I'm hoping I made a beginners mistake. This issue occurs for all combinations of type_filling,type_time,type and action. I know this as each represents an integer and by abusing loops I've tested all possible combinations, none worked.
Some additional information:
Algo trading is on No exceptions are listed The following is the result of mt5.account_info()
and the result of mt5.terminal_info()
And last but not least what an amazing initiative to improve their code. When I found out it worked without having to alter my own flow... Heaven!
I sincerely hope you can help me out,
Viktor