ArrayCopyRates

 

Hi everyone, 

I've been trying to run the ArrayCopyRates function (not with the same name, similar function according to same mission) in mql5 but I couldn't be successful. In mql4 i used it like : 

double abc[][6];
ArrayCopyRates(abc, Symbol(), PERIOD_D1);

//when i want to use it --> 
temp_value = abc[1][4];

i tired with MqlRates and CopyRates but I could not reach the same result. Does anyone know of a tip that might help?

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / History Data Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / History Data Structure
  • www.mql5.com
History Data Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Rabia Yoruk :

Hi everyone, 

I've been trying to run the ArrayCopyRates function (not with the same name, similar function according to same mission) in mql5 but I couldn't be successful. In mql4 i used it like : 

i tired with MqlRates and CopyRates but I could not reach the same result. Does anyone know of a tip that might help?

Use CopyRates . Note that there are three options for the function:

Call by the first position and the number of required elements

int  CopyRates(
   string           symbol_name,       // symbol name
   ENUM_TIMEFRAMES  timeframe,         // period
   int              start_pos,         // start position
   int              count,             // data count to copy
   MqlRates         rates_array[]      // target array to copy
   );

Call by the start date and the number of required elements

int  CopyRates(
   string           symbol_name,       // symbol name
   ENUM_TIMEFRAMES  timeframe,         // period
   datetime         start_time,        // start date and time
   int              count,             // data count to copy
   MqlRates         rates_array[]      // target array to copy
   );

Call by the start and end dates of a required time interval

int  CopyRates(
   string           symbol_name,       // symbol name
   ENUM_TIMEFRAMES  timeframe,         // period
   datetime         start_time,        // start date and time
   datetime         stop_time,         // end date and time
   MqlRates         rates_array[]      // target array to copy
   );
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
  • www.mql5.com
CopyRates - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Vladimir Karputov #:

Use CopyRates . Note that there are three options for the function:

Call by the first position and the number of required elements

Call by the start date and the number of required elements

Call by the start and end dates of a required time interval

   Firstly thank you for your reply and help,

   actually i tried it before however in mql4 i used two-dimensional destination array format of arrayCopyRates function. So copyrates doesnt support it and I couldn't migrate it.

 
Rabia Yoruk #:

   Firstly thank you for your reply and help,

   actually i tried it before however in mql4 i used two-dimensional destination array format of arrayCopyRates function. So copyrates doesnt support it and I couldn't migrate it.

You don't need a two-dimensional array in mql5. You will have an array of struct. Learn how to use it.
 
How to start with MQL5
How to start with MQL5
  • 2021.11.13
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 

Thank you, i resolved it now and perfectly working ! 

 
Alain Verleyen #:
You don't need a two-dimensional array in mql5. You will have an array of struct. Learn how to use it.
   Thank you, i research and compared according to your reply, i resolved it now and perfectly working !
Reason: