Trading Hours Empirical Mapper
A broker's published session table is marketing copy, not telemetry. It tells you what the sales page says trading hours are, not what the server actually did today, yesterday, or on the Monday after a daylight-saving change one side of the world observed and the other did not. MQL4 has no API that returns a broker's declared session table - that only exists on MQL5, through SymbolInfoSessionQuote(). The only way to know a broker's real hours from inside MQL4 is to read them back out of the bars that actually arrived. This script does exactly that: it walks every bar loaded for a chosen symbol and timeframe within a lookback window, buckets each one by weekday, and records the earliest and latest time-of-day a bar was seen for that weekday - in server time, the same clock every advertised session table is normally quoted in. If you also type in the advertised session string for a given weekday (server time, "HH:MM-HH:MM"), the script diffs the empirical window against it and flags any start or end that differs by more than your tolerance. Leaving a weekday's input blank simply skips the diff for that day and reports the empirical window on its own - useful even with no advertised value in hand, since it is often the first time anyone has actually looked. The empirical window is a floor and ceiling of ACTIVITY, not a guarantee of continuous quotes across it - a symbol that trades thinly around midday can still show an early-morning start and late-evening end with a quiet gap in between that this script does not detect. It answers "when did bars first and last appear this weekday", which is the specific, useful question a published session table cannot answer for a broker's real, current behaviour. Notes and limitations - Only bars already loaded in the terminal are scanned. If the report looks thin, scroll the chart back to load more history before running again. - The empirical window is the earliest/latest bar seen, not proof of continuous coverage across it - a symbol with a quiet midday lull still reports its morning start and evening end as one unbroken window. - Advertised session strings are read in server time. If your broker publishes hours in a different timezone, convert them before typing them in, or the diff will be meaningless. - Weekend (Saturday/Sunday) bar activity is reported as a note, not diffed against any advertised value, since almost no broker advertises weekend hours in the first place. - A daylight-saving transition inside the lookback window blends both sides of the shift into one weekday's earliest/latest reading - run with a shorter InpLookbackDays straddling just one side of a known DST change if you need to isolate it.
Script · MT5 · v1.0 · Free
About Trading Hours Empirical Mapper
Trading Hours Empirical Mapper is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Symbol, Timeframe and Lookback days. MQL source code included.
Files in the download: TradingHoursEmpiricalMapper.ex5, TradingHoursEmpiricalMapper.mq5, TradingHoursEmpiricalMapper.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to scan (blank = this chart's symbol) | |
| Timeframe | PERIOD_M1 | Timeframe used to detect quote arrival (finer = more accurate) |
| Lookback days | 30 | Only bars within this many days of now are counted |
| Tolerance minutes | 15 | Advertised vs empirical diff below this is not flagged |
| Monday session | Advertised Monday session, server time, "HH:MM-HH:MM" (blank = skip) | |
| Tuesday session | Advertised Tuesday session, server time | |
| Wednesday session | Advertised Wednesday session, server time | |
| Thursday session | Advertised Thursday session, server time | |
| Friday session | Advertised Friday session, server time |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Trading Sessions · Time Filter · Alerts · MT5 Script · MQL5 Source Code