DrawdownBootstrap.mqh estimates how deep the drawdown of an account or a strategy can get over the coming months, from its past daily results. The worst drawdown of a backtest happened once, in one order of events; a Monte Carlo of the same results in other orders shows the range to expect, and how often the worst of the history is exceeded.
#include <DrawdownBootstrap\DrawdownBootstrap.mqh> double days[]; // daily results in money (or in percent) // ... fill the days ... double dd[]; CDrawdownBootstrap::Run(days, 252, 10000, 10.0, 12345, dd); // horizon, paths, mean block, seed double p95 = CDrawdownBootstrap::Quantile(dd, 0.95); // 1 period in 20 goes deeper than this double worst = CDrawdownBootstrap::MaxDrawdown(days); // the drawdown of the history itself
The script DrawdownBootstrapExample.mq5 takes the daily closed results of this account (all of them or one magic number), or a CSV file of daily results, simulates 10 000 paths of one year and prints the percentiles of the drawdown in money and as a percent of a capital, and the share of the paths that go deeper than the worst drawdown of the history (picture 1).

The history the simulation starts from: the 1041 daily results of a sample portfolio added up (top), and how far below its previous high it was each day (bottom). The worst drawdown, 8 813.67, happened once, around day 857.

The 10 000 simulated years of 252 days, built from blocks of these days with the same seed as above. At the end of the year the median path is at +4 391, 5% of the paths are below -5 243 and 5% above +15 736, and 23.9% end with a loss although the history itself made money. The dotted lines are the path with the deepest drawdown and a typical one.

On 1 041 days of results, three runs (2 000 paths of 252 days with blocks of 10 days, 500 paths of 63 days with single days, 300 paths of 500 days with blocks of 25 days, three different seeds) gave the same drawdown for every path as an independent Python version of the same algorithm, within 2e-11.
DrawdownBootstrap.mqh goes to MQL5\Include\DrawdownBootstrap, DrawdownBootstrapExample.mq5 to MQL5\Scripts\DrawdownBootstrap.
PortfolioWeights: risk parity, HRP, minimum variance and maximum diversification
Portfolio weights from the returns of symbols or Expert Advisors: inverse volatility, risk parity, hierarchical risk parity, minimum variance, maximum diversification, Ledoit-Wolf covariance.
TesterReport: read a saved Strategy Tester report into deals and trades
Reads a Strategy Tester report saved as HTML into its deals, closed trades, net profit and balance drawdowns, for comparing, combining or exporting backtests.
BacktestOverfitting: probability of backtest overfitting (PBO) of an optimization
Probability of Backtest Overfitting (PBO) of an MT5 optimization by combinatorially symmetric cross-validation. Every pass sends its daily results as a frame, and the PBO is computed when the optimization ends.
Risk Lot Panel
On-chart panel that turns a risk setting into a lot size and shows what the broker's volume step and minimum lot do to that risk. Display only - it never places, modifies or closes an order.