Read time for the iCustom function

 

Hi All,

I'm trying to develop my own indicator (MyIndicator) by using the iCustom function to read three values from a third-party custom indicator.

Originally I was trying to calculate a value for MyIndicator for all bars in the sample window (GBPUSD Daily ~65K bars). But each time I ran MyIndicator, my MT4 session stopped responding. I then started to reduce the number (N) of bars to be analysed, and also placed a trace Alert command either side of the iCustom function being used to populate a double variable. The Alert shows the system time immediately before, and immediately after the read of N bars.

What I've found is that the fastest that I can make the system populate this double variable is 0.45 seconds elapsed time (actually measured by performing 100 reads in 45 seconds using a "for" statement). So obviously, getting such a loop to execute over 65K bars is going to take a v e r y long time, and would make such an indicator completely ineffective. Also of course, after the iCustom function, there is other logic required to calculate the value of MyIndicator, so that would make the indicator's execution time even worse.

Does anyone out there know how I can better use the iCustom function so that I can process an acceptable number of bars (min of about 10K) within a few seconds of starting up the MyIndicator? If not, is there a way that I can put the required logic into a Script, which could then calculate all the values of MyIndicator, and save these values to a file on my local storage, so that they remain instantly available each time MyIndicator starts up?

Any help would be greatly appreciated, thanks.

 

A) see if equivalent functionality can be provided WITHOUT using an external / iCustom function (do you have source? is there source for something similar?)

B) disk caching is an option. I suggest a database solution (xBase or SQL), but CSV blocks (e.g. one file per month per pair per timeframe) could work too. Be careful about caching of partial periods!

C) to help reverse engineer 3rd party indicators (should I be mentioning this?) I have created (using unused stock symbols) several series of prices (e.g. spike, step, ramp, waves, parabola) & see how they perform. It won't work with 'complicated' indicators, but is good for MA/Mom/Stoch & other 'single' category indicators.

D) I know that iCustom is slow, but 0.45 seconds seems VERY slow. Does this indicator needs DLLs? Maybe it's calling home to Mother each time?

 
Just thought - are you looping & calling iCustom multiple times for each historical bar? If so, just local caching might help (reducing calls to once per bar per value)