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?

 

A few years ago, I found a very strange phenomenon in the process of writing MT5 indicators ->>

Let me first talk about my code entry process:

1. The refresh of controls written by MT5 will flicker. When I started writing the trading assistant panel, I found that when I used the CANVAS sketchpad to refresh the display content of the controls, MT4 responded very quickly and did not feel refreshed, but MT5 There will be a flickering process, and it is obvious to see the white screen time of the control with an interval of 0. a few seconds

2. I made a ZIGZAG indicator with a very complex algorithm. Like 1, I will make two different MT4 and MT5 versions with the same function and display, which means that for users, they use the same function But this problem happened to trouble me for several years, because the buyers of the MT5 version of this indicator basically did not give me feedback on this problem, even if I found this problem myself, but because of my debugging results, it may be caused by MT5. When the data is loaded into the indicator buffer of ZIGZAG, it will keep blinking

3. When it comes to the flickering problem of the 2-point indicator, the flickering at that time was just a flickering feeling, and there would not be a long white screen time, but now I find that with the update of MT5, the white screen gap is getting longer and longer -> (Note: I use DRAW_SECTION type BUFFER for 1 and 2), I have been in MT4 and MT5 programming for more than ten years, but I have not seen the progress of MT5 in these years, but I am a BUG maker. The flickering problem alone , the same code logic, the code operation can perfectly render the effect in MT4, but MT5 just can’t, although I feel that this may be a problem with the graphics rendering logic of MT5, does it also mean that MT5 is doing too poorly in this aspect?

The indicator flickers seriously. The gif picture is as follows. Not only does it flicker, but it will also be white for a long time without rendering.

闪烁问题1

Friends who have experience in writing code indicators can discuss how you are writing ZIGZAG-like codes in MT5. Recently, I may spend some time and energy trying to optimize the ZIGZAG-like indicators in a different way from MT4. Energetic friends can come to discuss and discuss. I hope that the official programmers of MQL5 can pay attention to it. Please do not affect the user experience when developing MT5. The same indicators are also adapted to MT5 after writing, because the rendering problem of MT5 We pulled our legs.


Regarding the problem of refreshing the white screen of the control data I encountered at point 1, I solved it in this way later: I added a logical judgment before refreshing the display of the control, first judging that the data has changed, and then refreshing the content on the Bitmap_label.... Although this cannot be eradicated, it can basically reject invalid flickering. Other similar writings are solved in this way.

OBJ_BITMAP_LABEL


I hope that the post will be popular, so that MQL5 official programmers can also see it. After all, MT5 has been used and found that although many improvements have been made to indicators such as color filling, such as color-changing line support, it is better than MT4. But in terms of graphics rendering ( I can only attribute it to the fact that you have different rendering logics for indicator buffers) In the K-line data refresh logic of MT5, it is a BUG manufacturing machine, because I have seen this flickering problem for two or three years in my waiting It is getting more and more serious, under the premise that the code remains unchanged.

You are also welcome to guide me, how to write the ZIGZAG indicator of MT5 and the experience of MT4 are the same.


闪烁2 

 
Kaijun Wang:

A few years ago, I found a very strange phenomenon in the process of writing MT5 indicators ->>

Let me first talk about my code entry process:

1. The refresh of controls written by MT5 will flicker. When I started writing the trading assistant panel, I found that when I used the CANVAS sketchpad to refresh the display content of the controls, MT4 responded very quickly and did not feel refreshed, but MT5 There will be a flickering process, and it is obvious to see the white screen time of the control with an interval of 0. a few seconds

2. I made a ZIGZAG indicator with a very complex algorithm. Like 1, I will make two different MT4 and MT5 versions with the same function and display, which means that for users, they use the same function But this problem happened to trouble me for several years, because the buyers of the MT5 version of this indicator basically did not give me feedback on this problem, even if I found this problem myself, but because of my debugging results, it may be caused by MT5. When the data is loaded into the indicator buffer of ZIGZAG, it will keep blinking

3. When it comes to the flickering problem of the 2-point indicator, the flickering at that time was just a flickering feeling, and there would not be a long white screen time, but now I find that with the update of MT5, the white screen gap is getting longer and longer -> (Note: I use DRAW_SECTION type BUFFER for 1 and 2), I have been in MT4 and MT5 programming for more than ten years, but I have not seen the progress of MT5 in these years, but I am a BUG maker. The flickering problem alone , the same code logic, the code operation can perfectly render the effect in MT4, but MT5 just can’t, although I feel that this may be a problem with the graphics rendering logic of MT5, does it also mean that MT5 is doing too poorly in this aspect?

The indicator flickers seriously. The gif picture is as follows. Not only does it flicker, but it will also be white for a long time without rendering.


Friends who have experience in writing code indicators can discuss how you are writing ZIGZAG-like codes in MT5. Recently, I may spend some time and energy trying to optimize the ZIGZAG-like indicators in a different way from MT4. Energetic friends can come to discuss and discuss. I hope that the official programmers of MQL5 can pay attention to it. Please do not affect the user experience when developing MT5. The same indicators are also adapted to MT5 after writing, because the rendering problem of MT5 We pulled our legs.


Regarding the problem of refreshing the white screen of the control data I encountered at point 1, I solved it in this way later: I added a logical judgment before refreshing the display of the control, first judging that the data has changed, and then refreshing the content on the Bitmap_label.... Although this cannot be eradicated, it can basically reject invalid flickering. Other similar writings are solved in this way.

OBJ_BITMAP_LABEL


I hope that the post will be popular, so that MQL5 official programmers can also see it. After all, MT5 has been used and found that although many improvements have been made to indicators such as color filling, such as color-changing line support, it is better than MT4. But in terms of graphics rendering ( I can only attribute it to the fact that you have different rendering logics for indicator buffers) In the K-line data refresh logic of MT5, it is a BUG manufacturing machine, because I have seen this flickering problem for two or three years in my waiting It is getting more and more serious, under the premise that the code remains unchanged.

You are also welcome to guide me, how to write the ZIGZAG indicator of MT5 and the experience of MT4 are the same.


 

Yes, the solution for me was to transfer the code of ZigZag to OnTimer function and set EventSetMillisecondTimer(200)

 
In the process of writing many MT4 and MT5 indicators, there is still a pitfall:
If you use ArraySetAsSeries(BuffXXX,true) to write indicators in MT5 to set the same K-line sequence logic code as MT4, if the code is free of any errors, MT5 may have data confusion and indicators display abnormally.
The solution at this time is to use the sequence logic of MT5 to rewrite a copy, so that there will be no more problems with confusing indicators on the chart.
And from 10 years to the present, MT5 provides similar data acquisition logic as MT4 in many places, but there are many bugs. In fact, for our experienced developers, the logic of MT4 and MT5 itself is easy to adapt to. , but it is not enough to adapt to the logic. Although MT5 has many places close to MT4, it cannot be adapted and still has BUG...
You can talk about other various BUGs and solutions encountered in MT5. If necessary, I can also help you solve some problems you encounter, but some may only be solved by detours.
 
Arpit T #:

Yes, the solution for me was to transfer the code of ZigZag to OnTimer function and set EventSetMillisecondTimer(200)

I've tried your solution before and it didn't work.

Now I will try again and give you a reply.

 
Arpit T #:

Yes, the solution for me was to transfer the code of ZigZag to OnTimer function and set EventSetMillisecondTimer(200)

The forum is really amazing, I tried to solve it like this before...

But my main function is not only put on OnTimer(), but still put a copy in OnCalculate function, which made me miss this solution.

Thank you very much, very pleasantly surprised. I rarely come to the forum, and I feel lucky when I visit the forum for the first time.

Thank you very much ,bro.

 
Arpit T #:

Yes, the solution for me was to transfer the code of ZigZag to OnTimer function and set EventSetMillisecondTimer(200)

For this I tried various optimizations, tried many different multi-buffer filling schemes and various optimizations....

 

Strange!

I don't have any flickering on my own ZigZag indicators, which are coded for both MQL4 and MQL5.

I also don't see any flickering with the MetaQuotes supplied ZigZag indicators either.

 
Fernando Carreiro #:

Strange!

I don't have any flickering on my own ZigZag indicators, which are coded for both MQL4 and MQL5.

I also don't see any flickering with the MetaQuotes supplied ZigZag indicators either.

Yes, it seems that there is no problem in the case of a small amount of data. But as the content in the OnCalculate () function increases, it will flicker like this.

I am using the 1# scheme now, OnCalculate does not put the content, and now ZIGZAG is no longer flashing after using OnTimer.

In addition, the problem of flickering on MT5 and MT4 still exists on BITMAP, and there will be a rendering time for refreshing data.

 
Fernando Carreiro #:

Strange!

I don't have any flickering on my own ZigZag indicators, which are coded for both MQL4 and MQL5.

I also don't see any flickering with the MetaQuotes supplied ZigZag indicators either.

Maybe OnCalculate() has a problem of redrawing and rendering logic for DRAW_SECTION BUFFER. This must be different from MT4, otherwise it will not cause this problem.

 
Kaijun Wang #: Yes, it seems that there is no problem in the case of a small amount of data. But as the content in the OnCalculate () function increases, it will flicker like this. I am using the 1# scheme now, OnCalculate does not put the content, and now ZIGZAG is no longer flashing after using OnTimer. In addition, the problem of flickering on MT5 and MT4 still exists on BITMAP, and there will be a rendering time for refreshing data.

I have my charts at maximum number of bars and calculate the buffers for every single bar.

I have never had any flickering on MT4 or MT5 ever.

It seems that maybe something in your code is the cause. Maybe it is recalculating buffers on each call instead of only updating the changes.

Without seeing your code, it will be difficult to offer any advice.

 
Kaijun Wang #: Maybe OnCalculate() has a problem of redrawing and rendering logic for DRAW_SECTION BUFFER. This must be different from MT4, otherwise it will not cause this problem.
I use DRAW_SECTION on many of my indicators, and I have no such issue (MT4 or MT5).
Reason: