Theory of EA acceleration when using a custom indicator (function - iCustom) - page 3

 
-Aleks-:
So, the hodgepodge of necessary indicators will work faster than using the indicators separately - the information about quotes will be requested less frequently?

Not essential. Make sure that the calculations are not duplicated. If the preliminary calculations of two indicators are the same, they should be combined into one. You should not just paste all the indicators into one.

There are no problems with requesting the quotes. They don't need to be requested, they come by themselves.

 

Tried using a time delay to recalculate the indicator:

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
 static datetime   prevtime;
  datetime per=15; //задержка секунд
   
   if((TimeCurrent()-prevtime)<per) 
   {
   return(rates_total); //прошло мало секунд - поэтому выходим
   }
 
//--- main cycle  
....................

prevtime=TimeCurrent();
return(rates_total);
 }

When testing on "OHLSnaM1" there is almost no difference, perhaps testing on "all ticks" will be faster.

 

my impression of how iCustom works (if nothing has been changed in the last 2 months)
when you call the indicator from iCustom
all buffers for a possible history and the results stored in the cache will be calculated, and the cache will be bound to the parameters and indicator name

if you next time call the same indicator and the same parameters for the second index array - the result will return from the cache (+ correction for the new history data)
if you call the same indicator, but change only one parameter - the full calculation of all buffers for the possible history and saving of another cache, but with a binding to the new parameters will be performed.


You can specify how much history should be downloaded from the Expert Advisor, if you make such a parameter in the indicator, but at this call you should always pass the same number - the size of the history.
(it will affect the speed of the first call of iCustom).

You can try to remove the calculation of unnecessary buffers, if possible, both in the indicator and via indicator parameters, as in the example with the history size
(decrease the cache size - increase the calculation speed)

 

Thank you all for the information.

I want to clarify, if in an indicator with 5 graph buffers to use not a graphical buffer, but an ordinary array - to output data through a graphical buffer, as I suggested, the speed of the indicator during optimization will be faster, because less memory will be allocated for the indicator, and therefore less time will be spent to work with it?

If the optimization is performed and the indicator settings are not changed on each pass, will the indicator be recalculated?

 
-Aleks-:

Thank you all for the information.

I want to clarify, if in an indicator with 5 graph buffers to use not a graphical buffer, but an ordinary array - to output data through a graphical buffer, as I suggested, the speed of the indicator during optimization will be faster, because less memory will be allocated for the indicator, and therefore less time will be spent to work with it?

If the optimization is performed and the indicator settings are not changed on each pass, will the indicator be recalculated?

The buffer is an array, only convenient for displaying data.

During optimization the indicator is recalculated each time.

 
komposter:

A buffer is an array, only handy for displaying data.

I understand the array, but the array for calculating an indicator can be much smaller - often dynamic.

For example in the history of 1000 bars - the custom indicator draws 3 SMAs - 5/8/10.

In the standard case we will have a graphic buffer for almost 3000-10-8-5

And if we use my method

to calculate the SMA(5) we need an array of size (sorry for the terminology) of 4 bars

to calculate the SMA(8) I need an array of (excuse the terminology) 7 bars in size

to calculate the SMA(10) we need an array of (sorry for the terminology) 9 bars

and a chart array of 1000 bars, the result is that you need 1000+4+7+9 as the arrays will simply overwrite them.

Where am I wrong?

 
-Aleks-:

Thank you all for the information.

I want to clarify, if in an indicator with 5 graph buffers to use not a graphical buffer, but an ordinary array - to output data through a graphical buffer, as I suggested, the speed of the indicator during optimization will be faster, because less memory will be allocated for the indicator, and therefore less time will be spent to work with it?

If the optimization is performed and the indicator settings are not changed on each pass, will the indicator be recalculated?

It's more important to understand that when you call the indicator again, it won't be reloaded to the memory segment (overlay). Everything else is nothing compared to it.
 
-Aleks-:

I understand the array, but the array for calculating the indicator can be much smaller - often dynamic.

For example in the history of 1000 bars - the custom indicator draws 3 SMAs - 5/8/10.

In the standard case we will have a graphic buffer for almost 3000-10-8-5

And if we use my method

to calculate the SMA(5) we need an array of size (sorry for the terminology) of 4 bars

to calculate the SMA(8) I need an array of (excuse the terminology) 7 bars in size

to calculate the SMA(10) we need an array of (sorry for the terminology) 9 bars

and a chart array of 1000 bars, the result is that you need 1000+4+7+9 as the arrays will simply overwrite them.

Where am I wrong?

If you need a value on one bar, you really don't need a buffer. Neither is the indicator ;)

And if you need an indicator value on every bar, it is often more economical to calculate everything, and then to additionally calculate only the new bar.
And not all algorithms are as simple as SMA, they simply cannot be calculated "for 5 bars". Take a look at the zig-zag at least.

What confuses me the most is that you don't try to apply the answers in practice. It seems that there is no practical task, only theoretical tricks.
Then I do not understand why I take part in it.

 

By the way, MT4 copes very well with calculation of only a part of history and does not consume memory for the whole buffer, if the loop goes through the last 1000 bars (even if there are 50000 bars "in the window").

However, I encountered this problem in MT5 - it allocates memory for all 50000 bars even if only the last 100 are counted.

 
komposter:

If you need a value on one bar, you really don't need a buffer. Neither does the indicator ;)

Why one bar? I was just saying that in order to calculate the value of an indicator you rarely need to know all of its indicators for the whole time history. That's why I wrote that buffers (arrays) will be used only for calculation, while the result of calculation of 3 MAs will be stored in one graphicalbuffer.

Regarding Zig-zag - this is a headache for me now - it requires a number of answers, but I'll open a separate thread.

komposter:

What confuses me the most is that you don't try to apply the answers in practice. It feels as if there is no practical task, only theoretical speculations.

Then I don't understand why I take part in it.

The thing is that I'm not a programmer myself - my investigations will help me to draw up the requirements specification. Now I'm developing an indicator, which will be a component of EA's engine - it has a lot of buffers, so I'm thinking about how to speed up the EA not by integrating the indicator into code, but by other methods.

And I also hoped that someone would be interested in trying such an algorithm in practice - to compare the speed of operation ...


komposter:

By the way, MT4 is perfectly able to calculate only a part of history and doesn't eat memory for the whole buffer, if the loop goes through the last 1000 bars (even if there are 50000 in the "window").

However, I encountered this problem in MT5 - it allocates memory for all 50000 bars, even if I only count the last 100.

It's a sad fact for 5. Don't the developers explain the sacred meaning of this?