indicators as resources fails - why, where?

 

I want to load my indicator as resource:

#resource "\\Indicators\\MyEMA_R.ex5"
...

int OnInit()  {
...
   hMA = iCustom(_Symbol,PERIOD_H1,"::Indicators\\MyEMA_R.ex5",PER,cFLATT,REL,DEV,BRK);
   if (hMA == INVALID_HANDLE) {
      Print("Handle MyEMA_R failed, err:",err());
      return(INIT_FAILED);
   }
...

It is as described in the help and here: https://www.mql5.com/en/articles/261

And now I get in the Journal:

2023.04.20 15:32:27.879 Experts expert Dreamer 07 Opti (EURCHF,H1) loaded successfully
2023.04.20 15:32:29.303 Indicators      custom indicator MyEMA_R (EURCHF,H1) loaded succesfully

but in the Expert log:

2023.04.20 15:32:29.308 Dreamer 07 Opti.ex5::Indicators\MyEMA_R (EURCHF,H1)     cannot load custom indicator '::Indicators\MyEMA_R.ex5' [4802]
2023.04.20 15:32:29.308 Dreamer 07 Opti.ex5::Indicators\MyEMA_R (EURCHF,H1)     Expert: iCustom call: Error code=4802

Of course MyEMA_R.ex5 does exist in \Indicators.

The error is: ERR_INDICATOR_CANNOT_CREATE  4802.

The problem is that in OnInit the check of a valid handle passes (..loaded successfully) while then MyEMA_R.ex5 cannot be created :(

Any idea?

Use of Resources in MQL5
Use of Resources in MQL5
  • www.mql5.com
MQL5 programs not only automate routine calculations, but also can create a full-featured graphical environment. The functions for creating truly interactive controls are now virtually the same rich, as those in classical programming languages. If you want to write a full-fledged stand-alone program in MQL5, use resources in them. Programs with resources are easier to maintain and distribute.
 
Carl Schreiber:

I want to load my indicator as resource:

It is as described in the help and here: https://www.mql5.com/en/articles/261

Carl it's already second time a link you provided is not correct (error 404), because you added a dot at the end. I fixed both but please pay attention to it.


 
Carl Schreiber:

I want to load my indicator as resource:

It is as described in the help and here: https://www.mql5.com/en/articles/261

And now I get in the Journal:

but in the Expert log:

Of course MyEMA_R.ex5 does exist in \Indicators.

The error is: ERR_INDICATOR_CANNOT_CREATE  4802.

The problem is that in OnInit the check of a valid handle passes (..loaded successfully) while then MyEMA_R.ex5 cannot be created :(

Any idea?

Is it possible to get the indicator to try to reproduce it ?
 
Alain Verleyen #:
Is it possible to get the indicator to try to reproduce it ?

Sorry about the link - I thought I copied it directly from the address line ...

Hmm, sorry I don't want to send my indicators to others.

I loaded as resource another indicator: Braid Filter.mq5 (found somewhere) and this one worked :(

I added in OnInit() a Print(__LINE__,"  ",hMA ," OK"); and this shows a valid integer number - so a working handle.

And then in OnTick() the EA fails to get buffer values:

int iVv = CopyBuffer(hMA ,0,tC,2,aMA); if(iVv<1) Print("Dr1 ",__LINE__," Buff0 i:",iVv,"  err:",err());

This causes this entry in the Expert log:

2023.04.20 16:42:53.316 Dreamer 07 Opti (XAUUSD,H1)     Dr7 434 Buff0 i:-1  err:Error Err[4806] ERR_INDICATOR_DATA_NOT_FOUND: Requested data not found

The other indicator Braid Filter.mq5 does not has this problem neither in OnInit() nor with CopyBuffer in OnTick() :(

Of course my indicator works with no errors if directly a) loaded on a chart, b) normally loaded (not as resource) by this or other EAs, and c) used in an optimization.

PS.: I don't use any .dll - if this is of some importance.

 
Carl Schreiber #:

Sorry about the link - I thought I copied it directly from the address line ...

Hmm, sorry I don't want to send my indicators to others.

I loaded as resource another indicator: Braid Filter.mq5 (found somewhere) and this one worked :(

I added in OnInit() a Print(__LINE__,"  ",hMA ," OK"); and this shows a valid integer number - so a working handle.

And then in OnTick() the EA fails to get buffer values:

This causes this entry in the Expert log:

The other indicator Braid Filter.mq5 does not has this problem neither in OnInit() nor with CopyBuffer in OnTick() :(

Of course my indicator works with no errors if directly a) loaded on a chart, b) normally loaded (not as resource) by this or other EAs, and c) used in an optimization.

PS.: I don't use any .dll - if this is of some importance.

Is your indicator using other indicators ? As resource ?
 
Alain Verleyen #:
Is your indicator using other indicators ? As resource ?

This was it - almost. I am not using other indicators, but the indicator creates a link to itself as described in the a.m. article and that causes the problem.

As soon as I removed that it works. :)

Thank you!

Reason: