#include and declaring global variables

 

Hi friends,

I'm working on an EA and I'm going to lighten my EA code lines, so I decided to use the #include preprocessor and put some of my functions into the .mqh files and use them by putting the #include directive in my EA's code.

I actually have a problem with declaring global variables. I'm using some global variables in my current EA's code that are being used in different part of my program so I only need to declare them once at the beginning of my main code but the problem is that when I move the functions to the .mqh files, the new .mqh files get an error of "undeclared identifier". 

I'd appreciate if anyone could help me on this issue.

 
parham.trader: when I move the functions to the .mqh files, the new .mqh files get an error of "undeclared identifier".
mqh files do not get errors. You do not compile them. You include them in the main program and compile that.
 
whroeder1:
mqh files do not get errors. You do not compile them. You include them in the main program and compile that.


@whroeder1 great as always !

the problem has been solved. thank you so much.

As another questions , I'm going to use my EA (.ex4 file) on VPS so I need to put my .ex4 and .mqh files on windows server and as you may know using VPS would result in being exposed to the risk of accessing strangers to my files. Therefore I want to know is there any way to hide the code of my functions that are put in .mqh files exactly like the conversion of .mq4 files into .ex4 for the .mqh files, so that nobody could see my functions codes thats are put in .mqh files.

Again I need to thank you all and especially @whroeder1 for your kind guidance.

 
parham.trader: 'm going to use my EA (.ex4 file) on VPS so I need to put my .ex4
You are going to use the EX4 and only that.
 
whroeder1:
You are going to use the EX4 and only that.


what do you mean by that?

You mean after putting the #include lines in my code, I only need to compile the original code once to get its .ex4 file and afterwards I do not need to have the .mqh files in the directory where my EA is installed ? so the only and only file that I need to put on VPS is a .ex4 file with #include lines in its code and no .mqh file is needed anymore to put on VPS ? did I get what you said correctly ?  

 
whroeder1:
You are going to use the EX4 and only that.

All the discus are very strong. Really i am upset.
 
Mohaimenul:

All the discus are very strong. Really i am upset.


I didn't get what you mean ! Why are you upset ? what is the problem?

 
whroeder1:
You are going to use the EX4 and only that.


I just tried what you said and the .ex4 worked properly without need of having the .mqh file in its directory.

your kind guidance is highly appreciated.

Reason: