Problems with gaps in the hst file

[Deleted]  

Hi,

when MT4 or the internet connection were closed, we have gaps in the .hst files.

When MT4 or the internet connection open again, my indicator encounters these gaps.

What can I do in the indicator source code, to make MT4 fill these gaps?

At the moment my only workaround is to reload the profile with the indicator.

But I'm looking for a "clean" solution, without reloading.

Simon Gniadkowski
17410
mt4forum:

Hi,

when MT4 or the internet connection were closed, we have gaps in the .hst files.

When MT4 or the internet connection open again, my indicator encounters these gaps.

What can I do in the indicator source code, to make MT4 fill these gaps?

At the moment my only workaround is to reload the profile with the indicator.

But I'm looking for a "clean" solution, without reloading.

If you can detect that a gap has happened you can try reading the bars that you think are missing and checking for error 4066, when you no longer get error 4066 the missing bars should have been downloaded, then if you re-process all bars, not just any new bars, your Indicator should be in good shape . . . you are going to have to try it for yourself though, this issue can be a PITA. See this recent thread: https://www.mql5.com/en/forum/146558
[Deleted]  

Checking for 4066 seems promising.

But I think I need some more help on that:

I've tested the following indicator code:

int init()
{
   int i;
   int j;  
   double CloseVal;
   string EURUSD = "EURUSD";
   
   for (i = 10; i >= 0; i--)
      for (j = 1; j <= 3; j++)
      {
         CloseVal = iClose(EURUSD, 0, i);
         Error = GetLastError();
         
         Print("j: ", j, " iTime(EURUSD, 0,", i, "): ", TimeToStr(iTime(EURUSD, 0, i), TIME_DATE|TIME_MINUTES), " CloseVal: ", CloseVal, " Error: ", Error, Blank, ErrorDescription(Error));
      }
}

Which generates the following output:

11:47:21 GA_... USDJPY,M15: j: 1 iTime(EURUSD, 0,10): 2013.09.03 17:15 CloseVal: 1.3154 Error: 4066 requested history data in update state
11:47:21 GA_... USDJPY,M15: j: 2 iTime(EURUSD, 0,10): 2013.09.03 17:15 CloseVal: 1.3154 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 3 iTime(EURUSD, 0,10): 2013.09.03 17:15 CloseVal: 1.3154 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 1 iTime(EURUSD, 0,9): 2013.09.03 17:30 CloseVal: 1.3161 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 2 iTime(EURUSD, 0,9): 2013.09.03 17:30 CloseVal: 1.3161 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 3 iTime(EURUSD, 0,9): 2013.09.03 17:30 CloseVal: 1.3161 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 1 iTime(EURUSD, 0,8): 2013.09.03 17:45 CloseVal: 1.3156 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 2 iTime(EURUSD, 0,8): 2013.09.03 17:45 CloseVal: 1.3156 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 3 iTime(EURUSD, 0,8): 2013.09.03 17:45 CloseVal: 1.3156 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 1 iTime(EURUSD, 0,7): 2013.09.03 18:00 CloseVal: 1.316 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 2 iTime(EURUSD, 0,7): 2013.09.03 18:00 CloseVal: 1.316 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 3 iTime(EURUSD, 0,7): 2013.09.03 18:00 CloseVal: 1.316 Error: 0 no error
11:47:21 GA_... USDJPY,M15: j: 1 iTime(EURUSD, 0,6): 2013.09.03 18:15 CloseVal: 1.316 Error: 0 no error

That means, only the first attempt to read iClose(EURUSD, 0, 10) returns 4066.

The second read and any further reads return no error.

But as you can see the values for iClose and iTime are all wrong, showing yesterdays shifts when the internet connection was cut.

So how exactly do I use error 4066?

Thanx.

Simon Gniadkowski
17410
mt4forum:

Checking for 4066 seems promising.

So how exactly do I use error 4066?

Use the Forum search and you will find out plenty of info . . . you need to wait a little for the data to be received, it's not instantaneous.
[Deleted]  

I understand, that the download takes time.

But waiting, until I don't get Error 4066 anymore - as you suggested - doesn't seem to do the trick, right?
I will have do use some other checks, to verify, if the data is up to date.

Simon Gniadkowski
17410
mt4forum:

I understand, that the download takes time.

But waiting, until I don't get Error 4066 anymore - as you suggested - doesn't seem to do the trick, right?
I will have do use some other checks, to verify, if the data is up to date.

If the data is the same it hasn't updated yet . . . you need to wait some time . . . Sleep()
Ex Ovo Omnia
3118
Ex Ovo Omnia  
mt4forum:

I understand, that the download takes time.

But waiting, until I don't get Error 4066 anymore - as you suggested - doesn't seem to do the trick, right?
I will have do use some other checks, to verify, if the data is up to date.


I performed some other tests and I am convinced, that Error 4066 is a dummy feature.

It appears in every script only once - after the first call of a function. It is triggered every time independently on the update status. After its first appearance, it wouldn't appear any more, regardless of the update status, again.

So I am really curious, how those, who recommended this 4066 check many times, got some use of it.

Simon Gniadkowski
17410
Ovo:


I performed some other tests and I am convinced, that Error 4066 is a dummy feature.

It appears in every script only once - after the first call of a function. It is triggered every time independently on the update status. After its first appearance, it wouldn't appear any more, regardless of the update status, again.

So I am really curious, how those, who recommended this 4066 check many times, got some use of it.

It makes sense to me . . .

  • request data that is not in a hst file
  • the terminal requests the data from the server and sets error 4066 . . . history is updating and will be updated
  • some time later the history has updated

if the same data is requested again why should there be another error 4066 ? the history is either already updated or the data has been requested and is on it's way . . . if you want to know when the history has been updated then you will need to check this for yourself, for example; compare the value received just before the error 4066 was seen and the current value, if they are different then the data has been updated.

Ex Ovo Omnia
3118
Ex Ovo Omnia  
RaptorUK:

It makes sense to me . . .

  • request data that is not in a hst file
  • the terminal requests the data from the server and sets error 4066 . . . history is updating and will be updated
  • some time later the history has updated

if the same data is requested again why should there be another error 4066 ? the history is either already updated or the data has been requested and is on it's way . . . if you want to know when the history has been updated then you will need to check this for yourself, for example; compare the value received just before the error 4066 was seen and the current value, if they are different then the data has been updated.


You are getting 4066 for both synchronized and out-of-sync data, that is what I have spotted. There is no difference between missing and fetched data. And even if it worked like you describe (it does not), I doubt I could seriously use it.

Simon Gniadkowski
17410
Ovo:


You are getting 4066 for both synchronized and out-of-sync data, that is what I have spotted. There is no difference between missing and fetched data. And even if it worked like you describe (which does not), I doubt I could seriously use it.

OK, if you can't use it then you can't . . . what will you do instead ?
Ex Ovo Omnia
3118
Ex Ovo Omnia  
RaptorUK:
OK, if you can't use it then you can't . . . what will you do instead ?


I check iBars for increments > 1.