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, 4 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.

10 (edited by aaronpriest 2023-06-26 03:19:14)

Re: EA MACD Error Message

geektrader wrote:

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.

I just created new EAs tonight with the latest Express Generator and EAS, and I have this error on several symbols in MT5. It doesn't appear to be resolved yet, or the bug has returned.

I discovered the affected portfolio EAs have strategies where MACD SMA = 0. Could the new optimizer feature in Express Generator be causing this? I'm using numeric_values_steps = 20 for the optimizer.

Re: EA MACD Error Message

Mr. Popov should take a look at this for sure then.

12 (edited by aaronpriest 2023-06-26 04:05:25)

Re: EA MACD Error Message

I changed the 0 to a 1 for the close of every MACD or MACD Signal for every affected strategy in the portfolio EAs and that fixed it. I suspect it won't change the performance of the strategy.

Re: EA MACD Error Message

I'll examine this issue today.

Thank you for the report!

Re: EA MACD Error Message

I found and fixed the issue in Express Generator v2.36.

It was in an unexpected place. Because I tried to optimize Express Generator maximally, I skipped the MACD signal line calculations because it was unnecessary. However, it exports the indicators MACD's SMA period equal to 0.
Now I fixed it to 2.

Re: EA MACD Error Message

Thank you, Popov!

Re: EA MACD Error Message

Thanks for the fix! If you now set it to a fixed 2, do the calculations/backtests still match with EA Studio? Thanks.

Re: EA MACD Error Message

>If you now set it to a fixed 2, do the calculations/backtests still match with EA Studio?

The actual value doesn't matter because it is not used in the calculations.

However, I also added this value in the strategy's "first bar", but it is not in EA Studio.

It is fixed in Express Generator v2.37