knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Simple example to have access of daily EURUSD
dataset of MT5 server broker.
MT5.GetSymbol()
.bDeletecsv = FALSE
.Load mt5R
.
library(mt5R)
Let's check if mt5R
in MT5 plataform is listening.
MT5.Ping()
Everything is fine! Let's continue.
To reasonable size of data the best practice is to use the function MT5.GetSymbol()
. To small chunks try MT5.Quick_GetSymbol()
instead.
To obtain all the available data use iRows = Inf
(mt5R
0.1.3 or newer versions), iTF = 1440
is to obtain daily data, check ?MT5.GetSymbol
for other availables timeframes.
TimeStart <- Sys.time() ## Lets check how long it takes. Starting the chronometer! EURUSD <- MT5.GetSymbol("EURUSD", iTF = 1440, iRows = Inf, xts = TRUE) TimeEnd <- Sys.time() ## Saving the time when it ended
## Save time to create package site ## To run everything as should be, change eval to TRUE in above chunk and delete this one library(xts) load("F:/Pacotes/mt5R/EURUSD_Data.RData", env <- new.env()) EURUSD <- env$EURUSD TimeStart <- env$TimeStart TimeEnd <- env$TimeEnd
Finally!
It's a huge dataset. Lets get a closer look - how long it took to download all the data?
print(TimeEnd-TimeStart)
The time requirement scales linearly, it will takes considerable amount of time for very huge datasets - since a .csv
is created and the data is stored. To quickier load of data use MT5.Quick_GetSymbol()
instead.
Check dimensions of Data
.
dim(EURUSD)
It's 12,910 days of OHLC
data.
Let's check the first lines of EURUSD
.
head(EURUSD)
Let's check the end lines of Data
.
tail(EURUSD)
You can plot the EURUSD
using quantmod package.
library(quantmod) quantmod::chartSeries(EURUSD)
To make EURUSD
obtained available to other softwares (Python and etc), use argument bDeletecsv = FALSE
in function MT5.GetSymbol()
. See example below.
EURUSD <- MT5.GetSymbol("EURUSD", iTF = 1440, iRows = Inf, bDeletecsv = FALSE)
The .csv
table downloaded will be stored in Files
MT5's folder. To find out specifically where it is located use the function MT5.FileWorkingFolder()
.
MT5.FileWorkingFolder()
csv
is structured:Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.