Currently I'm writing a program that has "#include <Filter_BacktestPeriod_WinLossTieConfirms.mqh>" and "#include <NewsFilterWriteToAvoid[].mqh>." Filter_BacktestPeriod_WinLossTieConfirms.mqh declares the global array "Avoid[]" as shown below, while NewsFilterWriteToAvoid[].mqh is meant to write '1' into Avoid[]. Unfortunately it's not working right now, but when I substitute "#include <NewsFilterWriteToAvoid[].mqh>" with the actual contents of NewsFilterWriteToAvoid[].mqh the program works just fine. Could someone please advise me what I'm doing wrong? Thank you.
Declaration for Avoid[] in Filter_BacktestPeriod_WinLossTieConfirms.mqh
NewsFilterWriteToAvoid[].mqh
How the program incorporates "#include <NewsFilterWriteToAvoid[].mqh>" (in case it's relevant)
I would start with this quotation:
If the # symbol is used as the first character in a line of the program, this line is considered as a preprocessor directive. A preprocessor directive ends with a line feed character.
I would start with this quotation:
If the # symbol is used as the first character in a line of the program, this line is considered as a preprocessor directive. A preprocessor directive ends with a line feed character.
Sorry, I'm new to this so not entirely sure what I'm meant to garner from this. I've tried reading on preprocessor directive and line feed character. No idea about the line feed character, but are you saying that I can't have a "{" in front of "#include" but need to have it on its own line like below?
if(Consider_only_direct_news_and_USD == true) {if(CountryNewsRelatedTo==Currency1 || CountryNewsRelatedTo==Currency2 || CountryNewsRelatedTo=="USD") { #include <NewsFilterWriteToAvoid[].mqh> } } else { #include <NewsFilterWriteToAvoid[].mqh> } }
Not sure if that's what you meant but I tried it anyway. It did not resolve the issue
Additionally, I've tried modifying it again. I encased the entire content of "NewsFilterWriteToAvoid[].mqh" in a single "{}" so that I could remove those same marks from the program source code resulting in the below coding. When I try to compile though it gives the error "empty controlled statement found" which from my understanding means that there is no coding between "if" and ";" (The only reason I placed ";" at the end of "#include <NewsFilterWriteToAvoid[].mqh>" is because without it MetaEditor gives the critical error ')' - semicolon expected). So for some reason "#include" isn't copying the contents of "NewsFilterWriteToAvoid[].mqh" into the program source code? I have no idea why though. Because I have ";" at the end of #include when you're not meant to?
if(Consider_only_direct_news_and_USD == true) //step 1 { if(CountryNewsRelatedTo==Currency1 || CountryNewsRelatedTo==Currency2 || CountryNewsRelatedTo=="USD") #include <NewsFilterWriteToAvoid[].mqh>; }
The file gets included only once, the second #include is ignored.
Trader2973: the same file then only the first #include works and the remainder do not?
| Correct. |

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Declaration for Avoid[] in Filter_BacktestPeriod_WinLossTieConfirms.mqh
NewsFilterWriteToAvoid[].mqh
How the program incorporates "#include <NewsFilterWriteToAvoid[].mqh>" (in case it's relevant)