How to define path for an include file located in different folder ?

 

Dear Members

My indicator is in Indicators\Final Version\iFx VW_3EMAs.mq5

There is a file  MQL5\Experts\AKTAdvisor\Auxiliary\Enums.mqh, which I want to include into the Indicator. How can I define this path as file is in  Expert Folder and not in  Indicators Folder ?

#include  "C:\Users\Anil Varma\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\AKTAdvisor\Auxiliary\Enums.mqh"

I have tried "\..\Expert\AKTAdvisor\Auxiliary\Enums.mqh" but it did not worked.

thanks in advance for your guidance.


 

 
You don't. The indicator goes in the «DataFolder»/Indicators or with the EA.
 
William Roeder:
You don't. The indicator goes in the «DataFolder»/Indicators or with the EA.

Thanks William

Let me clarify ...

Indicator is in Indicators\Final Version\iFx VW_3EMAs.mq5

There is a file  MQL5\Experts\AKTAdvisor\Auxiliary\Enums.mqh, which I want to include in the Indicator, so how can I define this path as file in Expert Folder and not in Indicators Folder ?

Hope it clarifies the question better.

Regards

 
"../../Experts/AKTAdvisor/Auxiliary/"

Need to check how many level ups you need...
 
Dominik Egert:
"../../Experts/AKTAdvisor/Auxiliary/"

Need to check how many level ups you need...

Can this be of any help ?

//--- Folder that stores the terminal data
   string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
//--- Common folder for all client terminals
   string common_data_path=TerminalInfoString(TERMINAL_COMMONDATA_PATH);
 
It is the answer to your question.

Obviously you need to change directory, not into a subfolder from the location you are including, but first a few folders up in the hirarchy. This is done by using "../../"

Your "comment" including variables is with no help.

Includes are processed before preprocessing macros.


 
Dominik Egert:
It is the answer to your question.

Obviously you need to change directory, not into a subfolder from the location you are including, but first a few folders up in the hirarchy. This is done by using "../../"

Your "comment" including variables is with no help.

Includes are processed before preprocessing macros.


Thanks Dominik Egret

  #include "\..\..\Experts\AKTAdvisor\Auxiliary\Enums.mqh"

This worked out well, I was using only \..\ instead of \..\..\

and it is 'backslash' not 'forward slash' ...

 

As far as I know, its irrelevant if you use a backslash or forward slash, at least within common environments of windows.

Linux does only use forward slashes on paths and files, since backslash is an indication for an escape-sequence within a string....

 
Dominik Egert:

...

Your "comment" including variables is with no help.


Includes are processed before preprocessing macros.

Include directives and preprocessor macros are processed line by line in linear order. Same as with the C preprocessor. Otherwise things like this wouldn't work:

#define RELEASE_BUILD

#ifdef RELEASE_BUILD
#include "SimpleLogging.mqh"
#else
#include "Logging.mqh"
#endif

...

Dominik Egert:

As far as I know, its irrelevant if you use a backslash or forward slash, at least within common environments of windows.

Linux does only use forward slashes on paths and files, since backslash is an indication for an escape-sequence within a string....

The path specifier will be passed to the operating system's runtime environment as is. It's up to the OS how to deal with forward or backward slashes.

Windows (since XP afaik) is able to translate forward slashes into native format, which makes path specs with forward slashes more portable.

 
Very good.

Thank you for correcting my statement about preprocessor.
 
lippmaje:

Include directives and preprocessor macros are processed line by line in linear order. Same as with the C preprocessor. Otherwise things like this wouldn't work:

...

The path specifier will be passed to the operating system's runtime environment as is. It's up to the OS how to deal with forward or backward slashes.

Windows (since XP afaik) is able to translate forward slashes into native format, which makes path specs with forward slashes more portable.

Hi lippmaje / Dominik

Thanks for the useful information. Since I am not a computer software person, but a finance professional with passion for programming, these information are helping me learn more.

Reason: