![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
From your explanation, it seems to be a race condition — it seems that MetaQuotes never properly considered nor implemented the possibility of the OnChartEvent() being handled on separate threads.
I say this because all the Indicators on the chart share the same thread, but not the EA which is on a separate thread. It seems that OnChartEvent() can only be used on one thread at a time to prevent clashing with each other.
Maybe you could consider reversing your logic, and doing all the "graphics" and chart event handling in a special "slave indicator" and have the EA interchange data with that indicator instead of the other way.
In this way, multiple Indicators can use the the OnChartEvent() without clashing with the EA.
Since this only occurs when the chart changes, I think I can avoid this bunch of work.
OnChartEvent(), e.g .for buttons, mouse-hover effects etc. ist in use since years and never made any problems. But for that I have already a way round by simply reading the data by using original Windows functions within a timer and simulate OnChartEvent(). This method is used for having chart-events with MT4 when operating in the tester, but just one switch and it is in use always. I always avoided .DLL functions as good as possible, but in the meanwhile I ask myself why, the EA will never be available at the MQL Market Place I guess ...
From your explanation, it seems to be a race condition — it seems that MetaQuotes never properly considered nor implemented the possibility of the OnChartEvent() being handled on separate threads.
I say this because all the Indicators on the chart share the same thread, but not the EA which is on a separate thread. It seems that OnChartEvent() can only be used on one thread at a time to prevent clashing with each other.
Maybe you could consider reversing your logic, and doing all the "graphics" and chart event handling in a special "slave indicator" and have the EA interchange data with that indicator instead of the other way.
In this way, multiple Indicators can use the the OnChartEvent() without clashing with the EA.
Disagree.
I have already come to the conclusion that it is necessary to minimize the use of indicators whenever possible. The EA should not have any iCustom, iMa, etc. To increase the overall performance, all calculations should take place inside the EA. Of course, provided that the programmer takes care of the priority of trading functions. There are many reasons for this, one of which is that the asynchronous ChartGet functions, etc. work much faster in Expert Advisors, and the timer in EA, unlike indicators, is independent of OnChartEvent.
Yes, I agree that for efficiency one should not depend on Indicators.
However, my suggestion was because I know how @Doerk Hilger's project works and how it has an EA component and an Indicator component ALWAYS. It was designed that way.
There are probably other ways to resolve the issue from the user's side, but it is just frustrating that MetaQuotes' software has so many unresolved bugs.
There are probably other ways to resolve the issue from the user's side, but it is just frustrating that MetaQuotes' software has so many unresolved bugs.
This topic needs to be brought to the top again.
All Chart-Functions, such as ChartGetInteger() but also ChartTimePriceToXY() and ChartXYToTimePrice() have still serious issues. Sometimes the functions return false but without that GetLastError() shows anything. Sometimes, especially when heavily used within an Indicator and and EA on the same chart, the execution time of the functions is at 4-5 Seconds. Needless to say, that a usage 10 times in a row just freezes everything. Same time, when this happens, ObjectGetInteger() shows the same effect, but only when using the 3-Params Version, not when 5-Params-Version is used. Pretty weird, but true and reproducible on demand.
Funfact: I can only reproduce it with VPS and VMs, not on regular machines or dedicated servers, no matter how much I stress CPU and/or RAM, has nothing to do with it. On a VPS, it happens immediately, but ONLY when both, Indicator and EA use the same chart and the same functions. Actually it should be possible to write a sample code, but before I do, I wanna make sure that MetaQuotes will pay attention to it.
If you provide code to reproduce the issue I will check and make sure Metaquotes pay attention to it (without any guarantee it will success though).
PS: Better to write me in PM if you want a quicker answer.
If you provide code to reproduce the issue I will check and make sure Metaquotes pay attention to it (without any guarantee it will success though).
PS: Better to write me in PM if you want a quicker answer.
Thanks for offering your support and btw thanks for the life-sign via PM ... missed you kind of already ;)
Currently we solved the problem by creating a complex workaround and implementing all the calculations by ourselves, buffering all chart-properties and transferring them via a pipe to the indicators. All in all it costed weeks and I don't wanna waste more time on top. I guess, its not so difficult to create sample code, but I am not 100% sure that there are no further influences needed. MQL is a surprise box. Nearly daily I run into things which simply make no sense.
The biggest challenge is still, that it is impossible to debug many cases. Destructors and OnDeinit() are simply not executed always, sometimes yes, sometimes not. But who cares :)
But of course I appreciate your help and will come back to you next time directly, definitely.
Thank you.
Thanks for offering your support and btw thanks for the life-sign via PM ... missed you kind of already ;)
Currently we solved the problem by creating a complex workaround and implementing all the calculations by ourselves, buffering all chart-properties and transferring them via a pipe to the indicators. All in all it costed weeks and I don't wanna waste more time on top. I guess, its not so difficult to create sample code, but I am not 100% sure that there are no further influences needed. MQL is a surprise box. Nearly daily I run into things which simply make no sense.
The biggest challenge is still, that it is impossible to debug many cases. Destructors and OnDeinit() are simply not executed always, sometimes yes, sometimes not. But who cares :)
But of course I appreciate your help and will come back to you next time directly, definitely.
Thank you.
I understand.
I care, and I am interested by any issue which could be fixed (before I face it :-D). Of course only with code to reproduce the issue, as anyway, without it, there is no chance to get Metaquotes attention.
All the best.