Discussing the article: "The Deflated Sharpe Ratio in MQL5: Telling a Real Edge from a Lucky Backtest"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: The Deflated Sharpe Ratio in MQL5: Telling a Real Edge from a Lucky Backtest.
A Sharpe ratio read off the best of many optimization runs is not the number it looks like. This article ships a reusable native CDeflatedSharpe class that turns a raw Sharpe into an honest confidence statement. The Probabilistic Sharpe Ratio corrects it for sample length and for skew and kurtosis; the Deflated Sharpe Ratio adds the correction almost nobody applies, for the number of variants you tried before keeping the best. Everything is from scratch, the sample moments, the normal CDF and its inverse included, so there is no Python, no DLL and no library. On a real sweep of 56 moving-average variants on XAUUSD the winner looked significant at 98.5 percent by PSR, then fell to 90.6 percent once the 56 trials were admitted, below the usual bar. That gap is the selection bias, made measurable.
This site already has articles about the ratio and about the risk of trusting one backtest. The article Mathematics in trading: Sharpe and Sortino ratios explains how the ratio is calculated and notes that it assumes normally distributed returns. The article Rolling Sharpe Ratio with Statistical Significance Bands in MQL5 plots a rolling Sharpe ratio of the bar returns with significance bands. The bands use Andrew Lo's standard error for independent, normally distributed returns. The article Hypothesis Testing for Trading Strategies builds a one-sample t-test in MQL5 for whether the mean return differs from 0. The article Stress Testing Trade Sequences with Monte Carlo in MQL5 resamples the trade results to build equity paths, a drawdown distribution and a probability of ruin.
Three more articles deal with the search itself. The article Combinatorially Symmetric Cross Validation In MQL5 estimates the probability of backtest overfitting from the bar-by-bar returns of every optimization pass. The article Unified Validation Pipeline Against Backtest Overfitting combines that method with other cross-validation methods in Python, and lists the Deflated Sharpe Ratio paper as further reading. The article From "Best Pass" to Robust Solutions: Exploring the Optimization Surface in MetaTrader 5 exports the metrics of every pass and looks for a stable plateau around the best pass.
None of these articles computes the Probabilistic Sharpe Ratio or the Deflated Sharpe Ratio. The first four work on one series of returns or trade results at a time and do not count how many variants were tried. The last three look at the whole search, but they do not give a probability for the Sharpe ratio of the selected variant. This article adds that calculation, and it complements those checks. It needs only the trade returns of the winner and one Sharpe ratio per variant.
Both ratios are implemented in one small native class. The Probabilistic Sharpe Ratio (PSR) accounts for sample length and the shape of the return distribution. The Deflated Sharpe Ratio (DSR) also accounts for the number of variants searched, which is the adjustment that applies when a result was picked during optimization. The class implements the moments, the normal distribution and its inverse itself, so it needs no Python, no DLL and no include file.
Author: Martin Alejandro Bamonte