Download MetaTrader 5

Bug found?

To add comments, please log in or register
Luis
226
Luis  

I have been 3 hours with this... trying to find an error on my code, but it seems is not the logic, anyone can explain it?


     int i=0;   
     int j=1;
     while(i<300)
      {
      Alert("i= ",i," ", iTime(Symbol(),j,i));
      i++;
      }


When j==1, the Alert comes: 2015.01.20 17:22:18.392    2014.11.12 00:47  FlokeBrok_TImeRAnge GBPUSD,M1: Alert: i= 295 1970.01.01 00:00:00

for every i.

The other values come OK. (5,15,30)

Is this a bug or I missing something here?

Greetings

BeLikewater

honest_knave
Moderator
2322
honest_knave  

If you check the documentation for iTime you'll see:

Returned value

Time value for the bar of specified symbol with timeframe and shift. If local history is empty (not loaded), function returns 0. To check errors, one has to call the GetLastError() function. 

So when you call for a bar that isn't in the history, it is going to return 0.

When you convert 0 into time, you get the start of 1970. 

Luis
226
Luis  

Thank you for your answer.

I will investigate the issue deeply.

Greetings

Luis
226
Luis  

Ei man. You were right. I was a bit confussed with my m1 data. Seems like work like you  said now..

Greetings

BeLikewater

To add comments, please log in or register