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

 
I'll look into it. Thank you
 
Rashid Umarov:

There doesn't seem to be a folder

"c:\\users\\\user\\appdata\\\local\r-miniconda\\\envs\\r-reticulate\\\lib\site-packages\\numpy-1.19.5.dist-info\\METADATA'

Yes, there is no such file //METADATA.

 
Vladimir Perervenko:

Yes, there is no such file //METADATA.

Fixed it. Updated. Everything works.

 

what is the variable of current chart symbol (instrument) for use in python scripts in Mt5 ?

 
Igor_Gagarin #:

How do I send data from mt5 to a running python script and receive a response?

I guess I have to use stdin and stdout, and specify the process to pass it to.

Does anyone have any code where this is implemented?

p.s. This: https://www.mql5.com/ru/docs/integration/python_metatrader5 has read, and used, but it's not suitable for this task. The data needs to be transferred from the strategy tester as well.

I did it through pkl
 

Somebody give me a hint! Haven't been online for about three months, came in and updated the terminal. Immediately after the update the same error:

failed to connect at account #25115284, error code: (-2, 'Terminal: Invalid params')

Not even the code from the example works on the just created demo account ... Updated package to version 5.0.35, updated numpy to 1.21.2 .... And python itself to 3.10.0. Got a new error:

    import MetaTrader5 as mt5
ModuleNotFoundError: No module named 'MetaTrader5'

Cue the bundle where this works and actually how would I change the python version to the new one in the same console now? pip tied to the old ... I.e. the old one is kinda unnecessary and instead of updating I got the new python in a different folder ... Not sure if the new one will work at all though as I haven't been able to install the module on it yet as I am building all the modules on 3.10.0 separately and getting an error:

ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)
ERROR: No matching distribution found for MetaTrader5


 
sergey087 #:

Somebody give me a hint! Haven't been online for about three months, came in and updated the terminal. Immediately after the update the same error:

Not even the code from the example works on the just created demo account ... Updated package to version 5.0.35, updated numpy to 1.21.2 .... And python itself to 3.10.0. Got a new error:

Cue the bundle where this works and actually how would I now change the python version to the new one in the same console? pip tied to the old ... I.e. the old one is kinda unnecessary and instead of updating I got the new python in a different folder ... Not sure if the new one will work at all though as I haven't been able to install the module on it yet as I'm building all the modules on 3.10.0 separately and getting an error:



According to MetaTrader5 documentation :

Example of connecting Python to MetaTrader 5

  1. Download the latest version of Python 3.8 fromhttps://www.python.org/downloads/windows

Not many people are friendly with the tenth one yet.

 

An error popped up this morning that I couldn't pinpoint for half a day:

(r-reticulate) C:\Users\User>python
Python 3.7.11 (default, Jul 27 2021, 09:42:29) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\User\AppData\Local\R-MINI~1\envs\r-reticulate\lib\site-packages\pandas\__init__.py", line 144, in <module>
    from pandas.io.api import (
  File "C:\Users\User\AppData\Local\R-MINI~1\envs\r-reticulate\lib\site-packages\pandas\io\api.py", line 8, in <module>
    from pandas.io.excel import ExcelFile, ExcelWriter, read_excel
  File "C:\Users\User\AppData\Local\R-MINI~1\envs\r-reticulate\lib\site-packages\pandas\io\excel\__init__.py", line 1, in <module>
    from pandas.io.excel._base import ExcelFile, ExcelWriter, read_excel
  File "C:\Users\User\AppData\Local\R-MINI~1\envs\r-reticulate\lib\site-packages\pandas\io\excel\_base.py", line 33, in <module>
    from pandas.io.parsers import TextParser
  File "C:\Users\User\AppData\Local\R-MINI~1\envs\r-reticulate\lib\site-packages\pandas\io\parsers\__init__.py", line 1, in <module>
    from pandas.io.parsers.readers import (
  File "C:\Users\User\AppData\Local\R-MINI~1\envs\r-reticulate\lib\site-packages\pandas\io\parsers\readers.py", line 17, in <module>
    from pandas._typing import (
ImportError: cannot import name 'DtypeArg' from 'pandas._typing' (C:\Users\User\AppData\Local\R-MINI~1\envs\r-reticulate\lib\site-packages\pandas\_typing.py)
>>>

What does Exel have to do with it? Tried 3.8, 3.9 - nothing. Rolled back on the old version of panda - all works.

It's not a zoo, it's a versioned Python jungle.

 
Vladimir Perervenko #:

According to MetaTrader5 documentation :

Example of connecting Python to MetaTrader 5

  1. Download the latest version of Python 3.8 fromhttps://www.python.org/downloads/windows

Few people are friendly with the tenth one yet, it seems.

All as on version 3.9 ... The problem was after terminal update, new graphic and other things, i.e. before it was working fine with no problems and parameters became incorrect, but I can't say what went wrong when I passed two parameters separated by comma and what it wanted from me - may be it's a special format, separated string or I should feed this login and password to it =(

(500, 3081, '15 Oct 2021')
Failed to connect at account #64847969! Error code: (-2, 'Terminal: Invalid params')
I copied the login password to this demo directly from my code - logged in through the terminal without any problems, no errors. But in Python - flatly refuses to consider them correct =(
 

Shit, I think I need to manually specify the server when connecting now too, something must have changed and the default server isn't my only server at all... This is how it works:

authorized = mt5.login(account, server = "XMGlobal-MT5 2", password = "646564")
Reason: