How to read history file in mq5 using code and saving the data in an array?

 
How to read history file in mq5 using code and saving the data in an array?. Please if you are going to answer this question give an example with mq5 code.
 
rod777: How to read history file in mq5 using code and saving the data in an array?. Please if you are going to answer this question give an example with mq5 code.

It is right there in the documentation, with example code, and it is just one function ... CopyRates()

Plus you have already asked this before and I answered you with the same information, so follow the links provided and read the documentation that includes example of the code.

Forum on trading, automated trading systems and testing trading strategies

How can I read the history file using kernell32 library in mql4 and mql5?

Fernando Carreiro, 2018.10.06 12:29

As I have stated, in MetaTrader v5, you can't read the History file directly because it is encrypted, but you can just read the data directly by using the CopyRates() function. You can even read tick data directly as well with the CopyTicksRange() function.

Even on MetaTrader v4, there is no need to read the history directly, unless you are trying to circumvent the Strategy Tester to look ahead and thus produce false trading results, which is unethical.

Documentation on MQL5: Timeseries and Indicators Access / CopyRates
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
  • www.mql5.com
Gets history data of MqlRates structure of a specified symbol-period in specified quantity into the rates_array array. The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar. If you know the amount of data you need to copy, it should better be done to a statically allocated...
Reason: