Hello everyone, how can we get a calculation of the number of candles formed from the date 2009 to 2021, for example, on the minute frame?

 

Hello everyone, how can we get a calculation of the number of candles formed from the date 2009 to 2021, for example, on the minute frame? i want to gets (open ,high ,low ,close) prices form 9/10/2009 to 9/10/2022 for example can any one help me please

 
Db Orc:

Hello everyone, how can we get a calculation of the number of candles formed from the date 2009 to 2021, for example, on the minute frame? i want to gets (open ,high ,low ,close) prices form 9/10/2009 to 9/10/2022 for example can any one help me please

   datetime  startTime = D'9.10.2009 12:30:27';
   datetime endTime = D'9.10.2022 12:30:27';
   ENUM_TIMEFRAMES period = PERIOD_M1;
   int shiftStart = iBarShift(NULL,period,startTime);
   int shiftEnd = iBarShift(NULL,period,endTime);
   

   MqlRates rates[];
   ArraySetAsSeries(rates,true);

   CopyRates(NULL,PERIOD_M1,shiftStart,shiftEnd-shiftStart,rates);
   ArrayPrint(rates);
 
Arpit T #:

 

I tried the code, but the Forex market strength cannot obtain historical data from the year 1990 to the present time on a one-minute frame. (((((((((((((Thank you for your interest and I hope you will help me solve this problem.)))))))))))

 
Db Orc #:

 

I tried the code, but the Forex market strength cannot obtain historical data from the year 1990 to the present time on a one-minute frame. (((((((((((((Thank you for your interest and I hope you will help me solve this problem.)))))))))))

please check this utility  on codebase

study what is error by modifying this line

 if(CopyRates(NULL,PERIOD_M1,shiftStart,shiftEnd-shiftStart,rates)==-1) Print(GetLastError());

then search for the error cause on forum

Check how many bars available from Tools > Options > Chart > Max bar in chart or Print

Print(TerminalInfoInteger(TERMINAL_MAXBARS));
if your bars you want are not available in chart then it will fail to copy
 
Arpit T #:

please check this utility  on codebase

study what is error by modifying this line

then search for the error cause on forum

Check how many bars available from Tools > Options > Chart > Max bar in chart or Print

if your bars you want are not available in chart then it will fail to copy
Well, my brother, the result after modifying the code was this, noting that the date was from 9/10/2022 to 9/10/2023. Just As shown in the picture

Well, my brother, the result after modifying the code was this, noting that the date was from 9/10/2022 to 9/10/2023.
Just
As shown in the picture

Files:
error_2.png  135 kb
 
Db Orc #:

You can clearly see the date is WRONG. so in this case you have to troubleshoot why date is wrong, most probably Copyrates did not work due to the bars unavailability