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));
 

If anyone is still following this almost decade old thread, cleanest and simplest solution for me is to use DayOfWeek() to check is it's FRIDAY then use TimeDay(TimeLocal()) <= 7 to work out if it's the 1st one of the month. This solution is month agnostic so you shouldn't need to care about the month in datetime

 
Biantoro Kunarto #Maybe this script can help you
Your code Simplified
bool CheckFirstFriday()
 {
   bool result = false;  
   if ( Day() <= 7 && DayOfWeek() == 5 )
      result = true;
   return(result); 
 }
bool CheckFirstFriday()
 {
   return Day() <= 7 && DayOfWeek() == FRIDAY;
 }