Loading…

Signal Delay Decay Demonstrator

Backtests are usually run as if a signal is acted on the instant it appears. Real execution is never that fast - a strategy runs on a VPS with lag, a trader checks charts once an hour, an alert sits unread for a while. This demonstrator asks the direct question: if the same fast/slow MA cross signal had been acted on D bars late instead of immediately, how much of its average forward move over a fixed window would still have been captured? Every time a new bar closes, the harness reads the directional signal at every delay step from 0 up to InpMaxDelayBars bars ago, then measures the forward price move over a fixed InpHorizonBars window starting from that (delayed) signal bar, signed so a positive number means the market moved in the signal's favour. Because the delayed signal bar and its forward window are both already in the past by the time they are read, nothing here ever depends on data that has not happened yet - the decay curve is built entirely from already-elapsed history, one new sample per delay step every bar. The result, averaged per delay step, is a decay curve: delay 0 shows the signal's raw edge, and each step further out shows how much of it has eroded by the time a late reaction would have acted on it. Notes and limitations - Report-only. This EA places no orders and manages no positions. - Edge is expressed in pips of price movement only - it ignores spread, commission and slippage entirely, all of which would further erode the already-decaying edge shown here in the real world. - A bar where the delayed signal itself is undecided (fast MA equals slow MA) is excluded from that delay step's sample rather than counted as zero edge. - The comparison assumes the SAME horizon window at every delay step. A strategy that would naturally widen its target the later it entered is not modelled - this demonstrator isolates the delay effect on one fixed-horizon read, nothing more.

Expert advisor · MT4 · v1.0 · Free

About Signal Delay Decay Demonstrator

Signal Delay Decay Demonstrator is a script for MetaTrader 4 based on Moving Average. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Fast ma period, Slow ma period and Ma method. MQL source code included.

Files in the download: SignalDelayDecayDemo.ex4, SignalDelayDecayDemo.mq4, SignalDelayDecayDemo.txt.

Settings

SettingDefaultWhat it does
Fast ma period10Fast MA period
Slow ma period30Slow MA period
Ma methodMODE_EMAMA method (0 SMA,1 EMA,2 SMMA,3 LWMA)
Max delay bars10Highest artificial delay tested, in bars (0 = act immediately)
Horizon bars5Fixed forward-return window measured from the (delayed) signal bar
Report every n bars20Write the CSV report after this many new bars processed
Report file nameSignalDelayDecayDemo_report.csvReport file, written under MQL4\Files\

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Moving Average · Buy/Sell Arrows · Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria