Hello,
I'm using python. On my code i want to do sell order like this :
request variable contain:But i go "Invalid request" with retcode : 10013
In MT5 :
I can't find what is wrong with my request ... Any idea ? i probably miss a parameter, but i don't see it in example i used.
I don't use Python for MetaTrader, but looking at the documentation, your usage does not look like the examples:
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.ORDER_FILLING_RETURN,
} https://www.mql5.com/en/docs/integration/python_metatrader5/mt5ordersend_py
- www.mql5.com
I don't use Python for MetaTrader, but looking at the documentation, your usage does not look like the examples:
https://www.mql5.com/en/docs/integration/python_metatrader5/mt5ordersend_py
Hello,
thank for the reply.
Wich parameter is missing. From my print i got all of them with good data. If you talk about SL & TP that don't have 100 * points it's because i calculate them before, but they are valid because if i try manually it's working on MT5.
Hello,
thank for the reply.
Wich parameter is missing. From my print i got all of them with good data. If you talk about SL & TP that don't have 100 * points it's because i calculate them before, but they are valid because if i try manually it's working on MT5.
The action, type, type_filling look different - you have used numbers rather than what is shown in the examples.
Maybe it should work (I know not as I use MQL5 rather than Python), but why would you deviate from the official examples provided?
I suggest using the example code to get a working example
The action, type, type_filling look different - you have used numbers rather than what is shown in the examples.
Maybe it should work (I know not as I use MQL5 rather than Python), but why would you deviate from the official examples provided?
I suggest using the example code to get a working example
They are constant variable used in the MT5 library of python. In my code i have write "mt5.TRADE_ACTION_DEAL", but in the request in process it into a number.
They are constant variable used in the MT5 library of python. In my code i have write "mt5.TRADE_ACTION_DEAL", but in the request in process it into a number.
Yes I saw that these are constants - I have seen many situations when the software is patched/upgraded and no longer compatible if the vendor's best practices/guidelines have not been followed exactly. If they happen to change the constants numbering in a future release, there could be problems so why take the risk?
But I am glad you found the solution- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use

Hello,
I'm using python. On my code i want to do sell order like this :
request variable contain:{'action': 1, 'symbol': 'GBPCAD', 'volume': 0.01, 'type': 1, 'price': 1.5594, 'sl': 1.57441, 'tp': 1.53441, 'deviation': 20, 'magic': 234000, 'comment': 'python script', 'type_time': 0, 'type_filling': 2}But i go "Invalid request" with retcode : 10013
In MT5 :
I can't find what is wrong with my request ... Any idea ? i probably miss a parameter, but i don't see it in example i used.