How to load indicators in mqproj?

 

I have a mqproject (consisting of a MyEa.mq5 and a .mqproj file within the folder called "custom") and would like to use indicators from MQL5/Indicators/Examples in my EA.

With a simple EA without embedding it in a .mqproj, indicators can be loaded successfully without the need to include them. However, indicators from the MQL root cannot be loaded from a MQPROJ. The project compiles successfully, but when running in MT5, the log displays the message "Unable to load indicator 'Relative Strength Index' [4302]."

I also tried explicitly including the file in my MQL5 file:

#include "..\..\Indicators\Examples\RSI.mq5"

However, I receive the compiler error "Function 'OnInit' already defined and has a different return type." This is understandable, as there are now two MQL5 files in my MQPROJ file (the second one is RSI.mq5 which also has an void OnInit()). How can I import this indicator as a dependency in my MQPROJ?

 

How to include mql5 files in an mqproj:

General rules for working with local projects - Advanced language tools - MQL5 Programming for Traders - MetaTrader 5 algorithmic/automatic trading language manual


"The case when a custom indicator in the OnInit function creates one or more instances of itself requires separate consideration (if this technical solution itself seems strange, we will give a practical example after the introductory examples)."

(Connecting custom indicators as resources - Advanced language tools - MQL5 Programming for Traders - MetaTrader 5 algorithmic/automatic trading language manual).

 

Yes, thanks! It works by using:

#resource "\\Indicators\\Examples\\RSI.ex5"

 
harryma23 #:

Yes, thanks! It works by using:

#resource "\\Indicators\\Examples\\RSI.ex5"

You're welcome.

You're clearly a good programmer because you worked directly from mql5 reference materials without further issues.