ChartGetInteger() - delayed execution of up to 100ms - Bug? - page 2

 

With the help of @Nikolai Semko and some others, we were finally able to get Metaquotes attention on this issue. They are fixing it and investigating for similar bottlenecks.

Forum on trading, automated trading systems and testing trading strategies

Errors, bugs, questions

MetaQuotes , 06/20/15 18:32

We will upgrade access to the charts, this is our flaw.

Also launched a full audit of all similar places.


 

Forum on trading, automated trading systems and testing trading strategies

Errors, bugs, questions

Renat Fatkhullin , 2020/06/18 00:35

In beta 2494, ChartGetXXXXX features dramatically accelerated.

Now executed in 1-2 microseconds instead of milliseconds. But if the chart constantly receives later events / changes, then the read commands are still forced to wait for synchronization.

 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
 

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. 

 
@Doerk Hilger #:

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. 

The MetaQuotes' admin and developers seem to pay more attention to threads on the Russian forum than the English one. Maybe you can discuss it there to get more feedback.
 

I don't speak russian and would need Deep.L, don't think its very useful in such cases. 

"Pay more attention" - fact is rather, MetaQuotes ignores this forum at all since months. Totally frustrating. 

I collect all the data within the EA now and send it to the indicators via a pipe. Problem "solved", unfortunately only for me, not anyone else who will encounter weird problems without any logical reason. We were searching, testing and tracking this issue for days on countless machines. 

 
Doerk Hilger #:

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. 

I advise you to use my library, which I mainly created in order to bypass the asynchrony of the functions you mentioned. This library uses these functions only at the time of the chart change event and remembers them, and then uses its own coordinate transformation functions that work thousands of times faster.

https://www.mql5.com/ru/code/22164

https://www.mql5.com/en/code/23840

last ver 1.47

Easy Canvas
Easy Canvas
  • www.mql5.com
Данная библиотека и класс iCanvas упростит написание программ с применением Canvas.
 
Doerk Hilger #: I don't speak russian and would need Deep.L, don't think its very useful in such cases. 
I don't either, but with the help of Google translation I have been able to resolve a few minor issues there before.
 
Nikolai Semko #:

I advise you to use my library, which I mainly created in order to bypass the asynchrony of the functions you mentioned. This library uses these functions only at the time of the chart change event and remembers them, and then uses its own coordinate transformation functions that work thousands of times faster.

https://www.mql5.com/ru/code/22164

https://www.mql5.com/en/code/23840

last ver 1.47

Pretty interesting. But, the problem occurs exactly and mainly with OnChartChange(), when both, EA and indicator obtain the metrics. As soon as I avoid handling OnChartEvent() within the indicator, the problem is 99,9% gone. This is why I read the data only in the EA and send the metrics to the indicator. I also buffer the data and do my own calculations, but only for the Y axis - you are right, it is just very much faster than the MQL functions.

But ... what I would be mainly interested in, is some own functions to calculate the X axis. Is this extractable separately? I would also pay for a solution if you could offer such, of course. 

Nevertheless, I will have a deeper look at your library. Thank you!

 
@Doerk Hilger #:Pretty interesting. But, the problem occurs exactly and mainly with OnChartChange(), when both, EA and indicator obtain the metrics. As soon as I avoid handling OnChartEvent() within the indicator, the problem is 99,9% gone. This is why I read the data only in the EA and send the metrics to the indicator. I also buffer the data and do my own calculations, but only for the Y axis - you are right, it is just very much faster than the MQL functions. But ... what I would be mainly interested in, is some own functions to calculate the X axis. Is this extractable separately? I would also pay for a solution if you could offer such, of course. 

Nevertheless, I will have a deeper look at your library. Thank you!

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.