Broker Clock: Accurate Time Conversions for Trading

Broker Clock: Accurate Time Conversions for Trading
Download ALL MT5 indicators (6135)
YouTube Video Thumbnail



Similar MetaTrader Tools

Broker Clock: Accurate Time Conversions for Trading

Info

The Broker Clock: Accurate Time Conversions for Trading is a Indicator for MetaTrader 5 that accurate time conversions are crucial for automated trading, especially when dealing with different time zones and daylight saving changes. Many Expert Advisors (EAs) are designed to trade at specific market opening times, such as "08:00 London" or "09:30 New York".

Usage

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

Platform

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

Setup

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


How to Install and Use Broker Clock: Accurate Time Conversions for Trading

1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.

2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.

3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.

4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.

Frequently Asked Questions

Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."

Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).

Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.

What this tool does

Accurate time conversions are crucial for automated trading, especially when dealing with different time zones and daylight saving changes.

Typical Use Case

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

Compatible Platform & Setup

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

Description & Settings

Related: NY Close Candles for MT4/MT5: Consistent H4/D1 Charts Across All Brokers - another powerful indicator for MetaTrader 5 traders.

Accurate time conversions are crucial for automated trading, especially when dealing with different time zones and daylight saving changes.

Also recommended: Real-Time Broker Execution Analysis: Spread, Swap, and Cost Indicator - similar indicator with strong performance on MetaTrader 5.


Many Expert Advisors (EAs) are designed to trade at specific market opening times, such as "08:00 London" or "09:30 New York". However, these times must be converted to the broker's server time. This conversion is complicated by seasonal changes in daylight saving time, which affect different regions at different times. Most brokers adjust their server time (e.g., UTC+2 in winter to UTC+3 in summer) based on US daylight saving dates. European daylight saving typically starts and ends a few weeks later or earlier, creating periods where a fixed server time offset may not correspond to the intended market hour.

The MetaTrader Strategy Tester can also present challenges. The `TimeGMT()` function directly reflects the server clock, making it difficult to measure and account for the time zone offset accurately during backtesting.

BrokerClock.mqh is a comprehensive include file designed to address these issues. It incorporates daylight saving rules for major financial centers, ensuring accurate time conversions across different dates and broker configurations.

Key Features:
- Daylight saving rules for the US, EU (London, Frankfurt), and Sydney. Tokyo does not observe daylight saving.
- Support for three common broker server clock configurations: UTC+2/+3 based on US dates (common for "New York close" brokers), UTC+2/+3 based on EU dates, and UTC+0/+1 for London-centric servers. A fixed offset option is also available.
- In live trading, the `SERVER_AUTO` mode automatically detects the current server offset by comparing it to your PC's clock (`TimeGMT`). For backtesting, you should explicitly set the server type.
- Bidirectional time conversions between server time, UTC, and local market time.
- The `ZoneTimeOnServer()` function allows you to easily get a specific market time (e.g., "08:00 London today") converted into your broker's server time with a single function call.
- The library has been rigorously tested against the IANA time zone database from 2015 to 2030, confirming its accuracy.

Example Usage:
#include "BrokerClock.mqh" CBrokerClock clock; int OnInit() { clock.Init(SERVER_NY_CLOSE); // Use SERVER_AUTO on a live account return(INIT_SUCCEEDED); } void OnTick() { datetime now = TimeCurrent(); datetime open = clock.ZoneTimeOnServer(now, CLOCK_LONDON, 8, 0); // Today's 08:00 London, in server time if(now >= open && now < open + 60) Print("London is opening"); }

BrokerClockPanel Indicator:
An accompanying indicator, BrokerClockPanel, visually displays the server time, UTC, and the current status (including daylight saving shifts) of the five major markets. It also shows the server time for any specified market hour. To use this indicator, place BrokerClock.mqh in the same directory.

Important Notes:
- The daylight saving rules implemented are based on the US rule since 2007 and Sydney's since 2008. Dates prior to these are not covered.
- During the autumn time change, one hour occurs twice. In such cases, the conversion functions will return the earlier of the two moments.
- When using `SERVER_AUTO` mode, ensure your PC's clock is synchronized with internet time sources, as the offset is measured against `TimeGMT()` (your PC's time).

You may also like: Return-to-Mean Clock: Measuring Price Reversion to Moving Averages - excellent alternative for indicator users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version   "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property indicator_chart_window
#property indicator_plots 0
#include "BrokerClock.mqh"
input ENUM_SERVER_RULE InpRule      =SERVER_AUTO;
input double           InpFixedHours=0.0;
input ENUM_CLOCK_ZONE  InpEventZone =CLOCK_LONDON;

.......

Leave your opinion, ask a question, share some knowledge

⚠ 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 Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.