I've thought about it a while and I've acknowledged the possibility that maybe I'm the stupid one here. Throughout the docs it is mentioned that some functions such as CopyBuffer act asynchronously and simply fail (return -1) if the resource is not ready. If my understanding is correct, if the programmer wants it to behave like a synchronous call then he has to write a loop with a bunch of Sleep(...) calls.
The thing is, though, none of this seems to be mentioned in the documentation about graphical objects and charts. Of course there are mentions of some function calls being added on some sort of queue, but nowhere is it mentioned that functions like ChartIndicatorDelete would benefit from a synchronous adaptation.
The thing is, though, none of this seems to be mentioned in the documentation about graphical objects and charts. Of course there are mentions of some function calls being added on some sort of queue, but nowhere is it mentioned that functions like ChartIndicatorDelete would benefit from a synchronous adaptation.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Calling "Comment" and "ChartRedraw" directly before "ChartIndicatorDelete" causes it to fail with Error Code 4022 (ERR_PROGRAM_STOPPED)
After countless hours of work and hunting I finally managed to pinpoint the problem and come up with a precise minimalist code demonstration of the bug.
"AssertError" here is simply a macro that checks if the function returned false (which means it failed) and automatically alerts the last error. (It doesn't require a semicolon).
The following error will always occur: Error Code 4022: "Test forcibly stopped from the outside. For example, optimization interrupted, visual testing window closed or testing agent stopped"
The build that I ran this on is 5179. The error occurs regardless of compiler optimizations.
Interestingly enough, trying to run the code in debug mode by stepping and placing a breakpoint at ChartRedraw() seems to completely prevent the error. This makes it seem to me like it might be a race condition inside the MQL5 API.
Here is the full EA code that demonstrates this behavior.
GetErrorDescription is obviously simply a long function that associates each error code with a string description. Would've been too long to include it in the same file. You can replace it with a dummy function on your end.