Shadow Deployment Harness
The software-engineering "shadow deployment" pattern - running a new version's logic alongside the current version on real production traffic, comparing outputs, without ever letting the new version actually act - has an obvious trading analogue: before promoting a changed entry rule, see what it WOULD have done on the exact same live feed the current rule is trading, without risking money on the untested change. This EA runs two independent copies of a fast/slow moving-average crossover rule - "production" (the parameters currently trusted) and "candidate" (the parameters proposed as a change) - against the identical live symbol/timeframe feed every bar. Every bar where either version signals, both signals are logged to a CSV alongside whether they agreed, and running totals of agreement rate and each version's own-only signals (candidate-only buy/sell, production-only buy/sell) are shown on the chart. This is the evidence a trader needs to decide whether a proposed parameter change would have helped or hurt, measured against exactly what actually happened rather than a separate backtest window that overlaps only partially with the live period being compared. The safety design is deliberately asymmetric. The candidate rule has no code path that reaches OrderSend at all - not gated by an input, genuinely absent - because the entire point of a shadow deployment is that the new thing under test cannot act. Only the production rule can trade, and only once three independent gates all pass: the trading-enable input, an exact confirmation phrase, and a demo- account check that can only be bypassed by a further explicit override. Notes and limitations - The candidate rule has no code path to OrderSend at all - there is no override that lets it trade, by design, not merely by default. - Production trading requires three independent gates: the enable input, an exact confirmation phrase, and a demo-account check (bypassable only by a further explicit override). See the SAFETY section in the source header. - Agreement is measured signal-by-signal on the closed bar; it does not account for what either version's trade would actually have earned or lost - this tool measures decision agreement, not P&L simulation. Pair it with a backtest of the candidate's parameters for a profitability comparison. - A broker that misreports ACCOUNT_TRADE_MODE would defeat the demo-account refusal - a known limitation of the underlying platform API, not something this EA can independently verify. - Only one production position at a time.
Expert advisor · MT4 · v1.0 · Free
About Shadow Deployment Harness
Shadow Deployment Harness is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average. It has 15 settings, such as Prod fast ma, Prod slow ma and Candidate fast ma. MQL source code included.
Files in the download: ShadowDeploymentHarness.ex4, ShadowDeploymentHarness.mq4, ShadowDeploymentHarness.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 |
|---|---|---|
| Prod fast ma | 10 | Production logic: fast MA period |
| Prod slow ma | 30 | Production logic: slow MA period |
| Candidate fast ma | 12 | Candidate logic: fast MA period |
| Candidate slow ma | 26 | Candidate logic: slow MA period |
| Ma method | MODE_EMA | MA method shared by both versions |
| Enable production trading | false | DANGEROUS - see SAFETY header. Off by default. |
| Confirm phrase | Must exactly equal I UNDERSTAND THIS SENDS A REAL ORDER to arm production trading | |
| Allow on real account | false | DANGEROUS - overrides the demo-account refusal for production trading. Leave false. |
| Fixed lots | 0.10 | Lot size for production trades only |
| Stop loss pips | 30 | Fixed stop loss, production trades only |
| Take profit pips | 60 | Fixed take profit, production trades only |
| Magic number | 40801 | Magic number for production's own orders |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Log to file | true | Append each bar's comparison to a CSV under MQL4\Files\ |
| Log file name | ShadowDeploymentHarness_log.csv |
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 · MT4 Expert Advisor · MQL4 Source Code