Efficiency and Robustness of #include

Benjamin David Hardman  
Hi developers,

I have been finding ways to increase the efficiency and robustness of my EA and one thing I have read is the use of the #include preprocessor directive. 

Specifically writing Money Management, Entry Signals and Trade Management functions in separate files and then including them in a master framework. 

The main question is: Why would this be a good idea?

Surely it would be more logical to have everything within the same file to avoid latency and other potential problems. 

One specific problem example being if for some reason the Money Management file was moved, the framework may not be able to reference it and risk not correctly managing open positions etc. 

I’d love to hear people’s thoughts and improve my knowledge in the use of #inlcude. 

Thanks 

Fernando Carreiro  
TraderH1: I have been finding ways to increase the efficiency and robustness of my EA and one thing I have read is the use of the #include preprocessor directive. Specifically writing Money Management, Entry Signals and Trade Management functions in separate files and then including them in a master framework. The main question is: Why would this be a good idea? Surely it would be more logical to have everything within the same file to avoid latency and other potential problems. One specific problem example being if for some reason the Money Management file was moved, the framework may not be able to reference it and risk not correctly managing open positions etc. I’d love to hear people’s thoughts and improve my knowledge in the use of #inlcude.

The "#include" is handled at the compile stage, not at the runtime stage. So, once it is compiled, it no longer has any dependency on the original code (or the "#includes"), so even if you change the code or move the included files, it will not impact the executable in the least. There is no latency problems!

Also, the "#include" has two forms which allows for some leeway in where the files are located and allows for auto searching for the file within a certain scope. Please read the documentation for more information.

As a developer, it is up to you to create a well organised folder and file structure for all your source code and projects.

Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
  • www.mql5.com
Including Files (#include) - Preprocessor - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
William Roeder  
TraderH1: I have been finding ways to increase the efficiency and robustness of my EA

The include is irrelevant; that is only part of the efficiency of the programmer.

Reason: