Resource or Include

 

to import an indicator into my ea should I make it a resource? or would the effort to change my indicator into an include file, be worth it?
NOTE: i will be using the ea on several symbols + charts.
NOTE II: working on a mt5 ea.

 
Michael Charles Schefe:

to import an indicator into my ea should I make it a resource? or would the effort to change my indicator into an include file, be worth it?
NOTE: i will be using the ea on several symbols + charts.
NOTE II: working on a mt5 ea.

Indicator files are imported into ea using iCustom function and not by the include or resource.
 
Michael Charles Schefe: change my indicator into an include file,
  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.
              (MT4) Detailed explanation of iCustom - MQL4 programming forum (2017)

  2. You don't need it as a resource, unless you intend to sell the EA.

    Be aware that using resources is 40x times slower than using CIs directly.
              A custom indicator as a resource - MQL4 programming forum (2019)

    Also make use there are no spaces in the path.
              Getting error 4802 when loading custom indicator that loads another custom indicator with iCustom - Technical Indicators - MQL5 programming forum. (2020)

    Also Use of Resources in MQL5 - MQL5 Articles (2011)


 
William Roeder #:

thanks for the links.

 
Rajesh Kumar Nait #:
Indicator files are imported into ea using iCustom function and not by the include or resource.

yes, but my question was if it was worth the effort to change the indicator into an include file to be used and imported into an mt5 ea.

After reading the links from William's, it seems that the way I have done it, is quite optimal.

ie i have the indicator placed in the experts folder with the ea source code file, and a #property resource line at top of the my ea source code, with 0 spaces.

I am half way thru the readings from william.

 

@WHRoeder do I need a space between :: and the name of the indicator, when I call the indicator from OnInit?

#resource  "indicator.ex5"
int res = INIT_FAILED;

**OnInit func.
res = iCustom (NULL, 0, ":: indicator.ex5", 0,0); // note the space between the :: and indicator name

example modified from

https://www.mql5.com/ru/forum/357579/page6#comment_21310421

Новая версия платформы MetaTrader 4 build 1320
Новая версия платформы MetaTrader 4 build 1320
  • 2021.03.11
  • Valeriy Yastremskiy
  • www.mql5.com
В четверг 10 декабря 2020 года будет выпущено обновление MetaTrader 4. В нем исправлен ряд ошибок и повышена стабильность работы платформы...
 

NOTE i am going to do some testing and timing of different scenarios using the indicator in mt5 ea code. I will post results over the coming days.

The code that I will start with is from this post. If you have better reporting code, then please make your suggestion code below. Thanks. But just remember that I am coding in mt5, not mt4.

https://www.mql5.com/en/forum/327270#comment_14030970

A custom indicator as a resource - A custom indicator slow down 60 times tester against using the same indicator with the same inputs (not as a resource)
A custom indicator as a resource - A custom indicator slow down 60 times tester against using the same indicator with the same inputs (not as a resource)
  • 2019.11.26
  • Petr Nosek
  • www.mql5.com
A custom indicator included as a resource slow down 60 times tester against using the same indicator with the same inputs (not as a resource). Is the only way to solve the problem to embeed resource indicator code inside "main" code
 
Michael Charles Schefe #:

@WHRoeder do I need a space between :: and the name of the indicator, when I call the indicator from OnInit?

example modified from

https://www.mql5.com/ru/forum/357579/page6#comment_21310421

No if you include a space it will not work.

You only need to include the indicator as a resource if you want to distribute with the EA and not separately.

There are no performance issues with using an indicator as a resource in MT5, as far as I know that issue is limited to MT4.

 
Paul Anscombe #:
William Roeder #:

I have given the ea to a few friends, and since it is easier to install 1 file, rather than 6, then giving out the single file is preferred if there is no detrement to trading in any way whatsoever, even if more memory is required, that is ok too, so long as trading has not recieved any loss by importing the resource(s), instead of calling external files.