Do you have a solution for the flickering problem encountered when writing ZIGZAG type indicators on MT5? Is it a logic problem for MT5 to render the indicator buffer? - page 8

 
Kaijun Wang #:


To begin with, you had to do a profiling of your indicator, and then you would have seen the weaknesses.

You have organized the deletion and creation of objects - text labels - in a very non-optimal way. Search features are very expensive.

Moreover, you use very expensive ChartGet functions in MT5 on every tick....



 
Alain Verleyen #:

Thanks for your collaboration.

Can you say what is your "Max bars in chart" ?

And your configuration ?


It seems that more than 90% of the memory is used, and it shows 0. Less than 1G, equal to 0.

As for the disk, it has not affected my use for the time being. The actual remaining 1.66G of the hard disk, generally I will clear the hard disk space when it cannot be used, because some chat software will accumulate a lot of pictures and videos.

The point is that I changed the code and basically solved this problem when the hardware conditions remained the same.

The computer configuration is low, and it is really easy to reproduce this problem. I fell asleep and saw that you have a new research direction. Enthusiastic friends began to find places in my code that require a lot of calculation.I can only say that the friend upstairs is in the wrong direction. It is not for you to find out where the amount of calculation in my code exceeds, but to reproduce the problem of ZIGZAG flickering caused by the increase in the complexity of indicator calculations.


 
Nikolai Semko #:


To begin with, you had to do a profiling of your indicator, and then you would have seen the weaknesses.

You have organized the deletion and creation of objects - text labels - in a very non-optimal way. Search features are very expensive.

Moreover, you use very expensive ChartGet functions in MT5 on every tick....



First of all, thank you for your analysis.

I know that ObjectFind and some built-in functions of Object will be much more computationally intensive than in MT4.

This is a DEMO code for you to reproduce ZIGZAG flickering, not to let you find out where the calculation is bloated.

Thank you for your enthusiasm first, and then I say that your direction is wrong.

 
Kaijun Wang #:

First of all, thank you for your analysis.

I know that ObjectFind and some built-in functions of Object will be much more computationally intensive than in MT4.

This is a DEMO code for you to reproduce ZIGZAG flickering, not to let you find out where the calculation is bloated.

Thank you for your enthusiasm first, and then I say that your direction is wrong.

?

 
Nikolai Semko #:

?

I'm not trying to solve the problem of this demo code, this is a code to reproduce the flickering for friends who question in the forum. I will update the code separately later, specifically for reproduction.

 
Nikolai Semko #:

?

Nikolai Semko #:


首先,您必须对指标进行分析,然后才能发现弱点。

您以非常不理想的方式组织了对象(文本标签)的删除和创建。搜索功能非常昂贵。

此外,您在 MT5 中的每个报价单上都使用非常昂贵的 ChartGet 函数......



Nikolai Semko #:


To begin with, you had to do a profiling of your indicator, and then you would have seen the weaknesses.

You have organized the deletion and creation of objects - text labels - in a very non-optimal way. Search features are very expensive.

Moreover, you use very expensive ChartGet functions in MT5 on every tick....



I just want to maintain my conclusion: the MT5 indicator ZIGZAG will flicker when the computing power is greater than a certain amount. Of course, it is also related to the performance of the computer. (As long as your computing power is strong enough, why do you consider performance? )

In the DEMO file I uploaded now, I put three layers of loops. On my computer, the indicator buffer DRAW_COLOR_ZIGZAG will flicker, but in the same indicator, DRAW_ARROW will not flicker. I just aim at Questioned, one of the problems raised in MT5 is that DRAW_COLOR_ZIGZAG and DRAW_SECTION will flicker during the rendering process, and others have not found this imagination for the time being. And these flickers do not exist in MT4. (Arrow is specially reserved as a flickering contrast, in When ZIGZAG flashes, Arrow doesn't flash).

At the same time, the functions obtained by ObjectFind and other OBjects have too much performance overhead in MT5, which I very much agree with. The last DEMO code was written by me a few years ago, and I didn’t find this problem when I wrote it. This is also MT5 Different from MT4, these commonly used object functions have little performance overhead on MT4, and programming is extremely expensive in MT5.

Files:
 
Kaijun Wang #:

I just want to maintain my conclusion: the MT5 indicator ZIGZAG will flicker when the computing power is greater than a certain amount. Of course, it is also related to the performance of the computer. (As long as your computing power is strong enough, why do you consider performance? )

In the DEMO file I uploaded now, I put three layers of loops. On my computer, the indicator buffer DRAW_COLOR_ZIGZAG will flicker, but in the same indicator, DRAW_ARROW will not flicker. I just aim at Questioned, one of the problems raised in MT5 is that DRAW_COLOR_ZIGZAG and DRAW_SECTION will flicker during the rendering process, and others have not found this imagination for the time being. And these flickers do not exist in MT4. (Arrow is specially reserved as a flickering contrast, in When ZIGZAG flashes, Arrow doesn't flash).

At the same time, the functions obtained by ObjectFind and other OBjects have too much performance overhead in MT5, which I very much agree with. The last DEMO code was written by me a few years ago, and I didn’t find this problem when I wrote it. This is also MT5 Different from MT4, these commonly used object functions have little performance overhead on MT4, and programming is extremely expensive in MT5.

This indicator does not use objects, so there is no flicker. The fact is that the creation and deletion of objects in MT5 lives its own separate life in an asynchronous flow, which you cannot control or even measure. That is why flickering is possible, since the display of objects on the screen and their redrawing occurs together with the main chart, and the chart can be redrawn spontaneously when the MT5 internal system decides to redraw the next batch of objects. Moreover, different objects that are formed at the same time can be displayed on the screen at different times with different frames.

You can read discussions on this topic in the Russian-speaking part of the forum:

https://www.mql5.com/ru/forum/364640/page6#comment_21291999
https://www.mql5.com/ru/forum/373748

The solution from my point of view to this problem is this: You can use objects when there are not many of them. But when there are hundreds or thousands of objects and you are actively using ObjectFind(), it is better to switch to one object - canvas. Everything is under your control in it and there can be no problems with the flickering of the chart. I recommend using my iCanvas library, which inherits from the CCanvas class and is much easier to work with and runs much faster due to the fact that it optimizes the excessive use of very expensive ChartGet functions... to convert price-time(bar) coordinates to pixel coordinates and back. By default after

#include <Canvas\iCanvas_CB.mqh>

already created one instance called Canvas, which has the size of the entire chart and whose dimensions automatically change when the chart is resized.

Files:
iCanvas_CB.mqh  58 kb
 
Nikolai Semko #:

This indicator does not use objects, so there is no flicker. The fact is that the creation and deletion of objects in MT5 lives its own separate life in an asynchronous flow, which you cannot control or even measure. That is why flickering is possible, since the display of objects on the screen and their redrawing occurs together with the main chart, and the chart can be redrawn spontaneously when the MT5 internal system decides to redraw the next batch of objects. Moreover, different objects that are formed at the same time can be displayed on the screen at different times with different frames.

You can read discussions on this topic in the Russian-speaking part of the forum:

https://www.mql5.com/ru/forum/364640/page6#comment_21291999
https://www.mql5.com/ru/forum/373748

The solution from my point of view to this problem is this: You can use objects when there are not many of them. But when there are hundreds or thousands of objects and you are actively using ObjectFind(), it is better to switch to one object - canvas. Everything is under your control in it and there can be no problems with the flickering of the chart. I recommend using my iCanvas library, which inherits from the CCanvas class and is much easier to work with and runs much faster due to the fact that it optimizes the excessive use of very expensive ChartGet functions... to convert price-time(bar) coordinates to pixel coordinates and back. By default after

already created one instance called Canvas, which has the size of the entire chart and whose dimensions automatically change when the chart is resized.

It doesn't have any Object but ZIGZAG still flickers on my computer (increased CPU consumption).

In fact, I am quite proficient in using the CANVAS library......................

First of all, I would like to thank you for your help and suggestions for improvement,

Again, I emphasize my concept -> this is the problem that the two buffers of SECTION and ZIGZAG will flicker, which may be caused by the different rendering logic of MT5.

Of course, these problems are more likely to occur on a computer with no graphics card and a lower configuration. Because there are many users of these indicators, a large part of which is a computer with poorer configuration. On a computer with the same performance, MT4 can be used without flickering, but MT5 is flickering, how does the experience feel for them?

 
Kaijun Wang #:

It doesn't have any Object but ZIGZAG still flickers on my computer (increased CPU consumption).

In fact, I am quite proficient in using the CANVAS library......................

First of all, I would like to thank you for your help and suggestions for improvement,

Again, I emphasize my concept -> this is the problem that the two buffers of SECTION and ZIGZAG will flicker, which may be caused by the different rendering logic of MT5.

Of course, these problems are more likely to occur on a computer with no graphics card and a lower configuration. Because there are many users of these indicators, a large part of which is a computer with poorer configuration. On a computer with the same performance, MT4 can be used without flickering, but MT5 is flickering, how does the experience feel for them?

Your processor is over 10 years old.
Because of this, there can be many surprises.
After all, modern processors have a much more extended set of commands that actively use the OS and applications.
Therefore, it is time for you to upgrade your hardware, especially if you are a developer and are trying to make money on it.

 
Nikolai Semko #:

Your processor is over 10 years old.
Because of this, there can be many surprises.
After all, modern processors have a much more extended set of commands that actively use the OS and applications.
Therefore, it is time for you to upgrade your hardware, especially if you are a developer and are trying to make money on it.

I just explained that ZIGZAG will flicker, and its own nature will flicker.

It is not like other indicator buffers, which do not flicker.

This is not my only computer, I already have 5 personal laptops, I just like to use this one to write MQL codes.

And I don't use MT5 in trading,

MT5 is not my usual trading software, it doesn't mean I can't see this problem.

At the same time, you are also a seller of products, and there are many customers who buy you, and many of them have computers that are not well configured, or their computers run a lot of programs, software, EA, etc. This would seriously bother them.

Of course I got around the trouble, but the trouble is still there, isn't it?