Day Of Week - MetaTrader 5 Library | Martin EA Download - MT4/MT5 Resources



The purpose of the "Day of Week" function is to determine the desired number of months based on the data for the week and the day of the week within that month. For example, we need the third Friday of February 2000 or the fourth Wednesday of November 1998. This function allows determining the number of search days.
The idea of creating this function came to me when I was writing the indicator and came across many dates connected with the definite days of the week in the month. For example, there is such date as Martin Luther King Day, celebrated on the third Monday of January. I can't find the day using standard functions. Since the days of the week repeat every 28 years, the idea was to just input the next 10 years of data without creating this function, but I like difficulties so I decided to create it anyway.
Function parameters:
Example of using this function in code:
Request: Second Friday in February 1980.
Get the code for that number:
Integer day = func_day_o_w( 1980 , 2 , 5 , 2 );
Request: Last Thursday of December 2013
Get the code for that number:
Integer day=func_day_o_w( 2013 , 12 , 4 , 5 );
There is also attached the "DayOfWeek.mq5" script. It uses this function to find the date based on the first example ( second Friday in February 1980 )
Input parameters:


Check the results using the Windows operating system time bar:

Attachment download
📎 funcdayofweek.mqh (9.4 KB)
📎 dayofweek.mq5 (1.09 KB)
Source: MQL5 #1470
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •