DataSnooping.mqh answers the question that follows every optimization: the best of many strategies (or of many parameter sets of one strategy) beat the benchmark, but was it better, or only the luckiest of the lot? It has Hansen's test for superior predictive ability (SPA), White's Reality Check, the Romano-Wolf StepM procedure that finds every strategy better than the benchmark, and the model confidence set of Hansen, Lunde and Nason. The bootstrap keeps the dependence of daily results (stationary bootstrap) and takes a seed. No DLL.
#include <DataSnooping\DataSnooping.mqh>
matrix returns; // one column per strategy (or parameter set), one row per day
vector benchmark; // returns of the benchmark on the same days (zeros: no position)
// ... fill returns and benchmark ...
CSuperiorAbility spa;
spa.SetData(returns, benchmark, true); // true: higher is better
spa.Options(2000, 0.0, true, 1); // draws, mean block (0: square root of the days), studentized, seed
if(spa.Compute())
{
double p = spa.PValue(1); // consistent SPA p-value: is the best really better?
int better[];
int n = spa.StepM(0.05, better); // all the strategies better than the benchmark at 5%
}
CModelConfidenceSet mcs;
if(mcs.Compute(returns, true, 2000))
{
bool kept = mcs.Included(0, 0.1); // is strategy 0 in the 90% set of the best?
} The tests follow the Python package arch, and give the same p-values as arch when the same bootstrap draws are used. arch's SPA class has a studentize option, but in version 8.0 its computation does not divide by the standard deviations, so it returns the test without studentization whatever the option. Here, Options(..., studentize = false, ...) gives the same numbers as arch, and studentize = true gives Hansen's statistic, where a strategy with a high mean but very noisy results counts less than a steadier one.
The script SnoopingExample.mq5 builds 100 moving average rules on a symbol (long while the fast average is above the slow one, flat otherwise, 10 fast and 10 slow lengths), or reads the returns of your own strategies from a CSV file, and compares the p-value of the best rule tested alone with the SPA, Reality Check, StepM and model confidence set results (picture 1). On US30 D1 the best rule has a t statistic of 1.72: alone, a p-value of 0.043; as the best of 100, an SPA p-value of 0.19 (picture 2).


Picture 3: the t statistic of each rule, by fast and slow average. Neighbouring rules give similar numbers, because they are in the market on mostly the same days. The bootstrap of the SPA test and of the Reality Check keeps this dependence; a Bonferroni correction would ignore it and be far too strict.

Picture 4: the same best rule, SMA 5/160. Tested alone, its p-value is 0.043, below 5%. Taken as the best of the 100 rules that were tried, it is 0.244 (Reality Check) and 0.187 (SPA): nothing left to show that it beats staying out of the market.

With the bootstrap indices drawn by arch 8.0 (stationary bootstrap, 1 000 draws) on three data sets (50 strategies of which 3 have a real edge, 200 correlated parameter sets without edge, the daily results of 9 sample Expert Advisors):
DataSnooping.mqh goes to MQL5\Include\DataSnooping, SnoopingExample.mq5 to MQL5\Scripts\DataSnooping.
Basket Pair Closer
Position manager for MT5 that closes the best winner together with the worst loser when their combined result reaches your minimum. Basket take profit and stop loss in money, magic filter, simple panel. Works with grid, martingale and manual trades. Open source code.
Cointegration: ADF, Engle-Granger and Johansen tests with a pair scanner
Unit root and cointegration tests (ADF, Engle-Granger, Johansen) with MacKinnon p-values, hedge ratio, half-life and z-score of the spread, and a pair scanner.
Swap Markup Scanner
Shows the broker's hidden financing markup and the carry for every symbol, as annual % of notional.
Partial Close Multi TP Manager
Partial close expert advisor for MetaTrader 5: closes a percent of the position at TP1, TP2, TP3, TP4 and TP5, moves the stop loss to breakeven and trails it. Works on manual trades and on positions of any EA, on any symbol, Gold (XAUUSD) included. Open source code.