I created some .mqh files and left them in the Include folder (not a subfolder of the Include folder). I tried calling a class from the .mqh in my Expect Advisor but I keep getting a “undeclared identifier” error. Where should I place my .mqh files to be recognised by my Expert Advisor?
Most of my .mqh files are in MQL5\Include.
I have some in a sub-directory of MQL5\Expert.
Shouldn’t matter so long as you have your #include lines correct in the calling .mq5 file.
What should the #include path be?
Depends upon where the .mqh file is.
These are all valid. I know this because I just copied out of a working EA. As you can see, I mix and match angle brackets with double quotes as needed.
And note that you can include .mq5 files as well.
#include <clsTimeSeriesData.mqh> #include <clsTradeMetrics.mqh> #include <clsOkToTrade.mqh> #include "..\..\libraries\clsMoneyManagement.mq5" //#include "..\..\libraries\clsInternalAverages.mq5" #include <clsShowStatistics.mqh> #include "TimeSeries.mqh" #include "RSquare.mqh" #include <clsStrategy.mqh> #include <clsRange.mqh> ''' Read this link for specific details: https://www.mql5.com/en/docs/basis/preprosessor/include
Thanks, that solves it.