iCustom Call Speed

 

Hello Everyone

I'm working on a project right now using data from four custom indicators on 9 timeframes in mql4. Currently I make use of the iCustom function to get data from necessary buffers and bar indexes. As you can imagine, I have over 60 iCustom calls and its slowing down processing considerably. Is there a better way to optimize my indicator calls for speed?

 
Joshua Malomo: Hello Everyone

I'm working on a project right now using data from four custom indicators on 9 timeframes in mql4. Currently I make use of the iCustom function to get data from necessary buffers and bar indexes. As you can imagine, I have over 60 iCustom calls and its slowing down processing considerably. Is there a better way to optimize my indicator calls for speed?

Yes! Only read the data when a new bar forms on that particular time frame, and cache the data so that you don't have to call the iCustom function again later.

Also, pay careful attention to how the indicator calculates its values. You may devise a more efficient way of calculating the data in combination over the various time-frames.

 
Yeah like already mention and there's room for improment I run with more than 500 Custom calls at same time.(mtf signal indicator)
 

Several calls are not a problem as long as indicators works efficiently by itself.

For sure good improovements can be:

1 - make indicator calculates only last closed candle and not every tick.

2 - set a 'max history' bars to calculate to reduce the calculations.


Point 2 can be done without problems almost always, point 1 depends on your indicator.


PS. You are talking about using a lot of calls and on several timeframes and you are still on MT4. You should consider to move to MT5, where the process is a long way better (indicator handles initialized at EA startup and then you just copy buffers of indicators)

 
Fernando Carreiro #:

Yes! Only read the data when a new bar forms on that particular time frame, and cache the data so that you don't have to call the iCustom function again later.

Also, pay careful attention to how the indicator calculates its values. You may devise a more efficient way of calculating the data in combination over the various time-frames.

Thanks so much Fernando! I already cache the data every new 1M but you’re totally right in that there are better ways to process the indicator values rather than relying on buffers completely. Cheers!
 
Fabio Cavalloni #:

Several calls are not a problem as long as indicators works efficiently by itself.

For sure good improovements can be:

1 - make indicator calculates only last closed candle and not every tick.

2 - set a 'max history' bars to calculate to reduce the calculations.


Point 2 can be done without problems almost always, point 1 depends on your indicator.


PS. You are talking about using a lot of calls and on several timeframes and you are still on MT4. You should consider to move to MT5, where the process is a long way better (indicator handles initialized at EA startup and then you just copy buffers of indicators)

Hi Fabio! Thanks for your suggestions. That’s a good point with Max History Bars. Thing is I can’t exactly tell every user to change their max history setting. But it’s a good idea for optimization.

I did look into migrating to mql5 since I could just copy buffers and access the entire time series but the source codes of some of the indicators I make use of are pretty archaic. I tried conversion but ran into some pretty bad logical errors. I’ll definitely port over when I get some insight with the indicators though. Thanks for your help. Cheers!
 
Joshua Malomo #:
Hi Fabio! Thanks for your suggestions. That’s a good point with Max History Bars. Thing is I can’t exactly tell every user to change their max history setting. But it’s a good idea for optimization.

I did look into migrating to mql5 since I could just copy buffers and access the entire time series but the source codes of some of the indicators I make use of are pretty archaic. I tried conversion but ran into some pretty bad logical errors. I’ll definitely port over when I get some insight with the indicators though. Thanks for your help. Cheers!
'Max history bars' I intended to code a similar variable for reduce the max number of calcualtions bars inside the indicator itself.

Most of time, especially inside EA, it's useless that indicator calculates itself for all bars but it's enough doing it for few bars