Delayed drawing and chart updating with MT5/MQL5 - page 2

 
Doerk Hilger: MT4 jumps back immediately without a tick. Anyway this is pretty much senseless to wait for the next tick ... I dont understand anyway why MQ stucks with this terrible outdated way of charting but thats another topic.

Yes, that is correct and I did not explain it very well in my previous post (I've updated it accordingly).

When using Zoom in MT4 it aligns (if Auto-Scroll is enabled) by the Right-Hand-Side (of the entire chart), but when Auto-Scroll is disabled, it aligns by the Left-Hand-Side (of the visible part).

In MT5 however, irrespective of whether Auto-Scroll is enabled or not, it always aligns by the Left-Hand-Side of the visible part (hence, why it will not update, until a tick arrives, if auto-scroll is enabled).

PS! As far as the MT5 functionality, I am unsure if it was always like this on if it is like this only now. I don't really remember how it was in the early builds.

However, in MT4 I am pretty sure it has been like that since I first started with it.
 

Getting back to the graphics issue. In the meanwhile I have some benchmarks and the comparison between Mt4 and MT5 is horrible. The main code is 1:1 the same, max 1 ChartRedraw within one ChartEvent, max one ChartRedraw during OnInit and creation of all objects:

1. Loading time: MT4 3 seconds, MT5 25 seconds!

2. OnChartEvent: MT4 creates approx 10 times more chartevents when the chart is resized (and bitmap objects are rebuilt) than MT5 does

3. Compilation time: MT4 2-3 seconds, MT5 1,5 minutes

Both platforms deal with the same code, it differs only in a few things which do not affect the benchmarks at all. Bot create <> 800 chart objects during load, 14 global vars and <> 1000 code objects. Both run on Windows 8.1. No part of the code freezes, every function simply takes much longer to execute with MT5.

I passed this data to MQ and wait for an answer.

 
Doerk Hilger:

Getting back to the graphics issue. In the meanwhile I have some benchmarks and the comparison between Mt4 and MT5 is horrible. The main code is 1:1 the same, max 1 ChartRedraw within one ChartEvent, max one ChartRedraw during OnInit and creation of all objects:

1. Loading time: MT4 3 seconds, MT5 25 seconds!

2. OnChartEvent: MT4 creates approx 10 times more chartevents when the chart is resized (and bitmap objects are rebuilt) than MT5 does

3. Compilation time: MT4 2-3 seconds, MT5 1,5 minutes

Both platforms deal with the same code, it differs only in a few things which do not affect the benchmarks at all. Bot create <> 800 chart objects during load, 14 global vars and <> 1000 code objects. Both run on Windows 8.1. No part of the code freezes, every function simply takes much longer to execute with MT5.

I passed this data to MQ and wait for an answer.

Is this "test code" that you used for the tests, something which can be shared and run by others to obtain some independent benchmarks or is this code part of some private project of yours?

It would be useful if others could run some tests as well to get an overall idea of the performance under different conditions and setups.

EDIT: One thing that did get discussed here before, but I cant remember the thread name, was the MT4 handles the Graphic Object function processing synchronously and that MT5 handles them asynchronously. The difference could require that it be handled differently in order to achieve the same or better performance on MT5. Handling them as if synchronously on MT5 might be the cause of the handicap.

 
Doerk Hilger:

Getting back to the graphics issue. In the meanwhile I have some benchmarks and the comparison between Mt4 and MT5 is horrible. The main code is 1:1 the same, max 1 ChartRedraw within one ChartEvent, max one ChartRedraw during OnInit and creation of all objects:

1. Loading time: MT4 3 seconds, MT5 25 seconds!

2. OnChartEvent: MT4 creates approx 10 times more chartevents when the chart is resized (and bitmap objects are rebuilt) than MT5 does

3. Compilation time: MT4 2-3 seconds, MT5 1,5 minutes

Both platforms deal with the same code, it differs only in a few things which do not affect the benchmarks at all. Bot create <> 800 chart objects during load, 14 global vars and <> 1000 code objects. Both run on Windows 8.1. No part of the code freezes, every function simply takes much longer to execute with MT5.

I passed this data to MQ and wait for an answer.

I dont have any issue like you comment. Anyways when you compile code in MT5 you have separate compilation and optimizing stage. Compile its exactly same than MT4 ( same code and speed compilation) Optimization is slower ( around 5/10 times). Evidently you shouldnt make optimization while are developing the tools 
 

In MT5, many functions are queued for execution.
For example, if you refuse to use "ObjectFind ()", the speed will grow at times.

Use Profiling to identify slow functions.
Debug -> Start Profiling 

 
Taras Slobodyanik:

In MT5, many functions are queued for execution.
For example, if you refuse to use "ObjectFind ()", the speed will grow at times.

Use Profiling to identify slow functions.
Debug -> Start Profiling 


I have my own benchmark measurements in the code and I know the bottlenecks. What you miss is the much higher speed with MT4, so the code is obviously not the problem. Its simply the fact that any function is simply executed much slower than in MT4 and in the end its the summary of it all. 

Fernando Carreiro:

Is this "test code" that you used for the tests, something which can be shared and run by others to obtain some independent benchmarks or is this code part of some private project of yours?

It would be useful if others could run some tests as well to get an overall idea of the performance under different conditions and setups.

EDIT: One thing that did get discussed here before, but I cant remember the thread name, was the MT4 handles the Graphic Object function processing synchronously and that MT5 handles them asynchronously. The difference could require that it be handled differently in order to achieve the same or better performance on MT5. Handling them as if synchronously on MT5 might be the cause of the handicap.

Yes, I recognized that. Well, I do my own async and collected chart updates because if I would not, solely the build-up time would be enough to have a cup of coffee in between :D ...  I tested it, its unbelievable ... And if MT5 does async updates like that, then it´s simply doing something pretty wrong. You know the project im talking bout, it´s not just a hand full of code lines, but MT5 should be able to deal with it at least as fast as MT4 does ... I have no clue at the moment what I could do more in view of optimization. 
 
Doerk Hilger: Yes, I recognized that. Well, I do my own async and collected chart updates because if I would not, solely the build-up time would be enough to have a cup of coffee in between :D ...  I tested it, its unbelievable ... And if MT5 does async updates like that, then it´s simply doing something pretty wrong. You know the project im talking bout, it´s not just a hand full of code lines, but MT5 should be able to deal with it at least as fast as MT4 does ... I have no clue at the moment what I could do more in view of optimization. 

Since most of my projects (my own and for customers) as mostly non-graphical, I have yet to run into the problems I am sure you must be facing.

Your porting of ST to MQL5 is severely handicapped by this and I don't blame you for being so frustrated with the MetaTrader 5. If I were in your position, I would be blowing smoke out of ears and cursing everything around me!

 

I have my own benchmark measurements in the code and I know the bottlenecks. What you miss is the much higher speed with MT4, so the code is obviously not the problem. Its simply the fact that any function is simply executed much slower than in MT4 and in the end its the summary of it all. 

I'm not telling you about your code, but about the features of MT5.
In MQL5, the function "ObjectFind ()" (and some others) is very slow.

What you missed is that I recommended you do Profiling and see it with your own eyes)

 

I do benchmarking with some macros. This is much more efficent to find bottlenecks because you get exact timings and surround the problem step by step. One should also keep in mind, that the code is really 1:1 between MT4 and MT5, its because I dont use any of the old MT4 functions and by this all code is almost 100% portable anyway.

 I mention this because in view of this, any profiling cannot tell me anything new, thats the problem. Maybe I call one million functions during startup, maybe more, I dont know, and when every functions takes some microseconds more, in the end its a million times these microseconds.

What I see is, that any function which results in mainly updating a bitmap or a chart object, takes much more time than before. And this makes no sense, because I dont update the chart itself more often than with MT4 and modify non-bitmap chart objects only while they are invisible.

I dont use Objectfind at all. Maybe you have some ideas more?
 
Fernando Carreiro:

Since most of my projects (my own and for customers) as mostly non-graphical, I have yet to run into the problems I am sure you must be facing.

Your porting of ST to MQL5 is severely handicapped by this and I don't blame you for being so frustrated with the MetaTrader 5. If I were in your position, I would be blowing smoke out of ears and cursing everything around me!

Blowing smoke through ears hurts. I try to avoid that ;)
Reason: