Dear fellows
I am having hard time with CheckLoadHistory() of article https://www.mql5.com/en/docs/series/timeseries_access and seeking guidance here if any known issues with it or I am doing something wrong?
I am using following code to sync data and when I start the MQL Platform the indicator hangs out and I have to delete it. This causes error[-3] stopped by used.
When I attach indicate back and recompile the indicator, it starts working.
I have used following checkLoadHistory() with little bit modification to use it in a class (cATS) where class is initialized with mSymbol.
Dear @Dominik Egert
Thanks a lot for your reply and support to bail me out of the error issue.
Attached is compliable version in Zip format.
This indicator is really beyond my current coding capabilities and helping me a lot in learning MQL much better way. As I am still having other challenges in the code, please ignore areas not related and you can focus only on CSessionVPBase::OnTick(void) method at line 259 and if(resultM1 < 0 || resultH1 < 0) error there.
In addition any suggestion to improvise coding style will always be welcomed.
Thanks again a lot and look forward for solution.
Dear @Dominik Egert
Thanks a lot for your reply and support to bail me out of the error issue.
Attached is compliable version in Zip format.
This indicator is really beyond my current coding capabilities and helping me a lot in learning MQL much better way. As I am still having other challenges in the code, please ignore areas not related and you can focus only on CSessionVPBase::OnTick(void) method at line 259 and if(resultM1 < 0 || resultH1 < 0) error there.
In addition any suggestion to improvise coding style will always be welcomed.
Thanks again a lot and look forward for solution.
Dear @Dominik Egert
Thanks a lot for your reply and support to bail me out of the error issue.
Attached is compliable version in Zip format.
This indicator is really beyond my current coding capabilities and helping me a lot in learning MQL much better way. As I am still having other challenges in the code, please ignore areas not related and you can focus only on CSessionVPBase::OnTick(void) method at line 259 and if(resultM1 < 0 || resultH1 < 0) error there.
In addition any suggestion to improvise coding style will always be welcomed.
Thanks again a lot and look forward for solution.
So, I have analyzed it to some extend. Here is what I have found:
DealingWithTime.mqh
In line 235 to 238 there is a "Sleep()" command. - It is ineffective in indicators.
In line 633 there is an undocumented function call to MQL5InfoInteger, should probably be MQLInfoInteger.
In line 636 the error 4401 is raised for "ERR_HISTORY_NOT_FOUND".
In line 651, if that call fails, a while loop will run again using "Sleep" with no effect in indicators.
In line 663 the while loop will never turn false, keeping it running forever, because the chart thread is blocked by the indicator. - this results in a "race condition": One is waiting for the other while the other will never satisfy the condition, because (in this case) it will never get the chance to download the data.
This is the actual issue with the code. - In general, I would say the whole code needs a bit more error handling, and awareness of what it is actually doing. I have gotten multiple different error codes on the way, and the code should be written in such way, that it takes care of all error codes in one way or another.
Hi @Dominik Egert Thanks a lot for your support and taking time off to help me out.
In line 235 to 238 there is a "Sleep()" command. - It is ineffective in indicators. Is there any harm, if still included in code and there is a call from EA or Strategy Class, so it to work?
Somewhere in the documentation I found ...
Access to indicator and timeseries data is implemented irrespective of the fact whether the requested data are ready (the so called asynchronous access). This is critically important for the calculation of custom indicator, so if there are no data,
functions of Copy...() type immediately return an error. However, when accessing from Expert Advisors and scripts, several attempts to receive data are made in a small pause, which is aimed at providing some time necessary to download required
timeseries or to calculate indicator values.
Can you guide me, if an Indicator is calling an OOP class (not an EA or Script) and Copy...() type is located in such OOP class. Call to this Copy...() will be treated as from an Indicator OR from an EA/Script?
and hence if call is treated from an Indicator, your conclusion (So basically, the code is incompatible to indicators, as it is at the moment.) should held true.
I am trying to digest other clues from you and see any work around.
One more request, if you are aware of another article which handles such Organized Data Access for Indicators, you can point me to it.
I am also closing this thread with conclusion that checkLoadHistory() of article https://www.mql5.com/en/docs/series/timeseries_access is incompatible to indicators, as it is at the moment. I would like to request MQL Service Desk (@MQL-Services), to look into this and if possible provide and updated version.
Thanks a lot again and regards.
![Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access Documentation on MQL5: Timeseries and Indicators Access / Organizing Data Access](https://c.mql5.com/36/82/documentation-on-mql5-timeseries__2.png)
- www.mql5.com
Hi @Dominik Egert Thanks a lot for your support and taking time off to help me out.
In line 235 to 238 there is a "Sleep()" command. - It is ineffective in indicators. Is there any harm, if still included in code and there is a call from EA or Strategy Class, so it to work?
Somewhere in the documentation I found ...
Access to indicator and timeseries data is implemented irrespective of the fact whether the requested data are ready (the so called asynchronous access). This is critically important for the calculation of custom indicator, so if there are no data,
functions of Copy...() type immediately return an error. However, when accessing from Expert Advisors and scripts, several attempts to receive data are made in a small pause, which is aimed at providing some time necessary to download required
timeseries or to calculate indicator values.
Can you guide me, if an Indicator is calling an OOP class (not an EA or Script) and Copy...() type is located in such OOP class. Call to this Copy...() will be treated as from an Indicator OR from an EA/Script?
and hence if call is treated from an Indicator, your conclusion (So basically, the code is incompatible to indicators, as it is at the moment.) should held true.
I am trying to digest other clues from you and see any work around.
One more request, if you are aware of another article which handles such Organized Data Access for Indicators, you can point me to it.
I am also closing this thread with conclusion that checkLoadHistory() of article https://www.mql5.com/en/docs/series/timeseries_access is incompatible to indicators, as it is at the moment. I would like to request MQL Service Desk (@MQL-Services), to look into this and if possible provide and updated version.
Thanks a lot again and regards.
Thanks for clarifications :)
Forum on trading, automated trading systems and testing trading strategies
Help: array out of range, though in do...while loop I have tried to check error and exit
Alain Verleyen, 2024.01.31 16:09
You need to understand and deal, with the asynchronous nature of the data functions.
Using loop or sleep is a bad approach. When a data function returns -1 it (usually) means the data are not ready. The best approach is then to use events, either waiting the next tick, or forcing some events with a timer or custom event.
CheckLoadHistory() is useless, there is no need for an updated version. It could maybe be useful the first time you launch a program to collect data (but it's done automatically according to the requested data). Anyway, on indicators, which are using data from different timeframe or symbol as the current chart, EACH TIME you request data, it's ALWAYS possible the data are not ready. You NEED to deal with it, there is no shortcut, not miracle solution.
And I repeat : in indicators "Using loop or sleep is a bad approach".
You NEED to deal with it, there is no shortcut, not miracle solution.
Your message is loud and clear, I understood it very well. However, "You NEED to deal with it, there is no shortcut, not miracle solution." is where I need some guidelines as how to deal with it. Potential solution I found and thought would work was CheckLoadHistory(), but it has been proved to not useful.
I will try again tomorrow with fresh mind, now I am exhausted from whole days coding work.
Thanks for you suggestions.
Your message is loud and clear, I understood it very well. However, "You NEED to deal with it, there is no shortcut, not miracle solution." is where I need some guidelines as how to deal with it. Potential solution I found and thought would work was CheckLoadHistory(), but it has been proved to not useful.
I will try again tomorrow with fresh mind, now I am exhausted from whole days coding work.
Thanks for you suggestions.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear fellows
I am having hard time with CheckLoadHistory() of article https://www.mql5.com/en/docs/series/timeseries_access and seeking guidance here if any known issues with it or I am doing something wrong?
I am using following code to sync data and when I start the MQL Platform the indicator hangs out and I have to delete it. This causes error[-3] stopped by used.
When I attach indicate back and recompile the indicator, it starts working.
I have used following checkLoadHistory() with little bit modification to use it in a class (cATS) where class is initialized with mSymbol.