Execution Window Heatmap
Execution cost is not constant through the trading week - spread widens around rollover and news, thins out in the middle of a session, and behaves differently on a Friday close than a Tuesday afternoon. This EA samples the current spread on every tick, sorts each sample into a bucket by weekday and hour, and draws a live 7x24 heatmap panel on the chart: green cells are the cheapest windows observed, red cells the costliest, relative to everything else recorded so far. The same table is exported to CSV on every redraw for anyone who wants to chart it externally or feed it into a scheduler. Spread sampling is free and always on - it only reads the current quote. Slippage and rejection rate are a different matter: measuring them for real requires actually sending an order and watching what comes back, not just reading a number off the chart. That half of the tool is opt-in, off by default. When enabled, once per configured interval it sends one minimum-lot market order, records the difference between the price it asked for and the price it actually got, closes the position again immediately, and counts a failed send as a rejection for that hour's bucket. It is a genuinely tiny, genuinely real trade - not a simulation - which is the only honest way to measure what a broker's server actually does at 3am on a Sunday versus 2pm on a Tuesday. Notes and limitations With InpMeasureExecution off this EA never sends an order and carries no trading risk beyond the CPU cost of sampling. With it on, it WILL send real minimum-lot market orders on a live schedule and close them again immediately - the cost is small (one minimum lot's worth of spread per test, repeated on the configured interval) but it is real money on a real account, not a simulation, so only enable it on an account you are comfortable testing on. Buckets accumulate for as long as the EA stays attached; detaching and reattaching starts the averages over. The heatmap's colour scale is relative to the range observed so far, not to any fixed cost threshold, so early in the sampling window the colours mean less than they do after a full week. On a netting account, if a foreign-magic position already sits on the test symbol, that test window is skipped rather than forced through, so the bucket for that window may have fewer samples than its neighbours.
Expert advisor · MT5 · v1.0 · Free
About Execution Window Heatmap
Execution Window Heatmap is an expert advisor (trading robot) for MetaTrader 5. It has 8 settings, such as Measure execution, Test interval minutes and Magic. MQL source code included.
Files in the download: ExecutionWindowHeatmap.ex5, ExecutionWindowHeatmap.mq5, ExecutionWindowHeatmap.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Measure execution | false | RISK: also send tiny live test trades to measure slippage/rejections (see notes) |
| Test interval minutes | 60 | Minutes between test trades, only used when InpMeasureExecution is true |
| Magic | 20261209 | Magic number tagging this EA's own test trades |
| Max slippage points | 30 | Slippage tolerance passed to the test trade |
| Redraw seconds | 30 | Seconds between heatmap redraws |
| Csv file name | ExecutionWindowHeatmap.csv | Bucket export, in MQL5\Files |
| Panel x | 20 | Heatmap panel X offset, pixels from the chart corner |
| Panel y | 20 | Heatmap panel Y offset, pixels from the chart corner |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Trading Sessions · News Trading · MT5 Expert Advisor · MQL5 Source Code