Loading…

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

SettingDefaultWhat it does
Fast ma period10Fast EMA period for the placeholder crossover signal
Slow ma period30Slow EMA period for the placeholder crossover signal
Atr period14ATR period, used both for the stop and the volatility regime
Stop atr multiple2.0Stop distance, in ATR multiples
Vol lookback100Bars averaged to build the "normal" ATR baseline for the volatility regime
Vol high ratio1.25ATR / baseline ratio above which volatility counts as HIGH
Vol low ratio0.75ATR / baseline ratio below which volatility counts as LOW
Adx period14ADX period for the trend regime
Adx trend threshold25.0ADX reading above which the market counts as TRENDING
Lots0.10Fixed lot size for the placeholder signal
Magic number40500Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds
Report metricMETRIC_OVERALL_PROFITWhat OnTester() returns, for "Custom max" optimisation
Report fileRegimeSlicedTesterReporter_Report.csvRegime breakdown, written once at end of pass, under MQL4\Files\

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: Trend · Moving Average · ADX · ATR · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria