MT5.GetSymbol: Load data from MT5

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/Source_MT5.R

Description

Function to load sSymbol in Data.frame or xts if specified. It uses csv created by MT5 to manipulate the data, this function was created to manage reasonable size of data, for tiny sizes of data use MT5.Quick_GetSymbol() instead.

The csv created can be used by other softwares, by default is deleted after use bDeletecsv = TRUE.

Data is loaded silently and will take longer as defined iRows is.

Usage

1
2
3
4
5
6
7
8
9
MT5.GetSymbol(
  sSymbol,
  iTF,
  iRows = 5,
  xts = FALSE,
  iWait = Inf,
  bDeletecsv = TRUE,
  xts_tz = ""
)

Arguments

sSymbol

character; target symbol.

iTF

int; target time frame. See details.

iRows

int; how many rows. It's start from last. (default: 5)

xts

bool; if xts = TRUE the function will return a xts instead. See details.

iWait

int; how long to wait for csv from MT5 (default Inf)

bDeletecsv

bool; delete csv after use (default TRUE)

xts_tz

character; time zone specification to be used when xts = TRUE (default "")

Details

It should be used only for reasonable table sizes.

Even after stop this function on running or iWait ran out, mt5R running in MT5 will keep running to create the table. To a complete stop, proceed to kill both process. For very big sizes (iRow) the user should be patient.

MT5.Quick_GetSymbol() can be used instead for smaller tables, it not uses csv. Preliminary tests indicate to up 80x speed gain.

Supported time frames (iTF). See references for even more details.

Value

Always returns OHCLV format. Date will be exhibited as it xts parameter is defined.

xts = FALSE (default)

Returns [nx10] {data.frame} {Year, Month, Day, Hour, Minute, Open, High, Low, Close, Volume}

xts = TRUE

Returns [nx5] {xts} {Open, High, Low, Close, Volume}

On failure attempts it will return a empty data.frame.

Author(s)

Guilherme Kinzel, guikinzel@gmail.com

References

https://en.wikipedia.org/wiki/Open-high-low-close_chart

https://www.mql5.com/en/docs/constants/chartconstants/enum_timeframes

See Also

MT5.Quick_GetSymbol(), MT5.QuickLastRow_GetSymbol()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 

MT5.GetSymbol("EURUSD", iTF = 5, iRows = 3)

## Returns
##   Year Month Day Hour Minute    Open    High     Low   Close Volume
## 1 2020    12  11    1      5 1.21411 1.21414 1.21405 1.21409     39
## 2 2020    12  11    1     10 1.21408 1.21419 1.21404 1.21418     56
## 3 2020    12  11    1     15 1.21421 1.21421 1.21405 1.21408     63

MT5.GetSymbol("EURUSD", iTF = 5, iRows = 3, xts = TRUE)

## Returns
##                        Open    High     Low   Close Volume
## 2020-12-11 01:05:00 1.21411 1.21414 1.21405 1.21409     39
## 2020-12-11 01:10:00 1.21408 1.21419 1.21404 1.21418     56
## 2020-12-11 01:15:00 1.21421 1.21421 1.21405 1.21415     82


## End(Not run)

Kinzel/mt5r documentation built on March 25, 2021, 9:57 p.m.