Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2013.01.28 10:29
Libraries

Day Of Week - library for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

Views:
2949
Rating:
votes: 28
\MQL5\Include\\MQL5\Scripts\
dayofweek.mq5 (1.09 KB)view

The "Day of Week" function is designed to determine the number of required month according to data of the week and the day of the week inside this month. For example, we need the third Friday in February, 2000 or the fourth Wednesday in November, 1998. The function allows to determine the number of search day.

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 are such dates as Martin Luther King, Jr. Day which is celebrated on the third Monday of January. I could not find this day using the standard functions. As the days of the week are repeating every 28 years, the idea was just to enter the data for the next 10 years and do not create this function, but I like difficulties that is why I decided to make it anyhow.

Function parameters:

  • int year - a year,
  • int month - a month,
  • int day_o_w - the day of the week required (Monday=1, Tuesday=2,..., Sunday=7),
  • int sequence - the number of the day of the week in this month (from 1 to 5, when enter the fifth day, if this day is absent in this month, then the previous, i.e. the fourth day will output).

The example of using this function in the code:

Required: the second Friday in February, 1980.

The code for obtaining this number:

int day=func_day_o_w(1980,2,5,2);

Required: the last Thursday in December, 2013

The code for obtaining this number:

int day=func_day_o_w(2013,12,4,5);

Also the "DayOfWeek.mq5" script is attached. It uses this function to find the date according to the first example (the second Friday in February, 1980)

Input parameters:


The result:


 

Check the result using Windows OS time bar:


Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/1470

MaxMinRange MaxMinRange

Two histograms to define the current market situation

ExTrend ExTrend

The channel formed by two trend lines drawn at the high and low formed by the last two fractals

Range Range

The Range indicator calculates the range expansion index and displays the range of price change in the current bar

Exp_ColorCoppock Exp_ColorCoppock

The trade system using the ColorCoppock oscillator.