Importing Variable into include files

 
My EA uses classes and include files for my stop loss and money management ect. I normally like this method it keeps things clean and easy. I have a problem though, with my include files I can only call out variables generated by the system example market info, symbol, ect. I can not figure out how to call out a regular variable that i define( global or otherwise) from the main body of the expert advisor. I am sure it is something easy, I am not a pro by any means. I have been trying to figure out how what I am doing wrong for two weeks, and cant find it anywhere. Please have mercy on a tired amature and bless me with this knowledge. Haha
 
Matt:
My EA uses classes and include files for my stop loss and money management ect. I normally like this method it keeps things clean and easy. I have a problem though, with my include files I can only call out variables generated by the system example market info, symbol, ect. I can not figure out how to call out a regular variable that i define( global or otherwise) from the main body of the expert advisor. I am sure it is something easy, I am not a pro by any means. I have been trying to figure out how what I am doing wrong for two weeks, and cant find it anywhere. Please have mercy on a tired amature and bless me with this knowledge. Haha

All the variables you want to call from inside a include file, you have to declare inside this include file (or inside another include file included in it).  You can create a .mqh file with definitions, declarations, etc, etc, and then, include it inside all the project files.  You should declare inside main EA file (.mq4) only the variables that you don't need to use in other files (.mqh, etc).


Regards.

 
Matt:
My EA uses classes and include files for my stop loss and money management ect. I normally like this method it keeps things clean and easy. I have a problem though, with my include files I can only call out variables generated by the system example market info, symbol, ect. I can not figure out how to call out a regular variable that i define( global or otherwise) from the main body of the expert advisor. I am sure it is something easy, I am not a pro by any means. I have been trying to figure out how what I am doing wrong for two weeks, and cant find it anywhere. Please have mercy on a tired amature and bless me with this knowledge. Haha


You need to define an interface in your mqh-file, which can accept a reference to worker objects or parameters of your EA via special methods or constructors.

You can see an example of passing parameters into classes defined in a mqh-file in my blogs - Multiple timers with publisher/subscriber design pattern.

Reason: