Problem in optimization with include files

 

Hi guys,


I have implemented the sequence of files indicated on the book belowÇ


https://book.mql4.com/build/index


But i have a problem, the external variables aren't present to me on the optimization process, i need this to optimize and try some strategies, i try several ways to put the extern variables, but with no sucess, if someone know please help me. Thanks a lot 


 



Terminal



Code

 

I use several Included Files in my EA and I have not had any problems with passing extern variables to the included files for backtest optimization.


I notice you also include: stdlib.mqh, stderror.mqh, and WinUser32.mqh.


I do not use those files. You might want to "comment" those out for a quick try, unless you know you need them.

 

Hi

If you check out the book and look at the use of #include you will see that they come first in the code because the compiler needs to know about the routine before it encounters them. Your external variables should come after all the compiler directives. MQ4 is not tight on following C rules but it might be ignoring the extern definitions because directives come after them.

 

As stated earlier I use a lot of Included Files and all them are listed after the variables are declared. They all play a significant role in my algorithm. I am baffled as to why your external variables are not passed to the included files.


I did learn however, that third tier callouts do not work. For example the EA calls 1st the Included File, which in turn calls another Included File, which in turn calls another Included File. MQL does not support that kind of deep tiering or nesting of Included Files. I am successful in calling Included Files that are in the 2nd tier.


Are your sure your Included File is being implemented in the EA? I suggest you place a Print("Included File xxxx Reporting") statement in the first line in the suspect Included File and see if it is actually being called. When I first started debugging my EA it was a vegetable in the backtester. You probably have some algorithm problem that is contributing to the failure to see external variables in the Included File.


The attached pic confirms my use of Included Files and their location relative to the int() function.


Reason: