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

 
Alexey Volchanskiy:

I am also studying Python, but only as part of mastering neural networks, machine learning and other fancy stuff and packages. I do not think it is possible to work with this super-brainer, it is 200 times slower than MQL5, I cited the results of some simple tests.

I still haven't understood, is it possible to connect Python modules and call functions from MQL5? Or the only connection is Python->MQL5?

Does Volchansky switch to MO?

I'm interested

I see more and more good people going to the MO, the sabker is fiddling with pips, it's hard to make up your mind
 

A good tutorial on how to work with data and a bit of MO if there's something you didn't know but forgot. Including a tip on how to stop thinking that python is a brake.

https://jakevdp.github.io/PythonDataScienceHandbook/

 
Thechapu :
hola, mi trabajo todavía es con Python y MT4
https://youtu.be/rLV_NiasmpA
 
Alexey Volchanskiy:

There was a simple test without libraries, just calculating PI number in a primitive loop. Alas, I couldn't find my recent branch, here is an old one, without Python.

And I found my code in Python.

Numba package to the rescue (https://numba.pydata.org/) - works 10 times faster than NumPy, which is 2 times faster than Python. Good for functional programming and bottle necks.

Numba: A High Performance Python Compiler
  • numba.pydata.org
Numba translates Python functions to optimized machine code at runtime using the industry-standard LLVM compiler library. Numba-compiled numerical algorithms in Python can approach the speeds of C or FORTRAN. You don't need to replace the...
 
Renat Fatkhullin:

We are preparing MetaTrader 5 module for Python, similar to R.

As with the package for R, we are currently testing on simple functions to extract data from a running copy of the terminal.

How you can test the operation:

  1. Install Python 3.7.2 x64 from https://www.python.org/downloads/windows/ with the %PATH% path included

  2. Get the matplotlib package for graph support.
  3. Run installation of MetaTrader5 package
  4. You should have MetaTrader 5 build 2007 or later installed on your PC.

  5. Run the test script
  6. MetaTrader 5 will run in background, data will be extracted, displayed in console and a chart will be drawn



Test code:


Later we will add more features and place the package in the public Python package repository, so it can be installed out-of-the-box.

======================

In notepad, Jupyter spits out

---------------------------------------------------------------------------RuntimeError Traceback (most recent call last) <ipython-input-23-b7fba1d0ad5a> in <module>() 8 print( MT5Version()) 9 ---> 10 ticks1 = MT5CopyTicksFrom("EURAUD", datetime(2019,1,28,13),10000, MT5_COPY_TICKS_ALL) 11 ticks2 = MT5CopyTicksRange("AUDUSD", datetime(2019,1,27,13), datetime(2019,1,28,13,1), MT5_COPY_COPYICKS_ALL) 12 RuntimeError: IPC call failed

 
Maxim Dmitrievsky:

An example of a quick drawing of a correlation matrix:


Stumbles on :

ticks1= MT5CopyTicksFrom("EURAUD", datetime(2019,1,28,13),10000, MT5_COPY_TICKS_ALL)

...

RuntimeError: IPC call failed


Path to the terminal is through r (raw). The terminal itself is detected, of course.

 
Maxim Dmitrievsky:

An example of a quick drawing of a correlation matrix:


Does NOT work in general, and in Python 3.8 in particular!
 
capissimo:
NOT working in general, and in Python 3.8 in particular!

you're doing something wrong

 
Maxim Dmitrievsky:

you are doing something wrong

1. I originally had Python 3.7.2 installed. Installed your package and the command shell and Jupyter notepad gets the same error:RuntimeError: IPC call failed

2. I ripped Python 3.7.2, installed Python 3.8, but the same story - it doesn't install in Python 3.8

3. Installed Anaconda Python, specifically created a virtual environment for Python 3.7.2 and tried to pip your package and run an example - same view, but on the side:RuntimeError: IPC call failed