Download MetaTrader 5

copytime returns -1

To add comments, please log in or register
Share your knowledge. Become a well-known developer!
williamwong
632
williamwong 2010.12.07 04:50 
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.
gjrexach
68
gjrexach 2010.12.07 07:46  

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 

gjrexach
68
gjrexach 2010.12.07 07:50  

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..

Alexey Da
Moderator
6604
Alexey Da 2010.12.07 11:44  
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. 

williamwong
632
williamwong 2010.12.08 13:25  
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
   );
Mihai Ionescu
1289
Mihai Ionescu 2010.12.08 19:22  

same pb here, 

when the next build will be released? 

Alexey Da
Moderator
6604
Alexey Da 2010.12.09 12:11  
ifmihai:

same pb here, 

when the next build will be released? 

Today, I hope.
Jin
1539
Jin 2010.12.10 00:40  

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. 

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

Alexey Da
Moderator
6604
Alexey Da 2010.12.15 12:34  
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.
To add comments, please log in or register