MetaTrader 5 Python User Group - the summary

 

The Main Study

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

The Article

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

Metatrader 5 Help

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

The CodeBase

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

The Forum

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

The Blogs

Something to Read - Python for Finance: Analyze Big Financial Data - the blog post (the book)

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

more to follow ..

Python Releases for Windows
Python Releases for Windows
  • www.python.org
The official home of the Python Programming Language
 

Forum on trading, automated trading systems and testing trading strategies

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

Renat Fatkhullin , 2019.03.13 22:40

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

Like the package for R , we are still testing on simple functions of extracting data from a working copy of the terminal.

How can I test the work:

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

  2. Deliver matplotlib to support graphs.
    pip install matplotlib
  3. Run the installation of the Python package
    pip install MetaTrader5
  4. The computer must have MetaTrader 5 build 2007 or higher.

  5. Run the test script
    python metatrader5-test.py
  6. The MetaTrader 5 terminal will start in the background, the data will be extracted, shown in the console and drawn a graph



Test code:

 from datetime import datetime
from MetaTrader5 import *

MT5Initialize()
MT5WaitForTerminal()

print(MT5TerminalInfo())
print(MT5Version())

ticks1 = MT5CopyTicksFrom( "EURAUD" , datetime( 2019 , 1 , 28 , 13 ), 10000 , MT5_COPY_TICKS_ALL)
ticks2 = MT5CopyTicksRange( "AUDUSD" , datetime( 2019 , 1 , 27 , 13 ), datetime( 2019 , 1 , 28 , 13 , 1 ), MT5_COPY_TICKS_ALL)

rates1 = MT5CopyRatesFrom( "EURUSD" , MT5_TIMEFRAME_M1, datetime( 2019 , 1 , 28 , 13 ), 1000 )
rates2 = MT5CopyRatesFromPos( "EURRUB" , MT5_TIMEFRAME_M1, 0 , 1000 )
rates3 = MT5CopyRatesRange( "EURPLN" , MT5_TIMEFRAME_M1, datetime( 2019 , 1 , 27 , 13 ), datetime( 2019 , 1 , 28 , 13 ))

MT5Shutdown()

#DATA
print( 'ticks1(' , len(ticks1), ')' )
for val in ticks1[: 10 ]: print(val)
print( 'ticks2(' , len(ticks2), ')' )
for val in ticks2[: 10 ]: print(val)
print( 'rates1(' , len(rates1), ')' )
for val in rates1[: 10 ]: print(val)
print( 'rates2(' , len(rates2), ')' )
for val in rates2[: 10 ]: print(val)
print( 'rates3(' , len(rates3), ')' )
for val in rates3[: 10 ]: print(val)

#PLOTTING
x_time = [x.time for x in rates2]
y_open = [y.open for y in rates2]
y_close = [y.close for y in rates2]

import matplotlib.pyplot as plt

plt.plot(x_time, y_open, 'g-' )
plt.plot(x_time, y_close, 'r-' )

plt.show()


Later we will add more features and place the package in the public repository of the Python packages so that you can install properly.


Files:
 
MetaTrader R package - the summary
 

Forum on trading, automated trading systems and testing trading strategies

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

Renat Fatkhullin , 2019.03.14 14:54

This is one way integration.

That is, from Python / R you can request data from the MetaTrader 5 terminal. The terminal itself does not know anything about external users and does not transmit anything to them. From the tester all the more.

Integration packages are designed to enable analysts to use market data in their environment.


 
This package is not available on PYPI. The link to the PYPI repo in the OP is not the package that is intended to use with the new API. 
 
nicholi shen:
This package is not available on PYPI. The link to the PYPI repo in the OP is not the package that is intended to use with the new API. 

First post is just the information I collected from this mql5 portal incl the thread started by MQ.
And this post #1 (from MQ) should be used as the instruction.

 

Machine translation from Russian to the English (the discussion is going on with the participation of MQ for example) 

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 R User Group - how to use R in Metatrader

Vladimir Perervenko , 2019.03.15 11:35

From "R or Python" to "R and Python"

On the Internet, and even on our forum, there were long disputes, which language is better than R or Python? Recently, however, an increasing number of analysts are coming to the conclusion that instead of contrasting two languages, both should be used. Each of these languages has its strengths and weaknesses, you need to use the best of both. Below is a completely free review of the article .

Let's look at the different aspects of these languages, what is good and what is not very good in each of them.

Python

Since its release in 1991, Python has become extremely popular and widely used in data processing. Here are some of the reasons for its wide popularity:

  • object oriented language
  • universal
  • has many extensions and incredible community support
  • simple and easy to learn
  • packages like pandas, numpy and scikit-learn make Python an excellent choice for machine learning.
  • however, Python does not have specialized packages for statistical calculations, unlike R

R

The first release of the language was released in 1995 and has since become the de facto standard language for data science. Consists of packages for use in many areas of data science. I will give only a list of tasks that are solved by packages R:

Topics

  • Bayesian - Bayesian Inference
  • Chemphys - Chemometrics and Computational Physics
  • ClinicalTrials - Clinical Trial Design, Monitoring, and Analysis
  • Cluster - Cluster Analysis & Finite Mixture Models
  • Databases - Databases with R
  • DifferentialEquations - Differential Equations
  • Distributions - Probability Distributions
  • Econometrics - Econometrics
  • Environmetrics - Analysis of Ecological and Environmental Data
  • ExperimentalDesign - Design of Experiments (DoE) & Analysis of Experimental Data
  • ExtremeValue - Extreme Value Analysis
  • Finance - Empirical finance
  • FunctionalData - Functional Data Analysis
  • Genetics - Statistical Genetics
  • Graphics - Graphic Displays & Dynamic Graphics & Graphic Devices & Visualization
  • HighPerformanceComputing - High Performance and Parallel Computing with R
  • Hydrology - Hydrological Data and Modeling
  • MachineLearning - Machine Learning & Statistical Learning
  • MedicalImaging - Medical Image Analysis
  • MetaAnalysis - Meta-analysis
  • MissingData - Missing data
  • ModelDeployment - Model Deployment with R
  • Multivariate - Multivariate Statistics
  • NaturalLanguageProcessing - Natural language processing
  • NumericalMathematics - Numerical mathematics
  • OfficialStatistics - Official Statistics & Survey Methodology
  • Optimization - Optimization and Mathematical Programming
  • Pharmacokinetics - Analysis of Pharmacokinetic Data
  • Phylogenetics - Phylogenetics, Especially Comparative Methods
  • Psychometrics - Psychometric Models and Methods
  • ReproducibleResearch - Reproducible Research
  • Robust - Robust Statistical Methods
  • SocialSciences - Statistics for the Social Sciences
  • Spatial - Analysis of Spatial Data
  • SpatioTemporal - Handling and Analyzing Spatio-Temporal Data
  • Survival - Survival Analysis
  • TimeSeries - Time Series Analysis
  • WebTechnologies - Web Technologies and Services
  • gR - gRaphical Models in R

Comes with excellent visualization libraries (ggplot2, shiny). The possibility of offline analysis (Rstudio). R is not the fastest language and sometimes eats up a lot of memory when working with big data.

This is a quick and very superficial glance at two languages. Why not use Python and R together?



 

More -

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 R User Group - how to use R in Metatrader

Vladimir Perervenko , 2019.03.15 11:42

There are two approaches with which we can use R and Python side by side in one project:

R in Python

PipeR - provides an easy way to access R from Python through pipes. PypeR is also included in the Python package index, which provides a more convenient installation method. PypeR is especially useful when there is no need for frequent interactive data transfers between Python and R. By running R through a pipe, Python gets the flexibility to manage subprocesses, memory management and portability on popular operating system platforms, including Windows, GNU Linux and Mac OS

pyRserve - uses Rserve as an RPC connection gateway. Through such a connection, variables can be set to R from Python, and R functions can be called remotely. R-objects are represented as instances of classes implemented in Python, with R-functions as methods associated with these objects, in some cases.

rpy2 - Performs an embedded R process in Python. It creates a platform that can convert Python objects to R objects, pass them into R functions, and convert the output R data back to Python objects. rpy2 is used more often as it is being actively developed.

Python to R

rJython - this package implements an interface to Python via Jython. It is designed for other packages to be able to embed python code along with R.

rPython is again a package that allows R to invoke Python. It allows you to run Python code, make function calls, assign and retrieve variables from it (not in the repository for R 3.5.2).

SnakeCharmR is a modern, redesigned version of rPython. This is rPython, which uses "jsonlite" and has many improvements over rPython. (not in the repository for R 3.5.2)

PythonInR - makes accessing Python from R very easy by providing functions for interacting with Python from inside R.

reticulate - The package provides a complete set of tools for interaction between Python and R. Of all the above alternatives, this one is the most widely used, especially since it is being actively developed by Rstudio. Reticulate embeds a Python session into an R session, ensuring seamless, high-performance interoperability. The package allows you to reticulate Python code in R, creating a new breed of project that combines two languages.

Conclusion
Both R and Python are fairly reliable languages, and one of them is actually enough to perform the task of data analysis. However, there are definitely some high and low points for both of them, and if we could use the strengths of both, we could eventually do a much better job. In any case, the knowledge of both will make us more flexible, thereby increasing our chances of working in different environments.

After finishing the data preparation started in previous posts, I will show how easy it is to use Python packages in R projects using the CatBoost package as an example.

Good luck


 

Forum on trading, automated trading systems and testing trading strategies

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

Renat Fatkhullin , 2019.03.15 23:09

The MetaTrader5 package is already available in 32/64 libraries for Python 3.7 and is put in one line.

pip install MetaTrader5

Forum on trading, automated trading systems and testing trading strategies

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

Renat Fatkhullin , 2019.03.16 01:27

Yes, this is the first quick presentation.

A description of working from R / Python with MetaTrader 5 will be included in the MQL5 documentation .

 
Hi, I'm interested in your project, I'm a python programmer, this python module will have a system to interact with the purchase and sale orders
 
190:
Hi, I'm interested in your project, I'm a python programmer, this python module will have a system to interact with the purchase and sale orders

I am not a coder (and it is not my project).

I am just collecting all the information related to this subject (this is the summary thread).
Read this post #1 from MetaQuotes.

Reason: