Discussion of article "Dealing with Time (Part 1): The Basics"

 

New article Dealing with Time (Part 1): The Basics has been published:

Functions and code snippets that simplify and clarify the handling of time, broker offset, and the changes to summer or winter time. Accurate timing may be a crucial element in trading. At the current hour, is the stock exchange in London or New York already open or not yet open, when does the trading time for Forex trading start and end? For a trader who trades manually and live, this is not a big problem.

As said, traders who sit in front of the screen to buy and sell can easily handle the different times. Be it via the internet or certain functions, values or clocks that the PC keeps available and that can be retrieved at any time with MQL functions like TimeGMT(), TimeGMTOffset() and others. The situation is different if one wants to write and test a trading program with historical data that trades time-related. Actually, analogous to live trading, the question should be just as easy to answer.

Starting from UTC (Universal Coordinated Time) or Greenich Mean Time (GMT, https://greenwichmeantime.com/what-is-gmt/), one would simply have to add the geographic or instrument-related time shift and one would know what time it is where. But it is not that simple. There is the changeover of winter and summer time (DST or Daylight Saving Time), which, depending on the time, adds or subtracts 1 hour. However, not uniform, but each country or region such as Europe has its own definition, sometimes constant for years (EU and USA) or changed every now and then as in Russia, where it was abolished in 2014. In the EU, there was a discussion in 2018, including a survey on the question of abolishing the annual time change (https://ec.europa.eu/germany/news/20180831-konsultation-sommerzeit_de), which resulted in a majority in favor of abolition, so that the Commission submitted a legislative proposal for the end of the time change (https://ec.europa.eu/germany/news/20180914-kommission-gesetzesvorschlag-ende-zeitumstellung_de), which then came to nothing again.

Author: Carl Schreiber

 

Thank you for your article,

I was coding some functions and was stuck on some of the time functions and didnt know how to approach it.

I hope in the future there are more articles on more of the basics of the language and they are extended upon.

Most of my time is spent on creating simple function based the bare bones functionality that is currently present. Its nothing bad I actually enjoy expanding my understanding its really hard to find basic laymen concepts sure the AI and other functionality is great but most of us are normal people working and on the side trading and if the understand was easier to understand more people would want to use the platform the sentiment that i get from forums and other is that well not not talk about it. Thank you for your contributions I hope there is more information like this to come a redo of articles of just the basics is what I really desire and this is high on the list of really good explainations of functions and uses..

 
pi.xero #:

Thank you for your article,

I was coding some functions and was stuck on some of the time functions and didnt know how to approach it.

I hope in the future there are more articles on more of the basics of the language and they are extended upon.

Most of my time is spent on creating simple function based the bare bones functionality that is currently present. Its nothing bad I actually enjoy expanding my understanding its really hard to find basic laymen concepts sure the AI and other functionality is great but most of us are normal people working and on the side trading and if the understand was easier to understand more people would want to use the platform the sentiment that i get from forums and other is that well not not talk about it. Thank you for your contributions I hope there is more information like this to come a redo of articles of just the basics is what I really desire and this is high on the list of really good explainations of functions and uses..

Thank you! I am glad it helps you.
 

Brilliant article and help! I wasted many months looking at test results that just were invalid.
There should be any hint if the tester is used: "Take care with time dependend strategies in the tester.. " something like that. How could one know?

I think in the first table with the time zones and acronyms you mean "New York, summer time" in row 3 (EDT, UTC-4), not New York, normal time.

 

Thank you very much, but I won't change anything here as the calculation of some of the integrated functions has been changed (I assume in the context of the extended use of matrices and vectors) I posted a new version of all functions and macros and one more here: https://www.mql5.com/en/code/45287.

And there are two programs to test und check the way it works and can be used.

Dealing with time (2) functions
Dealing with time (2) functions
  • www.mql5.com
Calculate DST for USA, EUR, AUD and RUB and the offset time of the broker automatically from the 70's until 2030 - even in the Strategy Tester of MQ.
 
Carl Schreiber #:

Thank you very much, but I won't change anything here as the calculation of some of the integrated functions has been changed (I assume in the context of the extended use of matrices and vectors) I posted a new version of all functions and macros and one more here: https://www.mql5.com/en/code/45287.

And there are two programs to test und check the way it works and can be used.

Alright, will check your new versions, thanks again.

Reason: