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.
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.
Checking for 4066 seems promising.
So how exactly do I use error 4066?
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 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.
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.
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.
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.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.