Regime Sliced Tester Reporter
A single backtest report's profit factor is one number covering every condition the market was in during the test - trending or ranging, calm or volatile - blended together. A strategy that only works in trending, high-volatility conditions and loses steadily everywhere else can still show a respectable blended profit factor, which is exactly the kind of result that quietly stops working the moment the market spends a few months ranging. Finding that out normally means manually splitting the test into several date ranges by eye and rerunning each one. This EA classifies the CURRENT bar into one of six regimes - three volatility states (ATR relative to its own rolling average: low, normal, high) times two trend states (ADX above or below a threshold: ranging or trending) - and tags every trade its placeholder fast/slow EMA crossover opens with whichever regime was active at entry, via a short marker written into the order comment and read back once the trade closes. OnTester() aggregates the whole trade ledger by regime and writes trade count, win rate, net profit and profit factor for each of the six buckets to a CSV file in one pass - the same information six separate manual reruns would produce, but computed once, consistently, from one continuous test. Notes and limitations - The regime is read at ENTRY only and never re-evaluated for a trade already open; a trade that opens in a ranging market and closes after the regime shifts to trending is still counted under its entry regime, which is the point (it answers "what regime was this DECISION made in", not "what regime did most of the holding period fall in"). - A regime with fewer than three closed trades can still appear in the report with a computed profit factor, but that figure is not statistically meaningful on so few trades - read the trade-count column alongside every other figure, not in isolation. - The regime tag is recovered from the order's comment text on close; a comment longer than the platform's per-order comment limit would truncate the tag, but the tag is written last and kept short specifically to avoid that. - The placeholder crossover strategy has no claimed edge; it exists only to generate a trade ledger for the regime breakdown to be computed from - swap it for a real strategy's entry logic and the reporting layer is unaffected. - No hardcoded contract size anywhere in the file; lot sizing uses MODE_LOTSTEP/MODE_MINLOT/MODE_MAXLOT as usual.
Expert advisor · MT4 · v1.0 · Free
About Regime Sliced Tester Reporter
Regime Sliced Tester Reporter is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average, ADX and ATR. It has 16 settings, such as Fast ma period, Slow ma period and Atr period. MQL source code included.
Files in the download: RegimeSlicedTesterReporter.ex4, RegimeSlicedTesterReporter.mq4, RegimeSlicedTesterReporter.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 EMA period for the placeholder crossover signal |
| Slow ma period | 30 | Slow EMA period for the placeholder crossover signal |
| Atr period | 14 | ATR period, used both for the stop and the volatility regime |
| Stop atr multiple | 2.0 | Stop distance, in ATR multiples |
| Vol lookback | 100 | Bars averaged to build the "normal" ATR baseline for the volatility regime |
| Vol high ratio | 1.25 | ATR / baseline ratio above which volatility counts as HIGH |
| Vol low ratio | 0.75 | ATR / baseline ratio below which volatility counts as LOW |
| Adx period | 14 | ADX period for the trend regime |
| Adx trend threshold | 25.0 | ADX reading above which the market counts as TRENDING |
| Lots | 0.10 | Fixed lot size for the placeholder signal |
| Magic number | 40500 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Report metric | METRIC_OVERALL_PROFIT | What OnTester() returns, for "Custom max" optimisation |
| Report file | RegimeSlicedTesterReporter_Report.csv | Regime breakdown, written once at end of pass, 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: Trend · Moving Average · ADX · ATR · MT4 Expert Advisor · MQL4 Source Code