#include file won't write to the global array Avoid[]

 
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.

   int
   Avoid[100000]={0};
Declaration for Avoid[] in Filter_BacktestPeriod_WinLossTieConfirms.mqh

//------------------------------------------------------------------------------------------------
// Block 1. Determine if No Trade Period Due to News event occurs within backtest period. If yes,
// draw vertical lines for the no trade period and write values of '1' into the Avoid[].
//------------------------------------------------------------------------------------------------
for(a=StopTestIndex-Candles_NOT_to_trade_BEFORE_News;a<=StartTestIndex+Candles_NOT_to_trade_AFTER_News;a++)
   if (a<0)
      {continue;}
   if (a>(Bars-1))
      {break;}
   if(Time[a]==DTofNews)
      {
      NewsEventIndex=a;  //Step 1baa.
      break;
      }
      else
      {NewsEventIndex=-100000;}
   }
if (NewsEventIndex!=-100000)
   {
   StopTradingDueToNews=NewsEventIndex+Candles_NOT_to_trade_BEFORE_News;
   EndOfStopTradingDueToNews=NewsEventIndex-Candles_NOT_to_trade_AFTER_News;
   
   for(b=StopTradingDueToNews;b>=EndOfStopTradingDueToNews;b--)
      {
      ObjectCreate(ShortProgramName+" News Filter "+TimeToStr(Time[b]),OBJ_VLINE,0,Time[b],0);    //Step 3aa.
      Avoid[b]=1;
      }
   }

NewsFilterWriteToAvoid[].mqh

         if(Consider_only_direct_news_and_USD == true)   //step 1
            {
            if(CountryNewsRelatedTo==Currency1 || CountryNewsRelatedTo==Currency2 || CountryNewsRelatedTo=="USD")
               {#include <NewsFilterWriteToAvoid[].mqh>}
            }
            else
            {#include <NewsFilterWriteToAvoid[].mqh>}

 How the program incorporates "#include <NewsFilterWriteToAvoid[].mqh>" (in case it's relevant)

 
Trader2973:
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. 

 
Ovo:

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.
 
Ovo:
The file gets included only once, the second #include is ignored.
OHHHHH. So you can have multiple #include provided the file name is different, but if you have multiple #include for the same file then only the first #include works and the remainder do not?
 
Trader2973: the same file then only the first #include works and the remainder do not?
Correct.
 
Thank you very much for your assistance everyone
Reason: