Also read the following ...
Dealing with Time (Part 1): The Basics
Carl Schreiber, 2021.10.01 17:48
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.Dealing with Time (Part 2): The Functions
Carl Schreiber, 2021.10.08 10:31
Determing the broker offset and GMT automatically. Instead of asking the support of your broker, from whom you will probably receive an insufficient answer (who would be willing to explain a missing hour), we simply look ourselves how they time their prices in the weeks of the time changes — but not cumbersome by hand, we let a program do it — why do we have a PC after all.Dmitry Fedoseev, 2013.04.26 11:49
The article focuses on standard MQL5 functions for working with time, as well as programming techniques and practically useful functions for working with time that are required when creating Expert Advisors and indicators. Particular attention is paid to the general theory of time measurement. This article should be of interest primarily to novice MQL5 programmers.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello. I have two MT4 terminals running on a VPS at the same time, on the same broker, etc. The broker GMT is +3. I have an EA where I calculate the offset in the OnInit() function, that is only once, and then I use it for my news filter is order to compare the news time (plus GMT offset) with MT4 time. I've noticed already a couple of times that when the market opens one of the terminals is showing the times wrong. The original file with the times seems to be OK, so the problem has to be with the GMT offset calculation. What I find really strange is that one terminal seems to show the offset perfectly fine...
whereas the other shows some very funky times...
I would understand if both are wrong, but why is it that only one of them is getting the times completely wrong with the same EA running on them? Again, same broker, everything seems to be the same, but I've noticed this upon market open. Is it possible that there's some kind of "residue" variable in some sort of buffer? By the way, I'm doing some wonky thing to avoid the typical offset 2:59:59. I know now that the right code should be something like...
...but so far I'm doing this, and I'm not sure if this is the cause of my problem:
Also, should I use either of these codes in OnTick() rather than in OnInit()? I guess that should correct the offset by taking the correct current TimeCurrent(), but it seems rather unnecessary on every single tick.
Thanks in advance for any hint!