Libraries: High-Performance Time Functions (TimeUtils) - page 3

 
Really good to use and Good job.
 
Supreb. Allways hating working with date and time variables.. This makes it so much easier!! Thanks
 

Is there a way to identify the 4th Thursday of November as it approaches each year using this library?

To be clear, I'm trying to get the U.S. Thanksgiving holiday date in advance of its arrival but it's a moving target in terms of its date.

Although trading is allowed in the U.S. on Thanksgiving, I would like to filter it out x days in advance and y days after.

 
Ryan L Johnson #:

Is there a way to identify the 4th Thursday of November as it approaches each year using this library?

To be clear, I'm trying to get the U.S. Thanksgiving holiday date in advance of its arrival but it's a moving target in terms of its date.

Although trading is allowed in the U.S. on Thanksgiving, I would like to filter it out x days in advance and y days after.

Please disregard the above. I found the holiday listed in MQ's U.S. Calendar even though it's not an FX market holiday in the U.S. Will access from there.

Thanks anyway. Nice library.

 
Ryan L Johnson #:

Is there a way to identify the 4th Thursday of November as it approaches each year using this library?

To be clear, I'm trying to get the U.S. Thanksgiving holiday date in advance of its arrival but it's a moving target in terms of its date.

Although trading is allowed in the U.S. on Thanksgiving, I would like to filter it out x days in advance and y days after.

This:

void OnStart()
  {
   // Code for the current year
   int currYear = GetYear(TimeCurrent());

   datetime Nov4thThurs = GetNthWeekdayInYearMonth(currYear, 11, 4, THURSDAY);
   //string formatted = TimeToString(Nov4thThurs, TIME_DATE);
   string formatted = TimeFormat(Nov4thThurs, "DDD, DD/MM/YYYY");
   Print(formatted);

   // Code for 10 years
   for(int y = 2020; y < 2030; y++)
     {
      Nov4thThurs = GetNthWeekdayInYearMonth(y, 11, 4, THURSDAY);
      string formatted = TimeFormat(Nov4thThurs, "DDDD, D MMMM YYYY");
      Print(formatted);
     }

  }

Result:

/*
  Thu, 24/11/2022
  Thursday, 26 November 2020
  Thursday, 25 November 2021
  Thursday, 24 November 2022
  Thursday, 23 November 2023
  Thursday, 28 November 2024
  Thursday, 27 November 2025
  Thursday, 26 November 2026
  Thursday, 25 November 2027
  Thursday, 23 November 2028
  Thursday, 22 November 2029

*/

 
Update 6 July 2026 - version 2.00

  • New March-based conversion routines derived from the Neri–Schneider calendar algorithm (here) + validation script.
  • Removed "performance" mode.