MetaTrader 5 Python User Group - how to use Python in Metatrader - page 89

 
@yuddy7 #: Hello, how can I connect and open trade positions with the Deriv broker API using python ? I have read their documentation and it's not beginner friendly. 

Ask them! It has nothing to do with this website.

 
Mircea Vlad Albu #:
hello,

as far as I know  python order_send() method is using MT5 equivalent of OrderSend()

I am building an async adapter for the mt5 library and I would like my python order_send to use the  MT5 - OrderSendAsync()  instead of OrderSend ()

Is this possible with the current functionality available ?
Hi, you found an answer to this or a solution? Thanks
 
bao tang #:

stackoverflow: https://stackoverflow.com/questions/72081988/how-do-i-get-the-result-of-a-trade-in-mt5-with-python-using-the-ticket-number

I have the same issue here, even though the function "history_deals_get" accepts the argument "ticket=", it keeps return error (-2, 'Terminal: Invalid params'). I guess this function is buggy with argument "ticket", so the developer team denies it.

Hope developer team can see the discussion. Still no workaround after 1 year.

Thx


Dear developers,

There is a bug with function history_deals_get(ticket=order_ticket). Providing order ticket would not work, but providing deal ticket would work. This behaviour is different from the documentation, and in practice getting historical deals by providing order ticket would be more practical.

Can you please fix it?

Thank you,

Documentation on MQL5: Python Integration / history_deals_get
Documentation on MQL5: Python Integration / history_deals_get
  • www.mql5.com
Get deals from trading history within the specified interval with the ability to filter by ticket or position. Call specifying a time interval...
 

Hi everyone,

Im trying to pull H1 candle info into the db, 

same code is working for H4 and D1,, so that basically means, db is up and fine, login/creds working , all the basic. 

when I try to pull any candle info H1 and below I get the error below, 

INFO:root:Inserted 7137 candles into d1_candles table

INFO:root:Attempting to fetch h1 data for @YM from 1993-01-01 00:00:00+00:00 to 2024-10-21 19:46:47.781389+00:00

ERROR:root:Failed to retrieve H1_CANDLES data for @YM. Error: (-2, 'Terminal: Invalid params')

ERROR:root:Retries left: 2

INFO:root:Attempting to fetch h1 data for @YM from 1993-01-01 00:00:00+00:00 to 2024-10-21 19:46:47.781389+00:00

ERROR:root:Failed to retrieve H1_CANDLES data for @YM. Error: (-2, 'Terminal: Invalid params')

ERROR:root:Retries left: 1

INFO:root:Attempting to fetch h1 data for @YM from 1993-01-01 00:00:00+00:00 to 2024-10-21 19:46:47.781389+00:00

ERROR:root:Failed to retrieve H1_CANDLES data for @YM. Error: (-2, 'Terminal: Invalid params')


has anyone ran into this? " (-2, 'Terminal: Invalid params')"

thanks

 
Hello everyone. I have two installations of python the 3.12 and 3.13. I think both are not accepted by MT5.

I think I will have to download 3.11?

I tried with jupyter the 3.12 version; I installed metatrader5 with pip, but the problems I had with numpy, because mt5 wants a version of numpy < 2; in the end I installed but inside a venv and, I must say, I'm not sure I solved 100%.

Now I'm seeing videos for using python directly on the mt5 IDE.

THADA!!! A mess.

In the IDE compiler I added the path for python 3.12 but first I had to integrate pip install metatrader5 into the python 3.12 path, but it doesn't want to install a version of numpy < 2 at all.

So I come to the question. 

Which python should I install? If 3.12 is okay where do I find numpy < 2 or other libraries needed for mt5?

I was also thinking of downloading a numpy-1.24.3+cp312-cp312-win_amd64.whl (which I don't think exists) to solve; before I do that could someone kindly tell me how he solved it?

Thank you very much



 

Hello

Can some help me how to get SYMBOL_TRADE_CALC_MODE, SYMBOL_SECTOR, SYMBOL_INDUSTRY values in python?

Documentation says all such data is available in symbol_info, but it is not true.

 

Hi Sergey

I have python installed in Conda environment. How can I use / install it for MT5.

Python 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:20:11) [MSC v.1938 64 bit (AMD64)]

Type "copyright", "credits" or "license" for more information.

C:\Users\anilh\anaconda3\envs\envMQL\python.exe

Using this path in MT5 editor did not helped.

2025.10.06 16:39:54.108 Python script TestPython (XAUUSD,H1) removed

2025.10.06 16:39:54.109 Python script TestPython (XAUUSD,H1) started successfully

2025.10.06 16:39:54.110 Python 'TestPython': python process thread create error [The system cannot find the file specified. (2)]

Can you help to figure out what is wrong?

Thanks in advance.

Anil

 
Anil Varma #:

Hi Sergey

I have python installed in Conda environment. How can I use / install it for MT5.

I do not know sorry.
There are many traders/coders who are very comfortable with python (and they are using it incl the articles for example).
I hope - someone will reply on that.

-------------------

You can also check this thread with a lot of information:

MetaTrader 5 Python User Group - the summary - Metatrader 5 and python integration: Practical application of neural networks in trading
MetaTrader 5 Python User Group - the summary - Metatrader 5 and python integration: Practical application of neural networks in trading
  • 2019.03.14
  • www.mql5.com
Metatrader 5 and python integration: receiving and sending data  - the article   practical application of neural networks in trading. New metatrader 5 platform build 2085: integration with python and strategy tester improvements
 
Sergey Golubev #:

I do not know sorry.
There are many traders/coders who are very comfortable with python (and they are using it incl the articles for example).
I hope - someone will reply on that.

-------------------

You can also check this thread with a lot of information:

Thanks a lot Serger

Let me hope, I will be rescued by someone in the group :)