Entry Jitter Harness
A backtest that only performs well when every entry lands on the exact signal bar is measuring a fragile edge, and most live trading - manual confirmation, a slow VPS, a busy trade context - does not land on the exact bar. This EA tests that fragility directly rather than assuming it away. The underlying signal is a plain fast/slow MA cross. When it fires, entry is NOT sent immediately: a random jitter of 0 to InpMaxJitterBars extra closed bars is rolled, and the order is only sent once that many additional bars have closed. Every trade's signal bar, jitter amount used, and eventual outcome (profit including swap and commission) are appended to a CSV log. After enough trades, grouping that log by jitter amount and comparing average outcome per group is the honest way to see whether performance degrades as entry gets later - this EA logs the raw data for that comparison, it does not compute the correlation itself, since a single test run rarely has enough trades per jitter bucket for the comparison to mean much on its own. Notes and limitations - RISK WARNING: this EA intentionally trades worse entries than its own signal on purpose, to measure fragility. Run it on a demo account. OnInit posts an Alert if it detects a live account. - Only one position at a time; a signal is dropped if a jittered entry is still pending when a new one would fire. - If a manual or foreign trade appears on the symbol while an entry is pending its jitter, that pending entry is abandoned rather than risk acting on stale context. - The CSV log grows indefinitely across runs unless deleted manually between tests. - No hardcoded contract size; lot sizing is fixed (InpFixedLots) and normalised to the symbol's MODE_LOTSTEP/MIN/MAXLOT.
Expert advisor · MT4 · v1.0 · Free
About Entry Jitter Harness
Entry Jitter Harness is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average and ATR. It has 14 settings, such as Fast ma period, Slow ma period and Ma method. MQL source code included.
Files in the download: EntryJitterHarness.ex4, EntryJitterHarness.mq4, EntryJitterHarness.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 |
|---|---|---|
| Fast ma period | 10 | Fast MA period |
| Slow ma period | 30 | Slow MA period |
| Ma method | MODE_EMA | MA method (0 SMA,1 EMA,2 SMMA,3 LWMA) |
| Max jitter bars | 4 | Maximum extra bars an entry may be delayed (0 = jitter disabled) |
| Random seed | 0 | Random seed, 0 = seed from TimeLocal() (non-reproducible) |
| Atr stop multiple | 2.0 | Stop distance, ATR multiples, measured from the ACTUAL entry price |
| Atr target multiple | 3.0 | Target distance, ATR multiples |
| Atr period | 14 | ATR period |
| Fixed lots | 0.10 | Fixed lot size |
| Magic number | 20260418 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Order-send attempts before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Log file name | EntryJitterHarness_log.csv | Per-trade jitter log, written under MQL4\Files\ |
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 → Experts.
- 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 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: Moving Average · Buy/Sell Arrows · ATR · MT4 Expert Advisor · MQL4 Source Code