MT5CopyRatesRange {MetaTrader}R Documentation

Get bars from the specified period

Description

Gets the specified number of bars of a financial instrument from within the specified period.

Usage

  MT5CopyRatesRange(symbol, timeframe, date_from, date_to)

Arguments

symbol

symbol name, for example "EURUSD"

timeframe

timeframe specified as a value of the MT5_TIMEFRAME enumeration

date_from

bar time for the first element to get, specified in seconds since 1970.01.01

date_to

bar time for the last element to get, specified in seconds since 1970.01.01

Details

For additional information, see https://www.mql5.com/en/docs/series/copyrates

Value

Returns a matrix with bar values:

time Bar time specified in seconds since 1970.01.01
open Open price
high Highest price
low Lowest price
close Close price
tick_volume Tick volume
spread Spread
real_volume Trade volume
            time    open    high     low   close tick_volume spread real_volume
 [1,] 1548436560 1.13825 1.13840 1.13822 1.13823         102      8           0
 [2,] 1548436620 1.13824 1.13879 1.13824 1.13872         142      8           0
 [3,] 1548436680 1.13873 1.13934 1.13862 1.13918         223      8           0
 [4,] 1548436740 1.13917 1.13930 1.13913 1.13916         180      8           0
 [5,] 1548436800 1.13917 1.13949 1.13912 1.13941         194      8           0
 [6,] 1548436860 1.13940 1.13942 1.13925 1.13941          93      8           0

Examples

  # start MetaTrader 5 Terminal (you should have it installed), call on first request only
  MT5Initialize()
  # wait for connection with broker server, call on first request only
  MT5WaitForTerminal()
  # get data
  MT5CopyRatesRange("EURPLN", MT5_TIMEFRAME_M1,
      as.POSIXct("2019-01-27 13:00:00"), as.POSIXct("2019-01-28 13:00:00"))

[Package MetaTrader version 5.0.0 Index]