Download MetaTrader 5
To add comments, please log in or register
What is a social trading? Read the article to find that out!
Luis
226
Luis 2015.01.20 16:26 

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
969
honest_knave 2015.01.20 16:51  

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 2015.01.21 15:03  

Thank you for your answer.

I will investigate the issue deeply.

Greetings

Luis
226
Luis 2015.01.24 13:35  

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