myeatrade

MQL4 Reference

MQL4 Date & Time functions (1)

A group of functions providing the working with data of the datetime type (integer representing the amount of seconds elapsed from midnight, 1 January, 1970).

 

Year()

int Year()

Returns the current year, i.e., the year of the last known server time.

Note: At the testing, the last known server time is modelled.

Sample:

  // return if the date is within the range from 1 Jan. to 30 Apr., 2006.
    if(Year()==2006 && Month()<5)
    return(0);

Month()

int Month()

Returns the current month as number (1-January,2,3,4,5,6,7,8,9,10,11,12), i.e., the number of month of the last known server time.

Note: At the testing, the last known server time is modelled.

Sample:

  if(Month()<=5)
    return("the first half year");

Day()

int Day()

Returns the current day of the month, i.e., the day of month of the last known server time.

Note: At the testing, the last known server time is modelled.

Sample:

  if(Day()<5) return(0);

DayOfWeek()

int DayOfWeek()

Returns the current zero-based day of the week (0-Sunday,1,2,3,4,5,6) of the last known server time.

Note: At the testing, the last known server time is modelled.

Sample:

  // does not work on holidays.
  if(DayOfWeek()==0 || DayOfWeek()==6) return(0);

DayOfYear()

int DayOfYear()

Returns the current day of the year (1 means 1 January,..,365(6) does 31 December), i.e., the day of year of the last known server time.

Note: At the testing, the last known server time is modelled.

Sample:

  if(DayOfYear()==245)
    return(true);

Hour()

int Hour()

Returns the hour (0,1,2,..23) of the last known server time by the moment of the program start (this value will not change within the time of the program execution).

Note: At the testing, the last known server time is modelled.

Sample:

  bool is_siesta=false;
  if(Hour()>=12 || Hour()<17)
     is_siesta=true;

Minute()

int Minute()

Returns the current minute (0,1,2,..59) of the last known server time by the moment of the program start (this value will not change within the time of the program execution).

Sample:

  if(Minute()<=15)
    return("first quarter");

Seconds()

int Seconds()

Returns the amount of seconds elapsed from the beginning of the current minute of the last known server time by the moment of the program start (this value will not change within the time of the program execution).

Sample:

  if(Seconds()<=15)
    return(0);

TimeCurrent()

datetime TimeCurrent()

Returns the last known server time (time of incoming of the latest quote) as number of seconds elapsed from 00:00 January 1, 1970.

Note: At the testing, the last known server time is modelled.

Sample:

  if(TimeCurrent()-OrderOpenTime()<360) return(0);
This article url: http://www.myeatrade.com/441/

Please login to post comment, if you haven't account you can register free