Find the 4 trading days prior to Non Farm Payroll

 

I am attempting to have another shot at detecting the 4 trading days prior to NFP for any month.

Using the built in functions and the DaysOfMonth() available on the forum I have an idea.

I have an external variable ExcludeDaysBeforeNFP() that can be set from 1 to 4. with 4 meaning it should not trade any of the 4 Trading days before NFP. Using logic as follows.

For example, If the days in the month equal 31 and the day of the month equals 28 and the day of the week is a Monday  Then it is 4 days before NFP.

So we can decide to not trade that day.


extern int ExcludeDaysBeforeNFP = 0; // set between 1 and 4

bool TradeToday = true; 
int DaysPrior   = 0;

if (DaysOfMonth() == 31 && Day() == 28 && DayOfWeek() == 1)
     {
      DaysPrior = 4;
     }

   if (ExcludeDaysBeforeNFP==DaysPrior)
     {
      return(0); //TradeToday = false;  // do not trade this day
     }

Assuming that the above logic will work.... my problem is that it will need quite a few lines of code to check the differrent variations and i am wondering if there is a better method?

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 

I have edited my code as it was not well written.

It now compiles in the simple EA I created to check it.

If anyone can comment on its chance of success it would be helpful.

Regards


Neil