About computing load of indicators in EA

 

Hello,

i have this question:

i need to use in my EA some indicators and the EA work on many many instances, so i need to save as much computing power as i can.

For the computer it's easier to work if i calculate the data needed inside the EA through the formula of the indicator

OR

if i use the iCustom function and i ask to the EA to get the data by the external indicator?

Thank you very much

Jekko

 
You can try GetTickCount function to evaluate performance for both cases.
 

Jekko76:

For the computer it's easier to work if i calculate the data needed inside the EA through the formula of the indicator

OR

if i use the iCustom function and i ask to the EA to get the data by the external indicator?

  1. Don't try do that. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)
    Just get the value of the indicator into the EA and do what you want with it. You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum

    • EAs : Don't do per tick that you can do per bar, or on open.
      If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts and you recalculate.)
      If you are waiting for an order to open or close, only look when OrdersTotal has changed.
    • Indicators: Code it properly so it only recomputes bar zero.
                Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum
 
Jekko76:

For the computer it's easier to work if i calculate the data needed inside the EA through the formula of the indicator

OR

if i use the iCustom function and i ask to the EA to get the data by the external indicator?

Calls to an external indicator are always an overhead. But depending from the algorithm, an indicator can perform calculations more efficient (using batch calculations, buffers, etc), so if you can afford, you should measure your specific algorithm in both implementations and chose most appropriate.

 
thank you very much, i will try as suggested
Reason: