Code For Non Farm Payroll

 

Another attempt at coding to miss out days prior to NFP.

The code compiles and the logic seems sound but if i set the tester to run this bit of the code it does not trade at all rather than missing the days tested for.

Is there an obvious error anyone can see.


// Code to exclude Days Before NFP

   if(ExcludeDaysBeforeNFP > 0)  // we are excluding up to 4 days before NFP
     {
      
      for(int daysOM = 28; daysOM = 31; daysOM++)// DaysInMonth from 28 to 31 to test against used in calcs below

         //                   1
         for(int i = ExcludeDaysBeforeNFP ; i = 0; i--) // for i = (from max 4 down to 1) Loop through ExcludeDaysBeforeNFP in reverse

 // Example of logic with ExcludeDaysBeforeNFP = 4 then 3 with daysOM = 31 and then 28
   //            31                 31                31   + 4 - 4 (= 31)        4 = true if (Thursday)
   //            31                 31                31   + 3 - 4 (= 30)        3 = true if (Wednesday)
   //            31                 31                31   + 2 - 4 (= 29)        2 = true if (Tuesday)
   //            31                 31                31   + 1 - 4 (= 28)        1 = true if (Monday)
  
   //            31                 31                31   + 3 - 4 (= 30)        3 = true if (Wednesday) 
   //            31                 31                31   + 2 - 4 (= 29)        2 = true if (Tuesday)
   //            31                 31                31   + 1 - 4 (= 28)        1 = true if (Monday)
  
   //            28                 28                28   + 3 - 4 (= 27)        3 = true if (Wednesday)
   //            28                 28                28   + 2 - 4 (= 26)        2 = true if (Tuesday)
   //            28                 28                28   + 1 - 4 (= 25)        1 = true if (Monday)
        
             
            if(DaysOfMonth() == daysOM && Day() == (daysOM + i - 4) && DayOfWeek() == i)
            
            // If the above is true 
              {
               //       
               return(0); //Do not trade this day
              }

     }