Loading…

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 · MT4 · v1.0 · Free

About Midnight Open Reference Study

Midnight Open Reference Study is a script for MetaTrader 4. 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.mq4, MidnightOpenStudy.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to study, blank = this chart's symbol
Lookback days250Trading days to scan back through M1 history
Save csvtrueWrite the per-hour table to a CSV file

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria