Weekend Quote Leak Detector
Occasionally a symbol's stored history contains a bar that opens and closes entirely inside the weekend, when no market for that instrument was open at all. This can come from a corrupted history file, a broker's server clock drifting across a weekend boundary, or a data provider stitching synthetic bars into a feed. Any backtest, session study or seasonality tool built on that history silently inherits the bad data. This script checks for it directly. It reads recent bars for a chosen timeframe across every Market Watch symbol (or an explicit list), and flags any bar whose ENTIRE span - both its open and close instant - falls inside the closed-market window: all of Saturday, Friday from the broker's close hour onward, and Sunday before the broker's open hour. A bar merely straddling the boundary, such as one opening just before Friday close, is normal market activity and is deliberately left alone; only a bar with no legitimate reason to exist at all is flagged. The close and open hours are configurable inputs rather than a hardcoded schedule, because brokers genuinely differ - some close Friday 21:00 server time, others 22:00; Sunday reopen times vary similarly. Set them from the broker's own published trading hours before relying on the result. Notes and limitations A symbol with no history loaded for the chosen timeframe is skipped and reported, not silently ignored. The weekend window definition here is a simple day/hour rule; it does not account for holiday closures or DST transitions shifting the broker's actual close and open times on a specific week - a false flag near a known holiday should be checked by hand. Console output is capped at 20 lines per symbol to avoid flooding the log; the CSV export (when enabled) always contains every flagged bar.
Script · MT4 · v1.0 · Free
About Weekend Quote Leak Detector
Weekend Quote Leak Detector is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Symbol list, Timeframe and Bars to scan. MQL source code included.
Files in the download: WeekendQuoteLeakDetector.mq4, WeekendQuoteLeakDetector.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol list | Comma-separated symbols ("" = every Market Watch symbol) | |
| Timeframe | PERIOD_M1 | Timeframe to scan |
| Bars to scan | 5000 | How many recent bars to check per symbol |
| Friday close hour | 22 | Server-time hour the market closes on Friday (0-23) |
| Sunday open hour | 22 | Server-time hour the market reopens on Sunday (0-23) |
| Export csv | false | Also write flagged bars to a CSV file |
| Delimiter | DelimiterComma | CSV column separator |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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 · Alerts · MT4 Script · MQL4 Source Code