Performance implications of multiple chart object updating indicators on a chart

 

I'm new to MQL5/programming so forgive me in advance: In the process of modifying a clock indicator that gets updated in OnTimer() I found that I needed to do a ChartRedraw() in order to make sure it visually updated the label chart object in a timely manner.

This got me to thinking... if there's a chart with many indicators that each are constantly updating chart object properties, such as labels, is it possible that a lot of CPU resources are wasted having many indicators invoking chart redraws at close to the same time, rather than funneling all those redraw requests through a single timer/event? Or does MT5 already have some kind of gating mechanism?

Additionally, if the chart has hundreds of different objects visible, and even just 1 object is being modified, will ChartRedraw() end up using an equivalent amount of CPU as if all the objects were modified?

 
Max0r847:
ible that a lot of CPU re

OnTimer only works for EAs not indicators.

 
Yashar Seyyedin #:

OnTimer only works for EAs not indicators.

Of course not. OnTimer() works perfectly with indicators, except when invoked with iCustom().
 
Max0r847:

I'm new to MQL5/programming so forgive me in advance: In the process of modifying a clock indicator that gets updated in OnTimer() I found that I needed to do a ChartRedraw() in order to make sure it visually updated the label chart object in a timely manner.

This got me to thinking... if there's a chart with many indicators that each are constantly updating chart object properties, such as labels, is it possible that a lot of CPU resources are wasted having many indicators invoking chart redraws at close to the same time, rather than funneling all those redraw requests through a single timer/event? Or does MT5 already have some kind of gating mechanism?

Additionally, if the chart has hundreds of different objects visible, and even just 1 object is being modified, will ChartRedraw() end up using an equivalent amount of CPU as if all the objects were modified?

This is managed by the platform. Please read the documentation attentively (well I see know that the ChartRedraw() documentation itself is reduced.

See https://www.mql5.com/en/docs/constants/objectconstants/enum_object_property


 
Alain Verleyen #:

This is managed by the platform. Please read the documentation attentively (well I see know that the ChartRedraw() documentation itself is reduced.

See https://www.mql5.com/en/docs/constants/objectconstants/enum_object_property


I wish I had waited until I read that to ask, because it definitely answered part of the question and I found it later. I wouldn't be surprised if I have partially read that article a couple times before and completely forgotten about that detail, as I have a tendency to do.

I suppose the only question I have left might be what would be different in terms of CPU usage (only for the visual update, not the property changes) between the following scenarios all involving a chart with 1000 visible objects.

1. Only 1 object is changed, and a new quote arrives, invoking a visual update.

2. All 1000 objects have changes applied, and a new quote arrives.

3. Only 1 object is changed, a ChartRedraw() is invoked to visually update it.

4. All 1000 objects have changes applied, and a ChartRedraw() is invoked.

But I'll find out the hard way eventually :D

Reason: