copytime returns -1

 
void OnStart() 
  {
   datetime start=D'2010.12.6';
   datetime end=D'2010.12.6 7';
   datetime time[];
   int copied=-1,loop=0;
   while(copied==-1 && loop<100) 
     {
      copied=CopyTime(_Symbol,_Period,start,end,time);
      Sleep(1000);
      loop++;
      Print("loop=",loop," copied=",copied);
     }
  }
Could someone tell me what is wrong with the codes?  copied is always -1 even though the chart is loaded.
 

Hi..!!

Not sure that your code is wrong. I just found a problem with the date routines when converting a program from MQL4 to MQL5.  I am subtracting 1 day from a date by subtracting 60*60*24, which is the number of seconds in a day... Its not producing the correct output in MQL5, and it works fine in MQL4. Nevertheless, Iif you find out who to address on your issue please pm me.

 

Thanks....

Guillermo 

 

Hi again..

I think you might be having the problem due to the missalignment of the Date fields: At least MQ4 was very picky about it: YYYY.MM.DD hh:mm. See if that works..

 
williamwong:
Could someone tell me what is wrong with the codes?  copied is always -1 even though the chart is loaded.

 

This error (any Copy... functions with arguments DateFrom, DateTo) has been already fixed. Please wait for the next build. 

 
alexvd:

 

This error (any Copy... functions with arguments DateFrom, DateTo) has been already fixed. Please wait for the next build. 

Please also check all functions with start_time and count.
int  CopyTime(
   string           symbol_name,     // symbol name
   ENUM_TIMEFRAMES  timeframe,       // period
   datetime         start_time,      // start date and time
   int              count,           // data count to copy
   datetime         time_array[]     // target array to copy  open times
   );
 

same pb here, 

when the next build will be released? 

 
ifmihai:

same pb here, 

when the next build will be released? 

Today, I hope.
 

Just to be known, I am having the same problem with CopyRates (with arguments DateFrom, DateTo), that used to work.

Let's wait for the next build.

Thanks. 

 
As far as i know the build that fixes this problem hasn't been released yet. When do you think it will be released?

 
alix7:
As far as i know the build that fixes this problem hasn't been released yet. When do you think it will be released?

Please check again.