Spread At Fill Recorder
Post-trade reviews usually only have the average spread for the session, not the actual figure at each individual fill - and that per-fill number is what actually explains why one entry slipped and another did not. This EA scans the open-order pool every tick and, the instant a ticket appears that was not there a moment before, writes one CSV row with the ticket, symbol, type, lots, open price, open time, magic number and the spread observed at that instant. It attaches to any chart on the account and records every new ticket by default, or only tickets carrying a chosen magic number via InpMagicFilter - useful when several EAs and manual trades share one account and only one system's fills matter for this log. Tickets already open when the EA attaches are baselined without being recorded, since their true fill-time spread was never observed. Notes and limitations - This is the spread at DETECTION - at least one tick after the fill, since polling happens on OnTick, not a value read from inside the broker's own execution report. MQL4 exposes no such field. On a fast market the true fill-instant spread can already have moved by the time this EA notices. - Only works for orders visible on THIS account through this terminal. It cannot see fills on another account or another terminal instance. - Tickets open before the EA attaches are baselined silently, not recorded, because their fill-time spread was never observed. - This EA never places, modifies or closes any order - it only reads the order pool.
Expert advisor · MT5 · v1.0 · Free
About Spread At Fill Recorder
Spread At Fill Recorder 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 Log file name, Magic filter and Include pending. MQL source code included.
Files in the download: SpreadAtFillRecorder.ex5, SpreadAtFillRecorder.mq5, SpreadAtFillRecorder.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Log file name | SpreadAtFillRecorder.csv | CSV log, in MQL5\Files\ |
| Magic filter | 0 | 0 = record every position/order, otherwise only this magic number |
| Include pending | false | Also record pending orders the instant they appear (not just market fills) |
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 · Alerts · MT5 Expert Advisor · MQL5 Source Code