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
| Setting | Default | What it does |
|---|---|---|
| Allow live trading | false | DANGEROUS - see SAFETY header. Leave false. |
| Fast ma a | 10 | Variant A: fast MA period |
| Slow ma a | 30 | Variant A: slow MA period |
| Fast ma b | 20 | Variant B: fast MA period |
| Slow ma b | 60 | Variant B: slow MA period |
| Ma method | MODE_EMA | MA method shared by both variants |
| Fixed lots | 0.10 | Lot size for every trade, both variants |
| Stop loss pips | 30 | Fixed stop loss, in pips |
| Take profit pips | 60 | Fixed take profit, in pips |
| Magic a | 40201 | Magic number tagging variant A's trades |
| Magic b | 40202 | Magic number tagging variant B's trades |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Sprt alpha | 0.05 | SPRT type I error (false positive) rate |
| Sprt beta | 0.05 | SPRT type II error (false negative) rate |
| Sprt p0 | 0.50 | Null hypothesis: variant win rates are equal (0.50) |
| Sprt p1 | 0.65 | Alt hypothesis: the better variant wins this share of head-to-head decisions |
| Min trades each before verdict | 20 | Minimum closed trades PER variant before a verdict is even considered |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 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: Buy/Sell Arrows · Moving Average · MT5 Expert Advisor · MQL5 Source Code