Loading…

Live A/B Test Harness

Comparing two strategy variants by running them one after another, or on different symbols, or over different date ranges, confounds the comparison with whatever the market did differently between the two windows. This harness instead alternates strictly - Variant A takes the first signal, Variant B the next, A the one after that - so both variants see the same signal stream and the comparison is never biased by which one happened to run during a better or worse stretch of market. The harder problem most head-to-head EA comparisons get wrong is knowing when to stop. Eyeballing "A has a 58% win rate over B's 52% after 40 trades each" invites seeing a pattern in noise. This EA implements Wald's Sequential Probability Ratio Test on Variant A's own win/loss stream against a null hypothesis of no edge (p0=0.5) versus an alternative hypothesis of a real edge (p1, configurable). The test runs a log-likelihood ratio that accumulates with every closed trade and stops the moment enough evidence has accrued in either direction, rather than requiring a fixed sample size decided in advance or letting a trader eyeball a raw percentage that never actually resolves into a decision. Both variants are the identical embedded rule (a fast/slow moving average crossover) with independently configurable periods, so this tests a genuine parameter choice rather than two unrelated strategies - the fair comparison a trader actually needs before promoting one parameter set over another live. Notes and limitations - This EA sends real market orders when armed. It refuses to do so on anything that does not report as a demo account (via ACCOUNT_TRADE_MODE) unless InpAllowLiveTrading is explicitly set to true - a deliberately dangerous override, off by default. - The SPRT compares Variant A's own win/loss stream against a fixed null hypothesis; it does not directly test "A vs B" as a paired comparison, since the two variants never trade the identical bar. A verdict favouring A means A's own performance cleared the p1 bar with enough evidence, not a formal A-versus-B hypothesis test. - Only one open position per variant at a time - a variant with an open trade sits out further signals until it closes, so exposure stays comparable between the two variants. - Stop loss and take profit are fixed pip distances shared by both variants; this isolates the entry rule as the thing under test, at the cost of not testing exit-rule differences. - 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.

Expert advisor · MT5 · v1.0 · Free

About Live A/B Test Harness

Live A/B Test Harness is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It has 17 settings, such as Allow live trading, Fast ma a and Slow ma a. MQL source code included.

Files in the download: LiveAbTestHarness.ex5, LiveAbTestHarness.mq5, LiveAbTestHarness.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Allow live tradingfalseDANGEROUS - see SAFETY header. Leave false.
Fast ma a10Variant A: fast MA period
Slow ma a30Variant A: slow MA period
Fast ma b20Variant B: fast MA period
Slow ma b60Variant B: slow MA period
Ma methodMODE_EMAMA method shared by both variants
Fixed lots0.10Lot size for every trade, both variants
Stop loss pips30Fixed stop loss, in pips
Take profit pips60Fixed take profit, in pips
Magic a40201Magic number tagging variant A's trades
Magic b40202Magic number tagging variant B's trades
Slippage pips3Slippage tolerance, in pips
Sprt alpha0.05SPRT type I error (false positive) rate
Sprt beta0.05SPRT type II error (false negative) rate
Sprt p00.50Null hypothesis: variant win rates are equal (0.50)
Sprt p10.65Alt hypothesis: the better variant wins this share of head-to-head decisions
Min trades each before verdict20Minimum closed trades PER variant before a verdict is even considered

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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: Buy/Sell Arrows · Moving Average · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria