knitr::opts_chunk$set( collapse = TRUE, comment = "#>", out.width = "75%" ) library(mt5R) library(quantmod) library(badger)
r badge_lifecycle("stable", "blue")
mt5R is an R package that provides a framework for MT5 users that want to achieve Machine Learning analysis and trading. It provides easy integration with socket connection to reach maximum performance.
Package has 34 functions (check Reference tab):
Purpose | # functions ------------- | ------------- Trading | 16 Machine Learning | 5 Others | 13
This is a basic example to load EURUSD
data, using time frame of 5 minutes iTF = 5
:
MT5.GetSymbol("EURUSD", iTF = 5, iRows = 5) ## Using xts package MT5.GetSymbol("EURUSD", iTF = 5, iRows = 5, xts = TRUE)
Plot MT5.GetSymbol
output using quantmod package:
library(quantmod) Table = MT5.GetSymbol("EURUSD", iTF = 1440, iRows = 30, xts = T) quantmod::chartSeries(Table, theme = "white", name = "EURUSD")
Buy 0.001
EURUSD
at 1.2206
:
MT5.SingleOrder("EURUSD", iCmd = 0, fVol = 0.001, fPrice = 1.2206)
Check open positions:
MT5.ShowPositions()
Looking for more examples? Good! Check Articles tab for more simple examples.
Assuming that you have installed MT5 and successful connected to one broker server. If you don't have it yet, don't panic: MT5 is free for most of brokers!
Installation is divided into two parts:
Install the development version from GitHub with:
#install.packages("devtools") devtools::install_github("Kinzel/mt5R")
To mt5R works you must use the mt5R Expert Advsior in your MT5.
There are two installation options for mt5R in MT5:
.ex5
: "Plug and play" version. The most suitable version for most..mq5
: for developers.For "Plug and play" version .ex5
(mt5R v0_1_5.ex5
)
mt5R v0_1_5.ex5
.mt5R v0_1_5.ex5
to ...\MQL5\experts\
folder. To check where MT5's folders, open MT5 and Tools > Options > Storage
.And you're ready to go!
(If you're not a developer, go ahed to Getting Started)
Alternatively, for MQL developers you can also download the .mq5
code used to generate mt5R v0_1_5.ex5
. Both are exactly the same code, it's the no compiled version. This is the choice recommend for who want to tailor their own solutions and functions.
.mq5
(mt5R v0_1_5.mq5
) - The most suitable for developers.socket-library-mt4-mt5.mqh
to ...\MQL5\include\
folder.mt5R v0_1_5.mq5
.mt5R v0_1_5.mq5
code to ...\MQL5\experts\
folder.mt5R v0_1_5.mq5
.mt5R v0_1_5.ex5
(or the name you chose) will be generated.Attach mt5R v0_1_5.ex5
to any chart opened in your MT5, like any other Expert Advisor.
Check your "Expert" tab to this message:
Execute those commands:
library(mt5R) MT5.Ping()
If it returns TRUE
everything has been successfully installed and you're ready to use mt5R! Yay!
The most awesome part of MT5 is make reliable to create your owns solutions and functions. The cookbook is still under construction, but you can start checking functions MT5.zExample
in mt5R package and Z1
order in mt5R v0_1_5.mq5
. Its pretty easy!
## Execute the function without () to see its code mt5R::MT5.zExample
If you want to contribute to mt5R send me an email (guikinzel@gmail.com) with your GitHub account.
Guilherme Kinzel
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.