What is BEST Practice to use Indicators in EA ?

 

Dear Members

I am a bit confused about what method to use in EA for indicators. Read few articles on this and come to conclusion that 'Implementing Indicator Calculations' inside the EA is best practice.

However while going through this article https://www.mql5.com/en/articles/4602 on the forum and reading this statement at the end :

Conclusion

This article described the method of relocating the indicator calculations to an EA. Applying OOP makes access to the final indicator data as similar as possible to the standard retrieval of data from indicator buffers. This requires minimal intervention in the source code of the EA when it is reworked.

Based on the results of the conducted experiments, such an approach can also save time during testing and optimization of EAs. But when an EA works in real time, this advantage can be nullified by the multi-threaded MetaTrader 5 architecture.

I will be grateful to get final words of advise from Experts here.

regards.

 

The best practice is to use what is needed from your specifications. There is no general rules.

'Implementing Indicator Calculations' inside the EA is best practice.

In general I would rather say that it's a bad practice. You need to do that only with a very good reason.

As a side note, when you post a link, please do it correctly so it's really a clickable link.

 

Thanks Alain

However I did not got what you mean by 'As a side note, when you post a link, please do it correctly so it's really a clickable link.'

 
  1. Anil Varma: 'Implementing Indicator Calculations' inside the EA is best practice.

    Don't try to 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(s) of the indicator(s) into EA/indicator (using iCustom) and do what you want with it.
              Detailed explanation of iCustom - MQL4 programming forum 2017.05.23


  2. Anil Varma: However while going through this article 'https://www.mql5.com/en/articles/4602' on the forum
    Please use the link button Use the link button (Control+K) See the difference? https://www.mql5.com/en/articles/4602
              Messages Editor

 
William Roeder:
  1. Don't try to 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(s) of the indicator(s) into EA/indicator (using iCustom) and do what you want with it.
              Detailed explanation of iCustom - MQL4 programming forum 2017.05.23


  2. Please use the link button (Control+K) See the difference? https://www.mql5.com/en/articles/4602
              Messages Editor

Thanks William and Alain

Taking your advise to use iCustom and build my EA around it. This is whole lot of relief, as I have been struggling with Indicator Class for almost  last 3 weeks.

Also understood about posting the link. What a silly error I have been making :)

Regards.

Reason: