Loading…

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

SettingDefaultWhat it does
Prod fast ma10Production logic: fast MA period
Prod slow ma30Production logic: slow MA period
Candidate fast ma12Candidate logic: fast MA period
Candidate slow ma26Candidate logic: slow MA period
Ma methodMODE_EMAMA method shared by both versions
Enable production tradingfalseDANGEROUS - see SAFETY header. Off by default.
Confirm phraseMust exactly equal I UNDERSTAND THIS SENDS A REAL ORDER to arm production trading
Allow on real accountfalseDANGEROUS - overrides the demo-account refusal for production trading. Leave false.
Fixed lots0.10Lot size for production trades only
Stop loss pips30Fixed stop loss, production trades only
Take profit pips60Fixed take profit, production trades only
Magic number40801Magic number for production's own orders
Slippage pips3Slippage tolerance, in pips
Log to filetrueAppend each bar's comparison to a CSV under MQL4\Files\
Log file nameShadowDeploymentHarness_log.csv

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 → Experts.
  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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Moving Average · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria