In your EAs, where is the indicator code?

 

Good morning

Apparently there are two ways to code indicators for EAs.


The first, put all the indicator code in the EA code.

The second, put the indicator code in an indicator and call it via icustom() or CreateIndicator()


I am clearly in favor of creating the indicators in an indicator and making an icustom() for the EA.

For reference I would cite this article which talks about this subject

https://www.mql5.com/en/articles/10606


Unless I'm mistaken, the article does not mention that the indicators are designed to handle multi-threading, much better than EA.

Which will slow it down as it is optimized to react to the tick....

and other benefits.
The indicator in the EA is counterproductive

Developing a trading Expert Advisor from scratch (Part 25): Providing system robustness (II)
Developing a trading Expert Advisor from scratch (Part 25): Providing system robustness (II)
  • www.mql5.com
In this article, we will make the final step towards the EA's performance. So, be prepared for a long read. To make our Expert Advisor reliable, we will first remove everything from the code that is not part of the trading system.
 
Since this is true, indicators runs on limited thread, if there is a chance to transfer the calculation of indicator easily in ea, then I always transfer code from indicator to ea.

For another reason where indicator is ex5 or I think transferring the indicator code to my ea is too much time consuming I would be using iCustom
 
Gerard Willia G J B M Dinh Sy:


The third method is similar to iCustom, however, I add the indicators to my ea(s) as #resource(s). In past it was shown to be method to avoid much of issues that can be caused by slow ticks and no ticks. Am not clear if modern mt4/5 have the same issues today tho. Either way, my terminals are not laggy as they once were once I started doing it. Only downside is that it might take a few seconds longer to load several charts, and extra use of memory. But that is not an issue for me.

 
I don't use resources to add an indicator. 

I seem to have read that it was much slower (40 times?) than an icustom. 

And since I often need 2 to 5 indicators, I prefer to make sure and not waste too much time
 
I prefer to wrap all the calculations into classes. it removes indicator runtime errors and the errors come from iCustom
 
Gerard Willia G J B M Dinh Sy #:
I don't use resources to add an indicator. 

I seem to have read that it was much slower (40 times?) than an icustom. 

And since I often need 2 to 5 indicators, I prefer to make sure and not waste too much time

https://www.mql5.com/ru/forum/357579/page6#comment_21310421
you may need to translate this page. But I do as it says: have much of my include and resource files in same directory as my ea for compilation. This eliminated the slower reading of the resource files. But I do not know if this still applies to current, modern mt4/5 anymore. It would be great to see a modern thread by someone that tests that this issue still applies today.

Новая версия платформы MetaTrader 4 build 1320
Новая версия платформы MetaTrader 4 build 1320
  • 2021.03.11
  • Valeriy Yastremskiy
  • www.mql5.com
В четверг 10 декабря 2020 года будет выпущено обновление MetaTrader 4. В нем исправлен ряд ошибок и повышена стабильность работы платформы...
 
Gerard Willia G J B M Dinh Sy #: I don't use resources to add an indicator. I seem to have read that it was much slower (40 times?) than an icustom. And since I often need 2 to 5 indicators, I prefer to make sure and not waste too much time
Michael Charles Schefe #: https://www.mql5.com/ru/forum/357579/page6#comment_21310421

you may need to translate this page. But I do as it says: have much of my include and resource files in same directory as my ea for compilation. This eliminated the slower reading of the resource files. But I do not know if this still applies to current, modern mt4/5 anymore. It would be great to see a modern thread by someone that tests that this issue still applies today.


I don't know about MQL4 (because I no longer use it and also it only gets critical updates), but on MQL5, the issue no longer exists for quite some time now.

 
Fernando Carreiro #:


I don't know about MQL4 (because I no longer use it and also it only gets critical updates), but on MQL5, the issue no longer exists for quite some time now.

thanks for the confirmation.

 
There are indeed some advantages to passing an indicator as a resource, but I see more problems than anything else.

Passing parameters for example, which can be a source of error if you don't include the version with the correct parameters for the inputs.

I have not done any tests with a #resource, but I do not see how the indicator errors will appear and if they appear in the error log

Thanks for your feedback, but I think I'll stick with my icustom()

Have a nice weekend
 
Gerard Willia G J B M Dinh Sy #: There are indeed some advantages to passing an indicator as a resource, but I see more problems than anything else. Passing parameters for example, which can be a source of error if you don't include the version with the correct parameters for the inputs. I have not done any tests with a #resource, but I do not see how the indicator errors will appear and if they appear in the error log. Thanks for your feedback, but I think I'll stick with my icustom().

You still use iCustom() with a resource. The only difference between the two is that the indicator is either embedded or external. There are no other differences.

Your reasoning of it having parameter problems or the wrong version is totally illogical. In fact, it is the external indicator that can have the wrong version or even, be a completely different indicator, or be a corrupted file, or even be missing.

The resource however, is embedded at compile time, so as long as you verified it a compile time, it cannot be substituted by the wrong indicator or anything else.

So, please make sure you do proper research, so that you don't post such illogical reasoning.

EDIT: Also, please learn the difference between using an indicator as a resource and doing indicator calculations within the EA logic. They are two completely different concepts. Please don't mix them up.

 

Gerard Willia G J B M Dinh Sy: Unless I'm mistaken, the article does not mention that the indicators are designed to handle multi-threading, much better than EA. Which will slow it down as it is optimized to react to the tick....


Indicators are never multi-threaded. In fact an Indicator shares a single thread with all other indicators for the symbol, while each EAs has a dedicated single thread.

Documentation on MQL5: MQL5 programs / Program Running
Documentation on MQL5: MQL5 programs / Program Running
  • www.mql5.com
Each script, each service and each Expert Advisor runs in its own separate thread. All indicators calculated on one symbol, even if they are...