Question about CheckLoadHistory() function

 

This page https://www.mql5.com/en/docs/series/timeseries_access says:

"The CheckLoadHistory() function is designed as a universal function that can be called from any program (Expert Advisor, script or indicator); and therefore it requires three input parameters: symbol name, period and start date to indicate the beginning of price history you need.".

On the same page in the example of a script CheckLoadHistory() function uses Sleep() function.

But Sleep() function can't be called for custom indicators: https://www.mql5.com/en/docs/common/sleep

The question is: how CheckLoadHistory() function can be used in indicators, if Sleep() function will be ignored for them?

 
Andrei Iakovlev: This page https://www.mql5.com/en/docs/series/timeseries_access says: "The CheckLoadHistory() function is designed as a universal function that can be called from any program (Expert Advisor, script or indicator); and therefore it requires three input parameters: symbol name, period and start date to indicate the beginning of price history you need.". On the same page in the example of a script CheckLoadHistory() function uses Sleep() function. But Sleep() function can't be called for custom indicators: https://www.mql5.com/en/docs/common/sleep. The question is: how CheckLoadHistory() function can be used in indicators, if Sleep() function is not executed for them?

The example provided in the documentation is for a Script. It is however only an example.

For an indicator, you would have to use a different approach, where you would simply return from OnCalculate() should the data not be ready and wait for the next event call before trying again, repeating the process until the history data is loaded.

 
Fernando Carreiro #:

The example provided in the documentation is for a Script.

I know that this page says so, and yet, right under the 'Example of a Script for Adding History' chapter title this page says, what I mentioned in the first post:

"The CheckLoadHistory() function is designed as a universal function that can be called from any program (Expert Advisor, script or indicator)".

The meaning of this sentence, is that the CheckLoadHistory() function being developed there can be used in indicators also.

I suppose this sentence is incorrect and misleading, as it implies, that CheckLoadHistory() function from that page can just be copied and pasted and successfully used in indicators as well.

 
Andrei Iakovlev #:I know that this page says so, and yet, right under the 'Example of a Script for Adding History' chapter title this page says, what I mentioned in the first post: "The CheckLoadHistory() function is designed as a universal function that can be called from any program (Expert Advisor, script or indicator)". The meaning of this sentence, is that the CheckLoadHistory() function being developed there can be used in indicators also. I suppose this sentence is incorrect and misleading, as it implies, that CheckLoadHistory() function from that page can just be copied and pasted and successfully used in indicators as well.

Everyone makes mistakes and the documentation is no exception. There are also "bugs" in the documentation.

You were able to spot the problem and now know how to overcome it. That is part of being a programmer — solving problems!

 
Fernando Carreiro #:

Everyone makes mistakes and the documentation is no exception. There are also "bugs" in the documentation.

Of course mistakes can be made and they are more like inevitable, but now let's see, if this mistake will be fixed and how soon: https://www.mql5.com/en/forum/435978

[Suggestion] Correct 'Organizing Data Access' documentation page
[Suggestion] Correct 'Organizing Data Access' documentation page
  • 2022.11.08
  • www.mql5.com
This page https://www.mql5...
Reason: