Midnight Open Reference Study
Several intraday trading approaches treat the midnight (broker-time) open as a meaningful reference level - price is said to "return" to it, or to trade consistently above or below it once a directional bias sets in. This script checks the claim directly against M1 bar history instead of taking it on faith. For each trading day in the lookback window, the script records the open of the first M1 bar at or after broker-time midnight, then for every hour of that day measures the signed distance between price at that hour and the midnight open. Those distances are aggregated across all scanned days into a 24-row table: for each hour, the mean signed distance, its standard deviation, the mean absolute distance, and the percentage of days price was above the midnight open at that hour. A "return to midnight open" thesis only holds up if BOTH the mean absolute distance stays small AND the above/below split stays close to 50/50 at the relevant hour - a mean near zero on its own can hide a bimodal split where price is usually far above OR far below, never actually near the open itself. The printed table gives both figures side by side so that distinction cannot be missed. Notes and limitations - A calendar day with no M1 bar within five minutes of broker-time midnight (weekend, data gap) is skipped entirely rather than having its midnight open guessed or interpolated. - The same five-minute tolerance applies to each hourly sample point; an hour with a genuine data gap is skipped for that day rather than fabricated. - "Midnight" here means broker-server time as loaded in the terminal, not the trader's own local time zone or UTC. - This reports a historical pattern, not a trading signal - it does not say whether any observed tendency is large enough to trade profitably after spread and slippage.
Script · MT5 · v1.0 · Free
About Midnight Open Reference Study
Midnight Open Reference Study is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 3 settings, such as Symbol, Lookback days and Save csv. MQL source code included.
Files in the download: MidnightOpenStudy.ex5, MidnightOpenStudy.mq5, MidnightOpenStudy.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to study, blank = this chart's symbol | |
| Lookback days | 250 | Trading days to scan back through M1 history |
| Save csv | true | Write the per-hour table to a CSV file |
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: Alerts · MT5 Script · MQL5 Source Code