Topic: EA MACD Error Message

Hi,

I'm getting the following error when loading some Portfolio EAs in MT5:

cannot load indicator 'MACD' [4002]

What's the problem ? Will the EA not work correctly when using MACD as entry/exit ?

Re: EA MACD Error Message

> Will the EA not work correctly when using MACD as entry/exit ?

The EAs are working correctly with the MACD indicator for at least six years.

The problem should be other.

Please attach your expert for a test, and we will find and solve the problem.

3 (edited by felix-brenkel 2023-05-12 06:47:54)

Re: EA MACD Error Message

I attached some of the EAs where I get the error.

Post's attachments

Portfolio Expert BTCUSD M5.mq5 41.33 kb, 3 downloads since 2023-05-12 

Portfolio Expert ETHUSD M5.mq5 53 kb, 3 downloads since 2023-05-12 

You don't have the permssions to download the attachments of this post.

Re: EA MACD Error Message

Both experts compile, test, and run on an MT chart without errors.

Please post screenshots of the issues you experience.

5 (edited by felix-brenkel 2023-05-16 07:01:29)

Re: EA MACD Error Message

See attached file.

I'm getting this error on 2 different brokers.

Post's attachments

2023-05-16 07_57_56-Clipboard.jpg
2023-05-16 07_57_56-Clipboard.jpg 19.26 kb, 2 downloads since 2023-05-16 

You don't have the permssions to download the attachments of this post.

6 (edited by ViniQ 2023-05-16 16:35:32)

Re: EA MACD Error Message

Hi @felix-brenkel you're welcome to the forums! I would like to point out that there appears to be an error in the code or configuration.

   // MACD (Close, 34, 66, 0)
   indHandlers[2][1][0] = iMACD(NULL, 0, 34, 66, 0, PRICE_CLOSE);

Fast EMA: 34
Slow EMA: 66
MACD SMA: 0

   // MACD (Close, 30, 44, 0)
   indHandlers[0][1][0] = iMACD(NULL, 0, 30, 44, 0, PRICE_CLOSE);

Fast EMA: 30
Slow EMA: 44
MACD SMA: 0


It seems that when calling the MACD (Moving Average Convergence Divergence) indicator, the MACD SMA (Simple Moving Average) values are set to 0. However, it is important to note that the MACD SMA should be >=2 for the indicator to function correctly.

I recently exported a portfolio expert using the MACD indicator on the MQL5 platform, and the export process went smoothly with all the values intact. However, I am puzzled as to why your source code has exported the MACD SMA values as 0. It would be beneficial for you, @Popov, to review the minimum period for MACD SMA used in the generator. It is possible that the expert advisor was generated with the parameter set to 0 for MACD SMA, leading to this discrepancy.

Vinicius Pereira, Portuguese Support.
Improve your trading with my strategies & signals on MQL5. High success rate & many followers. Check them out & join my EAS telegram group for updates.

Re: EA MACD Error Message

@viniq
Thanks for your reply.

I'm using Express Generator & afterwards EA Studio to generate the Portfolio EAs. I do not touch any Code.
So it must be a problem of the generation process ?

8 (edited by Alann 2023-05-18 01:20:59)

Re: EA MACD Error Message

Added 15 and 9 to iMACD as shown:  iMACD(NULL, 15, 30, 44, 9, PRICE_CLOSE);

Now EA loads onto MT5 chart with no errors shown in MT5 Experts tab at bottom of price chart.

So all you need to do is open the MT5 Editor and add the correct 'period' and 'signal period' by replacing the two zeros and press the Compile button and you should be able to use the EA's.

Evidently Express Generator is not adding the 'period' and 'signal period' to the source code of iMACD when saving strategy as an EA.

Re: EA MACD Error Message

This problem should result from an earlier bug where the min indicator period could become 0 or negative. Popov fixed it already and newly created EAs should not show this problem anymore.