Giter VIP home page Giter VIP logo

mt5r's Introduction

mt5R

Overview

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

Example

This is a basic example to load EURUSD data, using time frame of 5 minutes iTF = 5:

MT5.GetSymbol("EURUSD", iTF = 5, iRows = 5)
#>   Year Month Day Hour Minute    Open    High     Low   Close Volume
#> 1 2021     3  19   23     35 1.19025 1.19028 1.19012 1.19024     43
#> 2 2021     3  19   23     40 1.19027 1.19027 1.19019 1.19025     47
#> 3 2021     3  19   23     45 1.19025 1.19026 1.19012 1.19015     55
#> 4 2021     3  19   23     50 1.19015 1.19048 1.19012 1.19033    135
#> 5 2021     3  19   23     55 1.19035 1.19055 1.19022 1.19024    223

## Using xts package
MT5.GetSymbol("EURUSD", iTF = 5, iRows = 5, xts = TRUE)
#>                        Open    High     Low   Close Volume
#> 2021-03-19 23:35:00 1.19025 1.19028 1.19012 1.19024     43
#> 2021-03-19 23:40:00 1.19027 1.19027 1.19019 1.19025     47
#> 2021-03-19 23:45:00 1.19025 1.19026 1.19012 1.19015     55
#> 2021-03-19 23:50:00 1.19015 1.19048 1.19012 1.19033    135
#> 2021-03-19 23:55:00 1.19035 1.19055 1.19022 1.19024    223

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()
#> [1] sSymbol iCmd    fVolume fPrice  fStop   fGain   fProfit iTicket
#> <0 rows> (or 0-length row.names)

Looking for more examples? Good! Check Articles tab for more simple examples.

Installation

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:

  1. mt5R in R
  2. mt5R in MT5

Instructions: Installing mt5R in R

Install the development version from GitHub with:

#install.packages("devtools")
devtools::install_github("Kinzel/mt5R") 

Instructions: Installing mt5R in MT5

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)

  1. Download mt5R v0_1_5.ex5.
  2. Move 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.

  • For non compiled version .mq5 (mt5R v0_1_5.mq5) - The most suitable for developers.

Getting Started

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()
#> [1] TRUE

If it returns TRUE everything has been successfully installed and you’re ready to use mt5R! Yay!

Creating your own functions

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

Contributing

If you want to contribute to mt5R send me an email ([email protected]) with your GitHub account.

See Also

  • quantmod: quantitative financial modeling framework
  • TTR: functions for technical trading rules
  • xts: eXtensible Time Series based
  • zoo: S3 Infrastructure for Regular and Irregular Time Series

Credits

  • JC without his awesome socket library mt5R would not be possible!

Author

Guilherme Kinzel

mt5r's People

Contributors

kinzel avatar

Stargazers

Gamuchirai Ndawana avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.