Spread Widening By Hour Study
"The spread gets wide around the news" is a common belief and often a true one, but "around the news" is not a time a strategy's session filter can use. This script turns a raw spread log into a table: average, and the minimum and maximum seen, for every hour of every weekday, so the actual widening pattern - not the memory of it - is what drives a decision. MetaTrader keeps no historical spread of its own. Bars carry open, high, low, close and tick volume, and nothing else; the platform simply never wrote down what the spread was five minutes ago, let alone five weeks ago. The only spread history that exists is one that was recorded while it happened, which is exactly what this catalogue's Export Ticks script does - it samples live bid, ask and spread for a chosen duration and writes a row every time the price changes. This script is built to read that file back. Cells with too few samples are left out of the table rather than reported as if they were reliable. An hour seen only twice in the log tells you almost nothing about that hour in general; InpMinSamplesPerCell sets the bar for what counts as enough, and any cell short of it is silently excluded from both the printed table and the CSV export - silently in the sense of not padded with a misleading number, though the row is still absent for anyone checking sample counts in the file. Notes and limitations - The study is only as good as the log feeding it. A capture taken during one unusually quiet or unusually volatile week will not represent a typical one; longer and more varied captures produce a more trustworthy table. - Hour and weekday are read from the timestamps in the file exactly as written - if the export was taken in server time, the table is in server time, and if in local time, local time. The script does not convert between them. - A file recorded across a daylight-saving change can show an odd discontinuity around the change date; this script does not attempt to correct for it. - Weekend rows will typically show few or no samples for a forex log, since most such symbols do not quote then - that is normal, not a bug.
Script · MT5 · v1.0 · Free
About Spread Widening By Hour Study
Spread Widening By Hour Study is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as File name, Min samples per cell and Export csv. MQL source code included.
Files in the download: SpreadWideningByHourStudy.ex5, SpreadWideningByHourStudy.mq5, SpreadWideningByHourStudy.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| File name | spread_log.csv | File to read, from MQL5\Files |
| Min samples per cell | 5 | Minimum samples before a cell is reported |
| Export csv | true | Write the full hour/weekday matrix to a CSV |
| Delimiter | DelimiterComma | Column separator, both files |
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 · News Trading · Alerts · MT5 Script · MQL5 Source Code