|
copy_rates_from
Get bars from the MetaTrader 5 terminal starting from the specified date.
copy_rates_from(
|
Parameters
symbol
[in] Financial instrument name, for example, "EURUSD". Required unnamed parameter.
timeframe
[in] Timeframe the bars are requested for. Set by a value from the TIMEFRAME enumeration. Required unnamed parameter.
date_from
[in] Date of opening of the first bar from the requested sample. Set by the 'datetime' object or as a number of seconds elapsed since 1970.01.01. Required unnamed parameter.
count
[in] Number of bars to receive. Required unnamed parameter.
Return Value
Returns bars as the numpy array with the named time, open, high, low, close, tick_volume, spread and real_volume columns. Return None in case of an error. The info on the error can be obtained using last_error().
Note
See the CopyRates() function for more information.
Only data whose date is less than (earlier) or equal to the date specified will be returned. It means, the open time of any bar is always less or equal to the specified one.
MetaTrader 5 terminal provides bars only within a history available to a user on charts. The number of bars available to users is set in the "Max. bars in chart" parameter.
When creating the 'datetime' object, Python uses the local time zone, while MetaTrader 5 stores tick and bar open time in UTC time zone (without the shift). Therefore, 'datetime' should be created in UTC time for executing functions that use time. Data received from the MetaTrader 5 terminal has UTC time.
TIMEFRAME is an enumeration with possible chart period values
ID |
Description |
---|---|
TIMEFRAME_M1 |
1 minute |
TIMEFRAME_M2 |
2 minutes |
TIMEFRAME_M3 |
3 minutes |
TIMEFRAME_M4 |
4 minutes |
TIMEFRAME_M5 |
5 minutes |
TIMEFRAME_M6 |
6 minutes |
TIMEFRAME_M10 |
10 minutes |
TIMEFRAME_M12 |
12 minutes |
TIMEFRAME_M12 |
15 minutes |
TIMEFRAME_M20 |
20 minutes |
TIMEFRAME_M30 |
30 minutes |
TIMEFRAME_H1 |
1 hour |
TIMEFRAME_H2 |
2 hours |
TIMEFRAME_H3 |
3 hours |
TIMEFRAME_H4 |
4 hours |
TIMEFRAME_H6 |
6 hours |
TIMEFRAME_H8 |
8 hours |
TIMEFRAME_H12 |
12 hours |
TIMEFRAME_D1 |
1 day |
TIMEFRAME_W1 |
1 week |
TIMEFRAME_MN1 |
1 month |
Example:
from datetime import datetime
|
See also
CopyRates, copy_rates_from_pos, copy_rates_range, copy_ticks_from, copy_ticks_range