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.

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 "")

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.

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.

  • 1: PERIOD_M1

  • 2: PERIOD_M2

  • 5: PERIOD_M5

  • 15: PERIOD_M15

  • 30: PERIOD_M30

  • 60: PERIOD_H1

  • 120: PERIOD_H2

  • 240: PERIOD_H4

  • 480: PERIOD_H8

  • 1440: PERIOD_D1

  • 7200: PERIOD_W1

  • 216000: PERIOD_MN1

References

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

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

See also

Examples

if (FALSE) { 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 }