Loading objects in MT5 takes a lot of time. - page 2

 
Dominik Christian Egert #:
One thing you could check that comes to mind is, are you creating objects and then accessing/reading some of their values with ObjectGet*() ?

If so, try checking if you could go without querying them. Reason is, an ObjectCreate will get queued in a queue for asynchronous processing. So the ObjectGet needs to wait for all abjects to be created first.

If that's not the issue, then try figuring out where the code is stalling by using GetMicrosecondcount() and print out the time every command needs.

This way you can find the bottlenecks and work your way around them.

Btw, I found out, sometimes ChartGet*() takes a long time to return, somewhat 200ms or more.

So also this could hinder your performance.

Thank you for your great suggestions.

 
Lorentzos Roussos #:

Nice work .

What Dominik said , you might be checking their size , try alternatives like TextGetSize etc , usually you would querry for font fitting or positioning .

Or comment out all the read operations .

Does this controls library have a "render" function of some sort ?

Can you hide them upon creation ? and show them all at once at the end ?

How many objects are there , i will try to recreate the issue . 

Comment out the equivalent of this in your version 

Thanks for your response and good ideas. I tested all of them.

I had some functions in my OnChartEvent function that starts with "if(id==CHARTEVENT_MOUSE_MOVE)" without any other condition to check, Those functions were the source of problem, now when I put the panel on the chart the speed of loading is very fast, but the issue still remains when I change timeframe of the chart. when I change the chart time frame, loading of my panel takes about 10 seconds, still struggling with this problem and cannot find the issue.

 
What does the EA do when you change the timeframe?

Shouldn't my suggestion, collecting performance times, also be able to identify the issue?

EAs do not get reloaded when Timeframe of chart changes. (Learned that just recently)
 
Dominik Christian Egert #:

EAs do not get reloaded when Timeframe of chart changes. (Learned that just recently)

Just to add, in case it confuses anyone. EAs are not re-loaded, but they are re-initialised when changing the chart time-frame.

 
Dominik Christian Egert #:
What does the EA do when you change the timeframe?

Shouldn't my suggestion, collecting performance times, also be able to identify the issue?

EAs do not get reloaded when Timeframe of chart changes. (Learned that just recently)

When time frame changes, the dashboard removes from the chart and initialize again, this dashboard is created using "Dialog.mqh". when time frame changes lot of objects on the chart will be deleted and re created again as the OnDeinit() and OnInit() is executed. 
The wired issue is when I put the dashobard on the fresh chart, it starts instantly with no delay, but when I change timeframe the dashboard is shown, however It is freezes for 10-12 seconds, no button works before that.

 
Fatemeh Ameri #:

Thanks for your response and good ideas. I tested all of them.

I had some functions in my OnChartEvent function that starts with "if(id==CHARTEVENT_MOUSE_MOVE)" without any other condition to check, Those functions were the source of problem, now when I put the panel on the chart the speed of loading is very fast, but the issue still remains when I change timeframe of the chart. when I change the chart time frame, loading of my panel takes about 10 seconds, still struggling with this problem and cannot find the issue.

Gate the Events Execution 

Set 2 Variables on the global scope (of the ea) "DeckReady=false,SystemBusy=true;"

Set DeckReady to false on top of OnInit and  on topof DeInit .

Set SystemBusy to false before return(INIT_SUCCEEDED) in OnInit and to true on top of DeInit

When the deck is designed set DeckReady to true 

place an

if(DeckReady&&!SystemBusy){
SystemBusy=true;
//anything in OnChart Event goes in here 

SystemBusy=false;}

with all the OnChartEvent code within the brackets 

 

This is a MT5 platform issue. Read manual about ObjectCreate in MT4 and MT5.\

MT4:

ObjectCreate

Return Value

When the function is used on the current chart, the chart is accessed directly (a usual behavior in MQL4), and the return of true means a successful creation of an object; otherwise false is returned. In this case, you should call GetLastError() for further information about the error.

To create objects on a different size, an asynchronous function call is used, and ObjectCreate() only returns the result of command adding to the chart queue.


MT5:

ObjectCreate

Note

An asynchronous call is always used for ObjectCreate(), that is why the function only returns the results of adding the command to a chart queue. In this case, true only means that the command has been successfully enqueued, but the result of its execution is unknown.


MetaQuotes should solve this problem.

I have the same issue. This MT5 so called "fast platform" read my objects (dozens of thousands) on 49 charts in 20 munutes.  MT4 platform read id in 20 seconds.

THANK YOU METAQUOTES.... AND WHEN YOU ADD A FUNCTION TO FREE MEMORY FROM UNWANTED SYMBOLS PRICE HISTORY !!!!??????