MQL4 - automated forex trading   /  

Documentation

MQL4 Reference  Array functions  ArrayCopyRates

 
int ArrayCopyRates( void dest_array[], string symbol=NULL, int timeframe=0)
Copies rates to the two-dimensional array from chart RateInfo array and returns copied bars amount, or -1 if failed. First dimension of RateInfo array contains bars amount, second dimension has 6 elements:
0 - time,
1 - open,
2 - low,
3 - high,
4 - close,
5 - volume.

If data (symbol name and/or timeframe differ from the current ones) are requested from another chart, the situation is possible that the corresponding chart was not opened in the client terminal and the necessary data must be requested from the server. In this case, error ERR_HISTORY_WILL_UPDATED (4066 - the requested history data are under updating) will be placed in the last_error variable, and one will has to re-request (see example of ArrayCopySeries()).

Notes: This rates array is normally used to pass data to a DLL function.
Memory is not really allocated for data array, and no real copying is performed. When such an array is accessed, the access will be redirected.
Parameters:
dest_array[]   -   Reference to the two-dimensional destination array of double type.
symbol   -   Symbol name (currency pair name)
timeframe   -   Timeframe. It can be any of the listed timeframes values.
Sample:
  double array1[][6];
  ArrayCopyRates(array1,"EURUSD", PERIOD_H1);
  Print("Current bar ",TimeToStr(array1[0][0]),"Open", array1[0][1]);