Loading OnChartEvent() function takes too much time in MT5.

 
Hello everyone, I've created a sophisticated trade panel in MT5 using some of MT5 panel libraries, the issue is when I change between timeframes, none of panel buttons work before 15-17 secs, I found out that OnChartEvernt() function is not called before 15-17 secs. but I have no solution for that, does anyone have any solution. Thank you very much for your kind responses. (attach is a picture of the panel)
Files:
MT5_Panel.png  108 kb
 
Fatemeh Ameri:
Hello everyone, I've created a sophisticated trade panel in MT5 using some of MT5 panel libraries, the issue is when I change between timeframes, none of panel buttons work before 15-17 secs, I found out that OnChartEvernt() function is not called before 15-17 secs. but I have no solution for that, does anyone have any solution. Thank you very much for your kind responses. (attach is a picture of the panel)

Start in the Editor the Profiling (Debug => Start Profiling ...).

There you can see the 'eaters' of performance.

 
Fatemeh Ameri:
Hello everyone, I've created a sophisticated trade panel in MT5 using some of MT5 panel libraries, the issue is when I change between timeframes, none of panel buttons work before 15-17 secs, I found out that OnChartEvernt() function is not called before 15-17 secs. but I have no solution for that, does anyone have any solution. Thank you very much for your kind responses. (attach is a picture of the panel)

Have you used the profiler to figure out where the bottlenecks could be?

 
Fatemeh Ameri the issue is when I change between timeframes, none of panel buttons work before 15-17 secs,
  1. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem


  2. Perhaps a call of ChartRedraw

 
Fatemeh Ameri:
Hello everyone, I've created a sophisticated trade panel in MT5 using some of MT5 panel libraries, the issue is when I change between timeframes, none of panel buttons work before 15-17 secs, I found out that OnChartEvernt() function is not called before 15-17 secs. but I have no solution for that, does anyone have any solution. Thank you very much for your kind responses. (attach is a picture of the panel)
Probably your program is busy processing something else.

Put a printf statement at top and before every return of the main handlers and see where your program is stuck.

Handlers like OnInit, OnCalculate, onTick, dep nding on the type of program...

I am almost certain, you are stuck in some other handler.


 
Carl Schreiber #:

Start in the Editor the Profiling (Debug => Start Profiling ...).

There you can see the 'eaters' of performance.

I try that, but I failed. Profiler shows that some main functions like OnChartEvernt() are time consuming. Cannot get much out of that information.

 
William Roeder #:
  1. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem


  2. Perhaps a call of ChartRedraw

1. man, I cannot post 20000 of code lines in 10 mql files here even if I want to.
2, ChartRedraw() does not solve this problem, I tried, it happens only when I change time frame.

 
Dominik Christian Egert #:
Probably your program is busy processing something else.

Put a printf statement at top and before every return of the main handlers and see where your program is stuck.

Handlers like OnInit, OnCalculate, onTick, dep nding on the type of program...

I am almost certain, you are stuck in some other handler.


Actually I know that the issue is certainly  OnChartEvernt() function, I have a lot of code lines in my  OnChartEvernt() function and the dashboard has many objects, when I reduce number of objects the it takes less time to load the panel on new chart when I change time frame. however I have no solution to make it faster with the existing number of objects.

 
Fatemeh Ameri #: . however I have no solution to make it faster with the existing number of objects.

And without your handler code we can't guess. Use the profiler.

 
Fatemeh Ameri #:

1. man, I cannot post 20000 of code lines in 10 mql files here even if I want to.
2, ChartRedraw() does not solve this problem, I tried, it happens only when I change time frame.

You can zip and attach them.

 
Fatemeh Ameri #:

Actually I know that the issue is certainly  OnChartEvernt() function, I have a lot of code lines in my  OnChartEvernt() function and the dashboard has many objects, when I reduce number of objects the it takes less time to load the panel on new chart when I change time frame. however I have no solution to make it faster with the existing number of objects.

If you are doing ChartGet* calls, or ObjectGet* calls, it's most probably them.

What you could do is, put a bunch of printf statements into the function and see how far it has come in the log.

Also, you should not assume, because as long as you don't >know< the cause, you cannot make any appropriate changes.

So, let's say, it's the creation of the objects, then you could try and keep the objects on chart, and (I suppose you are using an indicator) pick them up again in the OnInit call.

To do so, you would need to save a "state" in a global variable and check for that in the OnInit.

In OnDeinit you have to check for the reason, so that you know what to do. (Remove or keep the objects)

If it's an issue with ChartGet, overwrite the function and build your own cached version to use. (that's what I did)

If it's ObjectGet, then don't call it, store the values you are trying to read in some other solution. (As you most probably have set the value somewhere earlier with ObjectSet)

As you can see, there are multiple possible solutions.

As a hint, use GetMicroseconds() to measure your codes performance, it's much more clear to you than using the profiler.