Checking the server time changes due to the daylight saving time (DS T) changeover

Checking the server time changes due to the daylight saving time (DS T) changeover
Download ALL MT5 scripts (325)
YouTube Video Thumbnail

Similar MetaTrader Tools

Checking the server time changes due to the daylight saving time (DS T) changeover

Info

The Checking the server time changes due to the daylight saving time (DS T) changeover is a Script for MetaTrader 5 that unfortunately, i discovered that some brokers are a bit sloppy with the server timechange due to the daylight saving time (dst), which i did not expect and which surprised me a lot. The FOREX session is exactly 120 hours:from Sunday 5:00 p.

Usage

This tool is typically used for enhancing chart analysis and decision making.

Platform

This Script works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Scripts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use Checking the server time changes due to the daylight saving time (DS T) changeover

1. Installation: Move your script file into the MQL/Scripts directory and restart the platform.

2. Execution: Drag the script onto a chart; it will perform a one-time action, such as closing all open orders or clearing chart objects.

3. Editing: Use MetaEditor (F4) to modify code, click "Compile," and verify no errors appear in the terminal before running.

4. Removing: Scripts stop automatically, but you can remove them manually by right-clicking the chart and choosing "Remove Script."

Frequently Asked Questions

Q: How are scripts different from EAs? A: Scripts execute a single action and then stop; EAs monitor the market and trade continuously.

Q: Can I assign a hotkey to a script? A: Yes, right-click the script in the Navigator, select "Set Hotkey," and define your preferred keyboard shortcut.

Q: Why did my script stop? A: Scripts are designed to stop immediately after finishing their programmed command; this is normal behavior.

What this tool does

Unfortunately, I discovered that some brokers are a bit sloppy with the server timechange due to the daylight saving time (DST), which I did not expect and which surprised me a lot.

Typical Use Case

This Script excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Script works on MetaTrader 5. Place the file in the MQL5/Scripts folder and restart the terminal.

Description & Settings

Related: Programming Patterns - Observer - another powerful script for MetaTrader 5 traders.


Unfortunately, I discovered that some brokers are a bit sloppy with the server timechange due to the daylight saving time (DST), which I did not expect and which surprised me a lot.The FOREX session is exactly 120 hours:from Sunday 5:00 p.m. Eastern Standard Time (North America) or EST to Friday 5:00 p.m. EST.The problem arises from the time changes to summer time and winter time, which do nottake place on the same Sundays in the different regions of the world.For example, the USA changes on the 2nd Sunday in March and the 1st Sunday in November,and this also affects the start and end of the FOREX session.The EU changes on the last Sunday in March i.e. after the USA and on thelast Sunday in October i.e. before the USA (see above Timeline).This creates an interim period in which the USA and the EU have a different time differencesthan the normal differences of 5 hours (London), 6 hours (Frankfurt, CET) or 7 hours (Cyprus, EET).In this interim period, this change of the time difference should be reflected in the changedtime stamps of the first and last hours of the FOREX session. So if the FOREX session startson Monday at 00:00 (EET, MQ time), after the USA has changed it should start an hour earlier,i.e. Sunday at 23:00 and end an hour earlier on Friday, i.e. 23:00 (or 22:59:59).But unfortunately I had to find out (and with this script anyone can check this with their broker)that on a MQ demo account and on accounts of some real brokers the first hour always(!) appearson Monday at 00:00, but the last hour, as expected,on Friday at 23:00 (or 22:59) or one hour earlier. This means that the first hour of theFOREX session, in which the trader or an EA could react to weekend events, is missing.Also, the end of the FOREX session can no longer be determined by simply adding 120to the first hour of the FOREX session, e.g. to close all positions before the weekend.This script now checks the broker's time changes in the past and logs all FOREX sessionsthat are obviously incorrect (odd) or not 120 hours. If there are 120 hoursbetween the first and last hour of a FOREX session, nothing is logged.At the end the script prints the last retrieved timestamp, the number of odd sessionsfound and the approximate number of years that have been checked.

Also recommended: Time Server Daylight Savings - similar script with strong performance on MetaTrader 5.

Leider musste ich feststellen, dass manche Broker bei derServerzeitumstellung etwas nachlässig sind, was ich nicht erwartethatte und was mich sehr überrascht hat.Die FOREX-Sitzung dauert genau 120 Stunden:von Sonntag 17:00 Uhr Eastern Standard Time (Nordamerika) bzw. ESTbis Freitag 17:00 Uhr EST.Das Problem entsteht durch die Zeitumstellungen auf Sommerzeit und Winterzeit,die in den verschiedenen Regionen der Welt nicht an denselben Sonntagen stattfinden.Die USA stellen beispielsweise am 2. Sonntag im März und am 1. Sonntag im November um,was auch den Beginn und das Ende der FOREX-Sitzung beeinflusst.Die EU stellt am letzten Sonntag im März, also nach den USA, und amletzten Sonntag im Oktober, also vor den USA, um (siehe obige Timeline).Dadurch entsteht eine Übergangszeit, in der die USA und die EU eine andereZeitdifferenzen haben als die normalen Differenzen von 5Stunden (London), 6 Stunden (Frankfurt, MEZ) oder 7 Stunden (Zypern, EET).In dieser Zwischenzeit sollte sich diese Änderung der Zeitdifferenz in dengeänderten Zeitstempeln der ersten und letzten Stunde der FOREX-Sitzung widerspiegeln.Wenn die FOREX-Sitzung also am Montag um 00:00 (EET, MQ-Zeit) beginnt, sollte sienach der Änderung in den USA eine Stunde früher beginnen, also am Sonntag um 23:00 Uhr,und am Freitag eine Stunde früher enden, also um 23:00 Uhr (oder 22:59:59 Uhr).Aber leider musste ich feststellen (und mit diesem Script kann das jeder bei seinemBroker überprüfen), dass auf einem MQ Demokonto und auf Konten einiger echter Brokerdie erste Stunde immer(!) am Montag um 00:00 erscheint, die letzte Stunde aber erwartungsgemäßam Freitag um 23:00 (bzw. 22:59) oder eine Stunde früher. Damit fehlt die erste Stundeder FOREX Session, in der der Händler oder ein EA auf Ereignisse am Wochenende reagieren könnte.Auch kann das Ende der FOREX Session nicht mehr dadurch bestimmt werden, indem einfach120 zurersten Stunde der FOREX Session hinzuaddiert wird, um z.B. alle Positionen vor dem Wochenende zu schließen.Dieses Script prüft nun die Zeitänderungen des Brokers in der Vergangenheit und loggt alleFOREX Sessions mit, die offensichtlich falsch (odd) oder nicht 120 Stunden sind. Wenn zwischenerster und letzter Stunde einer FOREX-Session 120 Stunden liegen, erfolgt kein Ausdruck im Log.Am Ende druckt das Skript den zuletzt abgerufenen Zeitstempel, die Anzahl der gefundenenverkürzten Sitzungen und die ungefähre Anzahl der überprüften Jahre.

You may also like: Function for checking whether the market is open for trading at the moment by the current symbol - excellent alternative for script users on MetaTrader 5.


Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
RobotFX does not own any of the code provided on this platform. All tools are freely available on the internet; we simply index and re-offer them for download. We are not responsible for any financial losses that may occur. Trading responsibilities rely solely on the traders downloading and using the displayed Expert Advisors, indicators, and scripts. These tools are provided for educational purposes only and may require modification or optimization to align with a trader's specific strategy or needs.
© ROBOTFX - Best MetaTrader Expert Advisors & Indicators