#include not working

 

Hello, my #include command isn't working.

When I create a new include file using the wizard provided through the file menu on MetaLanguage Editor, it saves the include to the includes directory within the same directory as the EA.

When I compile the EA, there is an error that it cannot open the include file.

I have tried three ways to format the include command, all three of which seem to be represented in the documentation (https://docs.mql4.com/basis/preprosessor/include).

#include <tradeFunctions.mqh>

//or, alternately, on a separate compile
#include "tradeFunctions.mqh"

//again, on a separate compile attempt
#include "tradeFunctions.mqh";

What am I missing?

 
Strange. I can only guess. But each copy of MT4 you install has it's own copy of MetaEditor. Maybe you are using one from a different MT4 (which will look in the wrong include directory). Make sure you opening the right one.. go to the directory, or click the MetaEditor button in the correct MT4, or right click an indicator and "modify" in the correct MT4
 

Correction: that is not the code I used!

I found the problem. I had pasted the name of the file from its header which gave it a .mq4 extension, rather than its actual name which gives it a .mqh extension.

That seems like a bug in the wizard. Why does it create a header with an invalid file name/extension?

 
KalebC:

Correction: that is not the code I used!

I found the problem. I had pasted the name of the file from its header which gave it a .mq4 extension, rather than its actual name which gives it a .mqh extension.

That seems like a bug in the wizard. Why does it create a header with an invalid file name/extension?

It's to see if you are attentive when you copy & paste ;-)
Reason: