Spread History Recorder
Every broker quotes a "typical" or "average" spread somewhere on their website. It is measured however makes the broker look best, over whatever window they chose, and it says nothing about what actually happens on your account during news, rollover or a thin Asian session. The only way to know your real cost is to record it yourself. This tool attaches to one chart and samples every symbol in its watch list on the same fixed interval, regardless of how many ticks each symbol receives. Sampling on a timer instead of on every tick matters: a tick-driven logger over-samples an active symbol and under-samples a quiet one relative to wall-clock time, which quietly breaks any later comparison between symbols. A fixed interval samples everything on the same clock, so the resulting CSV rows line up cleanly for a spreadsheet pivot or a Python notebook. Each row records the timestamp, symbol, bid, ask, spread in points and spread in pips, with the point-to-pip conversion done correctly for 3 and 5 digit brokers. The file is opened, appended to and closed on every sample rather than held open for the whole session, so nothing is lost if the terminal is closed uncleanly. Notes and limitations - Only symbols already selectable by this broker can be sampled; an unknown symbol name simply produces no valid quote and is skipped with a log line rather than a fake zero row. - A symbol with no incoming quote yet (market closed, or not yet ticked since being added to Market Watch) is skipped for that sample rather than logged with a stale price. - This is a recorder only - it never places, modifies or closes an order. - Spread is sampled, not integrated; very short spread spikes between samples are not captured. Lower InpSampleIntervalSeconds if that resolution matters for your study.
Expert advisor · MT4 · v1.0 · Free
About Spread History Recorder
Spread History Recorder is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Watch symbols, Sample interval seconds and Csv file name. MQL source code included.
Files in the download: SpreadHistoryRecorder.ex4, SpreadHistoryRecorder.mq4, SpreadHistoryRecorder.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Watch symbols | Comma separated symbols to watch (blank = chart symbol only) | |
| Sample interval seconds | 60 | Seconds between samples, applied per symbol on the same clock |
| Csv file name | SpreadHistoryRecorder.csv | Output file, in MQL4\Files |
| Use common folder | false | Write to the shared Terminal\Common\Files folder instead |
| Append to existing file | true | Keep adding to an existing file instead of starting fresh |
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 · News Trading · Alerts · MT4 Expert Advisor · MQL4 Source Code