Get bars in the specified date range from the MetaTrader 5 terminal.
[in] Financial instrument name, for example, "EURUSD".
[in] Timeframe the bars are requested for. Set by a value from the MT5_TIMEFRAME enumeration.
[in] Date the bars are requested from. Set by the 'datetime' object or as a number of seconds elapsed since 1970.01.01. Bars with the open time >= date_from are returned.
[in] Date, up to which the bars are requested. Set by the 'datetime' object or as a number of seconds elapsed since 1970.01.01. Bars with the open time <= date_to are returned.
Returns bars as tuples (time, open, high, low, close, tick_volume, spread, real_volume).
See the CopyRates() function for more information.
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. The data obtained from MetaTrader 5 have UTC time, but Python applies the local time shift again when trying to print them. Thus, the obtained data should also be corrected for visual presentation.