Entry Timing Cost Estimator
Generic "spread by session" tables are built from someone else's broker and someone else's liquidity conditions. This script builds its own table instead: every time it runs, it appends the current spread reading tagged with the server hour to a small CSV log kept in the sandbox, then rebuilds an hour-of-day average from every sample logged so far on this account, on this broker, at this time of year. The current hour's average spread is compared against a chosen "next session" hour's average, both converted to money at a typed lot size using the symbol's own tick value and tick size - never a hardcoded contract size - so the comparison is a real money figure, not a raw points difference. An hour with too few recorded samples is flagged as provisional rather than presented with the same confidence as a well-sampled one. The estimate only becomes genuinely useful once the log has accumulated readings across a range of hours and days, which is why the script is meant to be run repeatedly through normal trading activity rather than once. Notes and limitations - The recorded history lives in a per-symbol CSV file in MQL4\Files and starts empty on a fresh install - the first several runs exist only to build the log, not to produce a trustworthy comparison yet. - This measures spread seasonality only. It says nothing about how price itself might move while waiting for the next session, which can easily outweigh any spread saving. - The log accumulates indefinitely; delete the CSV file from MQL4\Files to reset the history for a symbol. - Averages are simple means, not medians, so a single unusually wide spread reading (a news spike caught mid-sample) can skew a thin hour.
Script · MT4 · v1.0 · Free
About Entry Timing Cost Estimator
Entry Timing Cost Estimator is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Lots, Next session hour and Log sample now. MQL source code included.
Files in the download: EntryTimingCostEstimator.mq4, EntryTimingCostEstimator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Lots | 1.00 | Lot size used to price the spread difference in money |
| Next session hour | 8 | Server hour (0-23) marking the next session's typical open |
| Log sample now | true | Append the current spread reading before analysing |
| Min samples for trust | 5 | Minimum samples in an hour before its average is trusted |
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