First Friday of the Month (Nonfarm Payrolls)

 

Hi,


I have been looking for a functon to get the number of days in the month. I was thinking of doing a FOR loop to loop through each day of the month to find the 1st Friday of each month with the code:


 if(DayOfWeek()==5 && Day()<=7)
 
{
 
 
}

Once I have found this date, I would like to make sure the current date is at least 1 day after the 1st Friday of each month so that I may draw horizontal lines on the high and low points of this date.


Anyone has any idea how to do this?

 
datetime bar_datetime;
   
   for(int bar_counter = 0; bar_counter <= Bars; bar_counter ++)
   {
      bar_datetime = iTime(NULL, 0, bar_counter);
   
      if(TimeDayOfWeek(bar_datetime)==5 && TimeDay(bar_datetime)<=7 && TimeMonth(bar_datetime) == Month())
      {
         Alert("1st Friday of " + Month() + " = " + TimeDay(bar_datetime) + "/" + TimeMonth(bar_datetime) + "/" + TimeYear(bar_datetime));
   
         break;
      }

   }
I think I figured it out.