0 returned for the iTime function - page 2

 

I guess we are back to the beginning question.

I would like to use the functons iTime, iClose, iOpen, iHigh, etc. What is the recommended technique to use these functions for different time frames and currency pairs in an EA attached to a single chart?

 

try

  while(iTime("your Symbol", your PERIOD, 0) == 0)
   {
   Sleep(100);
   }
 
I don't see how the "Sleep" function will help. The question is: What needs to be done, so that iTime doesn't return a zero value for a different currency pair/time frame then exists on the chart.
 
Fsarno:
I don't see how the "Sleep" function will help. The question is: What needs to be done, so that iTime doesn't return a zero value for a different currency pair/time frame then exists on the chart.

It "sleeps" while waiting for the time array to be updated
 
if you dont see how sleep() is gonna help then don't use my suggestion
 

The problem is that there isn't history data for the currency pairs and time frames that I am using the "I" functions for. (This is why iTime returned 0) The sleep function won't produce or update these local files.

I will open up a new topic which is really what I was hoping to address here.

I would like to use the functons iTime, iClose, iOpen, iHigh, etc. What is the recommended technique to use these functions for different time frames and currency pairs in an EA attached to a single chart? Do I have to open up a chart for all of currency pairs and time frame combinations I wish to access? I was hoping to update the local history data within the EA without having to create a chart for each combination.

 
Fsarno:

The problem is that there isn't history data for the currency pairs and time frames that I am using the "I" functions for. (This is why iTime returned 0) The sleep function won't produce or update these local files.

WOW, you sure ?

I will open up a new topic which is really what I was hoping to address here.

don't bother

the only thing you should bother is:

why wasting other people's time when you even didn't bother to test their suggestions


I would like to use the functons iTime, iClose, iOpen, iHigh, etc. What is the recommended technique to use these functions for different time frames and currency pairs in an EA attached to a single chart? Do I have to open up a chart for all of currency pairs and time frame combinations I wish to access? I was hoping to update the local history data within the EA without having to create a chart for each combination.

tell us what you find

 
Fsarno:

The problem is that there isn't history data for the currency pairs and time frames that I am using the "I" functions for. (This is why iTime returned 0) The sleep function won't produce or update these local files.

I will open up a new topic which is really what I was hoping to address here.

I would like to use the functons iTime, iClose, iOpen, iHigh, etc. What is the recommended technique to use these functions for different time frames and currency pairs in an EA attached to a single chart? Do I have to open up a chart for all of currency pairs and time frame combinations I wish to access? I was hoping to update the local history data within the EA without having to create a chart for each combination.


The Sleep function won't update the files, the initial call to iTime etc will

Sleep just allows some time for the data to update.

I used this code for an exotic pair that I knew there was no history for

 for(int x=0;x<100;x++)
     {
      datetime t=iTime("USDCNH",PERIOD_M30,0);
      double h=iHigh("USDCNH",PERIOD_M30,0);
      Print("Time is ",TimeToStr(t,TIME_MINUTES),", High is ",DoubleToStr(h,4));
      if(t==0 || h==0)
         Sleep(100);
      else
         break;
     }

The prints were

15:53:35 a1 GBPUSD,M15: initialized

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:35 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:36 a1 GBPUSD,M15: Time is 00:00, High is 0.0000

15:53:36 a1 GBPUSD,M15: Time is 11:30, High is 6.2217

15:53:36 a1 GBPUSD,M15: uninit reason 0

So it took just over a second and history now exists where it didn't before

 
Aren't sleep used for making the ea idle itself for awhile without doing anything?
 
deysmacro:
Aren't sleep used for making the ea idle itself for awhile without doing anything?

correct, but, he needs the data before continuing

so he has no choice but sleep

Reason: