TimeNewYork() function equivalent?

 

Hello,


how can one get the same, actual New York-time all year long, no matter whether it's summer- or winter-time there?


How can this be achieved with MQL5 if one doesn't live in the New York-time zone themselves? Something like the missing TimeNewYork()-function?


Because MQL5 only provides our respective local time and our respective MT5-server time. The problem is that the time difference to New York (of both those time zones) are variable, because New York has a longer summer time than the others. So for three weeks per year, the time difference deviates fom the norm, it's variable and I have no clue how to calculate it with the MQL5 built-in tools (or anything else that also works in the Strategy Tester).


Any ideas?

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 
See the examples on https://www.mql5.com/en/code/48419

Example: "Convert the current local time in all timezones to the broker time"
 

Hi

You can also get GMT time – so you can calculate new York time from GMT time. Something like:

datetime nyTime = TimeGMT() – 4*3600; //gmt time minus 4 hours

Best Regards