Robustness Lab Monte Carlo Backtest Analyzer
- Utilità
- Versione: 1.0
- Attivazioni: 5
MOST BACKTESTS ANSWER THE WRONG QUESTION
A backtest tells you what happened once, in one order, on one price path.
It does not tell you how much of that result was the edge, and how much was
the order the trades arrived in, a handful of lucky trades, or simply a
short sample.
Robustness Lab takes the trades you have already closed and measures exactly
that gap. It does not optimise, it does not trade, and it does not predict.
It answers one question with numbers:
"If this same sequence had arrived in a different order,
how bad could the drawdown have been?"
WHAT IT DOES
1. Reads every closed deal of the account (or of the current Strategy Tester
run) and merges partial fills into one record per position.
2. Converts each position to an R-multiple, where 1R is the average losing
trade in money. A +2.0R trade made twice the average loss, whatever the
lot size was.
3. Rebuilds the equity path at a risk per trade that you choose, and measures
the drawdown you actually lived through.
4. Resamples the same trades with replacement (Monte-Carlo bootstrap,
default 2,000 iterations) to get the drawdown distribution that a single
history hides: median, 95th percentile, P(DD > 20%), P(final < start),
and the ruin rate.
5. Shuffles the same trades (permutation test, default 2,000 iterations) and
reports where your real drawdown ranks in that distribution. If your
realised drawdown sits at the 10th percentile, you were lucky. If it sits
at the 95th, the path was never going to be kind.
6. Measures concentration (share of gross profit made by the best 5 trades,
and the net result with those trades removed) and rolling-window
stability (how many fixed-size windows were negative, and the worst
window in R).
7. Prints one composite score from 0 to 100, with every component shown
separately so you can disagree with the weighting.
THE FIVE THINGS IT MEASURES
Sample size how much history is actually behind the number
Edge profit factor and expectancy in R
Drawdown risk 95th percentile of the bootstrap drawdown distribution
Path dependence percentile rank of the realised drawdown
Concentration dependence on the best few trades
Stability share of rolling windows that lost money
THE SCORE
Robustness = 0.20 x sample
+ 0.20 x edge
+ 0.25 x drawdown
+ 0.15 x path
+ 0.10 x concentration
+ 0.10 x window stability
Each component is clamped to 0-100 with the thresholds printed in the manual,
so the number is reproducible by hand. The weights are a stated opinion, not
a law: the panel shows all six components, and the CSV export writes them out
so you can re-weight them yourself.
The score is a description of how much of the result depends on things that
will not repeat. It is not a pass/fail verdict and not a forecast.
THE SCORE IS WITHHELD BELOW 30 TRADES
Four of the six components saturate on a small sample. A 17-trade sequence that
lost once shows a profit factor of 300 and a drawdown of 1%, which reads as a
perfect edge and is simply noise. Below 30 closed trades the panel shows
n/a (needs 30+ trades)
and the CSV writes score_valid,0, while still printing every component so you
can see exactly which one saturated. A number is not better than no number
when the sample cannot support it.
THE SAME TRADES AT A DIFFERENT RISK
The panel is a fixed report. The numbers in it are not.
Change Risk per trade from 1% to 2% and nothing about the trading changes:
same trades, same wins, same losses, same order. Only the risk assumption
changed, and the whole picture moves:
realised drawdown 21.6% -> 39.2%
95th percentile drawdown 17.9% -> 33.3%
P(drawdown > 20%) 2.1% -> 36.6%
robustness score 72 -> 59
Nothing here is stored or hard-coded. Every figure is recomputed from your
trade list on the spot, which is why the panel prints the risk it used
("Risk per trade") next to the numbers it produced. If two screenshots look
identical and only the values differ, that is the feature, not a mock-up:
the report is the same, the assumption inside it is not.
This is also the answer to "my backtest survived". Survived at what risk?
At 0.5% and at 3% the same sequence is two very different businesses.
WHAT YOU SEE
A single panel on the chart, no sub-windows, no repainting, no buffers:
trades, period, net P/L, 1R in money
profit factor, win rate, expectancy in R, payoff
max drawdown realised, time under water, longest loss streak
drawdown median / 95th percentile / P(DD>20%) / P(final<start) / ruin
realised drawdown percentile rank
top-5 share of gross wins, net result excluding the top 5
rolling window count, negative window share, worst window in R
the composite score, its six components, and a one-line reading
Optional one-click CSV export with all of the above plus the raw R sequence,
so the same test can be archived, compared between EAs, or re-run in R/Python.
HOW TO USE IT
1. Attach it to any chart. It reads the account history, not the chart symbol,
so the chart is only a place to put the panel.
2. Filter the scope: last N days, symbol substring, magic number. Leave the
magic filter at 0 for the whole account, or set it to compare one EA
against another.
3. Change "Risk per trade" and watch the drawdown columns move. The same
trades at 0.5% and at 3% are two very different businesses.
4. Optionally turn on CSV export to keep the result.
SCORING A SEQUENCE YOU ALREADY HAVE
Set "Trade-sequence CSV" to a file name in MQL5\Files and the indicator reads
that file instead of the account history. One row per trade, one column of
profit in money, a header row is fine:
profit;comment
150,win
-100,loss
...
Comma, semicolon and tab separators all work; non-numeric rows are skipped.
This is how you score an EA you do not own, a Strategy Tester report you have
already exported, or a batch of runs made on synthetic markets. The 1R is
still the average loss of that file, so nothing has to be normalised by hand.
Inside the Strategy Tester it works the same way: run your EA, then attach
Robustness Lab to the tester chart and read the panel for that run.
INPUTS
Scope
Period in days 0 = all available history
Symbol filter substring match, empty = all symbols
MagicNumber 0 = all experts
Trade-sequence CSV file in MQL5\Files, empty = use account history
CSV column 0-based column holding the profit
Risk assumption
Risk per trade (%) basis of the drawdown and score columns
Start balance display only
Statistics
Monte-Carlo iterations default 2,000
Permutation iterations default 2,000
Seed fixed by default, so results are reproducible
Rolling window (trades) default 100
Output
Export CSV writes to MQL5\Files
CSV file name empty = auto name
Display
Show panel, corner, X, Y, width, value column X, font, font size,
refresh seconds, eight colours
WHAT IT DOES NOT DO
- It does not place, modify or close orders. There is no trading function in
the code. It is an indicator, not an expert advisor.
- It does not re-run somebody else's EA on new data. MQL5 offers no API for
one program to launch another, and anything that claims otherwise from
inside a single terminal is either driving the terminal from outside or
guessing. This tool stays inside what the terminal can prove.
- It does not tell you whether to buy or sell, and it does not forecast
profit.
- A high score is not a guarantee. It means the result you already have is
less dependent on order and luck than most. It says nothing about the next
six months of market conditions.
REQUIREMENTS
MetaTrader 5, any broker, any symbol, any timeframe.
Works on netting and hedging accounts.
Needs closed deals in the account history or in the tester run.
No DLLs, no external files, no internet access.
NOTES
Backtests and historical results do not guarantee future results.
Past drawdown behaviour is not a limit on future drawdown.
KEYWORDS
monte carlo simulation, backtest analyzer, drawdown distribution, risk of ruin,
walk forward analysis, overfitting, curve fitting, equity curve analysis,
stress test, trade sequence analysis, robustness score, prop firm evaluation,
EA evaluation, out of sample test, statistical significance, expectancy in R.
