Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

Robustness Lab: Optimisation robustness map with plateau score for the Strategy Tester - library for MetaTrader 5

Panagiotis Paterakis
Panagiotis Paterakis
  • Algorithmic trading developer (MQL5, cTrader C#, Python) at  Self-employed
  • Greece
  • 128
I design, code and run automated trading systems. My own systems trade forex, indices and gold live on cTrader (C#), across several brokers, so I work through the full cycle: clear strategy rules, backtesting with realistic costs, robustness checks around the chosen parameters, live deployment, and
Views:
65
Rating:
(1)
Published:
\MQL5\Experts\RobustnessLab\
RL_Demo_EA.mq5 (6.08 KB) view
\MQL5\Include\RobustnessLab\
RL_MonteCarlo.mqh (16.04 KB) view
RL_Common.mqh (8.96 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

The best line of an optimisation report is often the luckiest one. A parameter set is more trustworthy when its neighbours give similar results. This library shows that directly.

Optimisation robustness map with plateau score, demo EA on EURUSD H1

How it works

  • Each optimisation pass sends its statistics to the terminal through frames (FrameAdd). The collector in the terminal draws a heatmap of two chosen inputs and updates it during the optimisation.
  • Metric per cell: net profit, profit factor, recovery factor, Sharpe ratio, the value returned by OnTester, or the MC recovery factor (net profit divided by the 95th percentile Monte Carlo drawdown of that pass).
  • If more than two inputs are optimised, each cell holds the mean (or best) over the other inputs.
  • Plateau score of a cell = mean - k x standard deviation of the valid cells within the chosen radius. At least 60% of the neighbourhood must be valid. Passes with too few trades are excluded and shown grey.
  • At the end it marks the best single cell (white) and the most robust cell (cyan) and tells you if the best cell sits on a weaker neighbourhood.

How to use it in your EA

  1. Copy the three .mqh files to MQL5\Include\RobustnessLab and add #include <RobustnessLab\RL_OptimizationMap.mqh>.
  2. Declare a global CRLOptimizationMap object and add the four tester functions (OnTester, OnTesterInit, OnTesterPass, OnTesterDeinit). RL_Demo_EA.mq5 shows them in a few lines.
  3. Optimise two inputs, choose "Custom max" as the criterion if you want the MC recovery factor to drive the optimisation, and watch the map on the chart that opens.
  4. Reports go to Terminal\Common\Files\RobustnessLab (HTML and CSV) and the picture to MQL5\Files\RobustnessLab.

A single test (not an optimisation) writes a Monte Carlo drawdown report for that run instead.

Demo EA

RL_Demo_EA is a plain EMA crossover with ATR stops. It exists only to demonstrate the tools and is not a trading recommendation.

Notes

  • Works with complete and genetic optimisation. Grid up to 200 values per axis.
  • A robust cell still needs an out-of-sample (forward) check before live use.

The screenshot shows the optimisation of the demo EA on EURUSD H1, 2021-2025: fast EMA 4-40 and slow EMA 20-200, 361 combinations (grey cells are invalid combinations where fast >= slow).

Robustness Lab: Monte Carlo drawdown analysis of your trading history Robustness Lab: Monte Carlo drawdown analysis of your trading history

Takes the closed trades of your account (all, or filtered by magic number and symbol), reshuffles or resamples them thousands of times and shows how deep the drawdown could realistically get. You get drawdown percentiles, the probability of a drawdown above your limit, the spread of final equity, an equity fan chart and a drawdown histogram, on the chart and as an HTML report. Part of the free Robustness Lab set.

Robustness Lab: Market regime indicator (bias-corrected Hurst, efficiency ratio, volatility) Robustness Lab: Market regime indicator (bias-corrected Hurst, efficiency ratio, volatility)

Classifies the market as trend, mean-reversion or noise using three public measures: the Hurst exponent by rescaled range with small-sample bias correction, Kaufman's efficiency ratio and the percentile of the current ATR. A colour strip shows the regime bar by bar, and a panel shows the regime on M15, H1, H4 and D1 at the same time. Part of the free Robustness Lab set.

Prop Firm Risk Manager - daily loss and trailing drawdown guard Prop Firm Risk Manager - daily loss and trailing drawdown guard

Account guard for prop-firm challenges. It does not open trades: it watches the whole account (manual trades and any EA) and closes everything before the firm's limits are broken. - Daily loss limit: closes all and blocks trading until the next day. - Max drawdown: static or trailing (can lock at the start balance); closes all and locks the account. - Optional profit-target lock, max lots / max positions, Friday close. - On-chart panel (equity, today's P/L, daily and drawdown room left) and push alerts. - Equity peak and lock are saved per account, so a restart does not reset the protection. Main inputs: StartBalance, DailyLossUSD, DDMode, MaxDDUSD, LockAtStart, safety buffers, TargetUSD, MaxOpenLots, MaxOpenPositions, FridayCloseOn, ResetLock. Attach to any one chart, any symbol and timeframe, with Algo Trading enabled.

MACD Signals MACD Signals

Indicator edition for new platform.