Entry Delay Cost Study
A signal measured on a backtest that enters on the exact signal bar's close rarely matches how a manual or semi-automated trader actually acts - by the time the chart is checked, an order placed, or an alert read, several bars may have passed. This script measures the cost of that delay directly, on real history. The signal is a simple, fully mechanical moving-average crossover, computed once. For every signal bar, the script measures the forward return over a fixed InpHoldingBars horizon starting from the signal bar's own close (delay 0), then again starting 1, 2, up to InpMaxDelayBars bars later - always holding for the SAME number of bars regardless of the delay, so only the entry timing changes between rows, not the exit rule as well. Mixing a changing holding period into the same sweep would blur delay cost together with holding-period effects and make the decay curve unreadable. For each delay it reports the sample count, mean and median forward return in pips, and the win rate - so a trader can see not just whether the average edge shrinks with delay, but whether it degrades gracefully or falls off a cliff after a specific number of bars. Notes and limitations The signal is a plain SMA crossover chosen for reproducibility, not presented as a profitable strategy on its own - the point of this submission is the shape of the delay-cost curve, not the base signal's own quality. Forward returns are measured on bar closes with no spread, commission or slippage applied. Real trading costs subtract a roughly constant amount per trade regardless of delay, so they would shift every row down by a similar figure rather than change the shape of the decay curve. A signal bar whose delayed entry or exit would fall past the end of the loaded history is dropped from that delay's sample rather than extrapolated - sample counts can differ slightly between delay rows for that reason, most noticeably at the largest delays tested. This is a historical measurement over one fixed sample and signal definition. The specific decay shape found here (gradual vs. a sharp early drop-off) is informative about this instrument and timeframe, not a universal law of entry timing.
Script · MT5 · v1.0 · Free
About Entry Delay Cost Study
Entry Delay Cost Study is a script for MetaTrader 5 based on Moving Average. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Timeframe, Fast ma period and Slow ma period. MQL source code included.
Files in the download: EntryDelayCostStudy.ex5, EntryDelayCostStudy.mq5, EntryDelayCostStudy.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Timeframe | PERIOD_H1 | Timeframe to study |
| Fast ma period | 10 | Fast SMA period (signal) |
| Slow ma period | 40 | Slow SMA period (signal) |
| Holding bars | 10 | Forward holding horizon measured, in bars |
| Max delay bars | 10 | Largest entry delay tested, in bars |
| Max bars | 5000 | Most recent bars to study |
| Save csv | true | Write the per-delay table to a CSV file |
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: Buy/Sell Arrows · Alerts · Moving Average · MT5 Script · MQL5 Source Code