MQL function day of First Friday every month?

 

Dear Guys,

is any MQL function, how i know what is the date of the first friday every months. Example : in February 2016 first Friday of the month, date is : 05-Feb-2016

how i know by MQL function or coding. Please help me

Thanks

 

Maybe this script can help you

bool CheckFirstFriday()
 {
   bool result = false;  
   if ( Day() <= 7 && DayOfWeek() == 5 )
      result = true;
   return(result); 
 }
 
biantoro kunarto:

Maybe this script can help you

But this will not give 1st friday in March and next nonthes
 

The first script only for checking the current day is First friday

If you want to check the first friday of the march 2016, you can use this script

datetime CheckFriday(int MonthTime, int YearTime)
 {
   datetime result = 0;
   for ( int cnt = 1; cnt <= 7; cnt++ )
      {
         string DateString = IntegerToString(cnt);
         string MonthString = IntegerToString(MonthTime);
         string YearString = IntegerToString(YearTime);
         datetime FridayTime = StringToTime( YearString + "." +
                                             MonthString + "." +
                                             DateString);
         if ( TimeDayOfWeek( FridayTime ) == 5 )
            result = FridayTime;
      } 
   return(result);
 }
 

If you want to check the first friday of march 2016, you can type this:

Print(CheckFriday(3,2016));
Reason: