Quant Metrics

  • Libraries
  • Shipra Gupta
    Shipra Gupta
    I’m Shipra Gupta, a trader and quantitative strategy developer with a strong background in mathematics, economics, and algorithmic trading systems. Over the years, I’ve worked extensively across forex, gold, indices, commodities, and crypto markets, focusing on building data-driven trading
  • Version: 1.0

QuantMetrics – Deflated Sharpe, Monte Carlo & OnTester Criteria

Stop optimising on net profit. QuantMetrics gives your EA the statistics quant funds use to separate skill from luck, in a single #import.

Features

  • Deflated Sharpe Ratio (DSR) – Bailey & López de Prado. Probability your Sharpe is real after accounting for skew, fat tails and the number of optimisation passes.
  • Probabilistic Sharpe Ratio (PSR) – Probability the true Sharpe beats any benchmark, given your sample size.
  • Monte Carlo – Trade-order reshuffling: drawdown at any percentile and probability of ruin.
  • Risk-adjusted ratios – Sharpe, Sortino, Calmar, CAGR, Ulcer Index, Ulcer Performance Index, Kestner K-Ratio, Van Tharp SQN, skewness, kurtosis.
  • 10 OnTester criteria – Recovery, Sharpe, Sortino, Calmar, UPI, K-Ratio, SQN, PSR, DSR, PSR×Calmar, with a minimum trade count.
  • Reads history directly – Filter by magic and symbol. Swaps, commissions and fees are included. Or load your own return array.

Quick start

1. Buy and download the library. MetaTrader installs it to MQL5\Libraries\QuantMetrics.ex5.
2. Paste the import block below at the top of your EA, indicator or script.
3. Call the functions.

double OnTester()
  {
   QM_BuildFromHistory(TesterStatistics(STAT_INITIAL_DEPOSIT),-1,"");
   QM_SetTrials(200);              // optimisation passes you ran
   Print(QM_Report());
   return(QM_Criterion(QM_CRIT_DSR,30));
  }

Import block (copy into your code)

#define QM_OK              0
#define QM_ERR_NODATA      1
#define QM_ERR_PARAM       2
#define QM_ERR_HISTORY     3
#define QM_CRIT_RECOVERY   0
#define QM_CRIT_SHARPE     1
#define QM_CRIT_SORTINO    2
#define QM_CRIT_CALMAR     3
#define QM_CRIT_UPI        4
#define QM_CRIT_KRATIO     5
#define QM_CRIT_SQN        6
#define QM_CRIT_PSR        7
#define QM_CRIT_DSR        8
#define QM_CRIT_PSR_CALMAR 9

#import "QuantMetrics.ex5"
int QM_LastError();
int QM_BuildFromHistory(const double initial_deposit,const long magic,const string symbol);
int QM_LoadReturns(const double &returns[],const double start_equity,const double years);
int QM_Trades();
double QM_NetProfit();
double QM_WinRate();
double QM_ProfitFactor();
double QM_Expectancy();
int QM_MaxConsecLosses();
double QM_MaxDrawdownPct();
double QM_MaxDrawdownMoney();
double QM_RecoveryFactor();
double QM_CAGR();
double QM_Skewness();
double QM_Kurtosis();
double QM_Sharpe(const bool annualize);
double QM_Sortino(const bool annualize);
double QM_Calmar();
double QM_UlcerIndex();
double QM_UlcerPerformance();
double QM_KRatio();
double QM_SQN();
double QM_ProbabilisticSharpe(const double benchmark_sr);
bool QM_SetTrials(const int trials);
double QM_DeflatedSharpe();
bool QM_MonteCarlo(const int sims,const double percentile,const double ruin_dd_pct, const uint seed,double &dd_at_percentile,double &prob_ruin);
double QM_Criterion(const int mode,const int min_trades);
string QM_Report();
#import

Notes

  • Select Custom max in the Strategy Tester to rank passes by your criterion.
  • Monte Carlo work is capped so optimisation stays fast.
  • Example on S&P 500 daily (Donchian 55/20): PSR 0.90 falls to DSR 0.11 after 100 tested variants.

Technical

  • Pure MQL5. No DLL, no WebRequest, no file I/O.
  • Every exported function validates its inputs. QM_LastError() returns the reason for any failed call.
  • Works in the Strategy Tester and live, on any broker, symbol and account currency.

Past performance shown in screenshots is from historical data and does not guarantee future results.



More from author
AMD Po3
Shipra Gupta
AMD Po3 for MetaTrader 5 Accumulation, manipulation, distribution: mapped for you. AMD Po3 is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator maps the reaction zones that matter right now: the nearest areas above and
KN Smart TP SL Signals for MetaTrader 5 Overview KN Smart TP SL Signals is an EMA crossover indicator for MetaTrader 5 that converts confirmed moving-average crossovers into structured visual trade setups. Each signal includes an entry level, ATR-based Stop Loss, and three configurable Take Profit targets. The indicator automatically plots these levels on the chart, helping traders evaluate potential trades without manually calculating each price level. Signals are generated using closed candle
IFVG Sniper Entry Engine — MQL5 Marketplace Description IFVG Sniper Entry Engine is a precision MT5 indicator built around one of the most specific and high-probability Smart Money Concepts entry patterns — the Inverse Fair Value Gap (IFVG) . It silently tracks every raw Fair Value Gap formed on the chart, monitors each one for inversion (mitigation), and the moment a qualifying IFVG is confirmed, it fires a BUY or SELL signal with a full SL/TP trade layout and a push notification — on every si
Coppock Curve MultiFilter for MetaTrader 5 The classic Coppock curve with modern filters. Coppock Curve MultiFilter is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with
FREE
Tension Flow Trend — Dynamic HMA Ribbon with Historical RR Backtest Tension Flow Trend is an advanced trend-following indicator for MetaTrader 5 that combines a Hull Moving Average (HMA) trend ribbon , Z-Score momentum analysis , and a built-in visual Risk:Reward backtesting engine into a single chart overlay. Designed to identify high-probability trend continuation opportunities, the indicator filters out market noise by requiring both a slope-confirmed HMA crossover and a configurable signal c
FREE
Adaptive RSI Supertrend for MetaTrader 5 Trend and RSI momentum in one view. Adaptive RSI Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
FREE
Trend Target Ribbon for MetaTrader 5 A colour ribbon for trend, targets for risk. Trend Target Ribbon is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull c
FREE
Overview Structure-Anchored VWAP [WAT] is a market-structure-aware VWAP indicator for MetaTrader 5. It anchors Volume Weighted Average Price (VWAP) to relevant swing points and market-structure events rather than relying exclusively on fixed session resets. The indicator combines market structure analysis, anchored VWAP, deviation bands, retest signals, and ATR-based trade-level calculations in one chart-based framework. It is designed to help traders assess price relative to structural movemen
FREE
Liquidity Intelligence System — MQL5 Marketplace Description Liquidity Intelligence System   is an institutional-grade MT5 indicator that maps Smart Money liquidity pools, detects sweep-and-reverse setups, and generates high-confluence trade signals through 16 independently-testable signal models — all within a single, clean indicator. How It Works The engine continuously builds a live liquidity map by detecting pivot-based   Buy-Side Liquidity (BSL)   and   Sell-Side Liquidity (SSL)   zones, in
Precision Sniper Trader for MetaTrader 5 EMA trend plus momentum confirmation. Precision Sniper Trader is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to c
FREE
TrendIQ Pro for MetaTrader 5 Adaptive volatility trend with a trend cloud. TrendIQ Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull colour for long
Squeeze Momentum Breakout for MetaTrader 5 Low volatility in, momentum breakout out. Squeeze Momentum Breakout is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is trading in and hi
FREE
Volume Breakout Pro for MetaTrader 5 Breakouts backed by abnormal volume. Volume Breakout Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is trading in and highlights periods
FREE
Meridian Flow — Smart Money Structure Indicator for MT5 Meridian Flow is a MetaTrader 5 indicator built for traders who follow Smart Money Concepts (SMC) and ICT price action methodology. It automatically detects BOS (Break of Structure) and CHoCH (Change of Character) events on any symbol and timeframe, then plots a complete risk map — Entry, Stop Loss, TP1, TP2, and TP3 — for every signal, including historical ones. Signals fire only on confirmed, closed bars. No repainting. No guesswork. MT5
Adaptive Trend System for MetaTrader 5 A trend line that adapts to volatility. Adaptive Trend System is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
Market Path Forecast for MetaTrader 5 Projected price paths from swing statistics. Market Path Forecast is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how price b
FREE
RSI Signal Entries for MetaTrader 5 RSI extremes plus candle confirmation. RSI Signal Entries is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with clear extreme zones.
FREE
Trident Swing Projector for MetaTrader 5 Quarter-swing projections from ABC structures. Trident Swing Projector is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how
Z-Score Range Boxes Breakout for MetaTrader 5 Statistical extremes boxed, breakouts flagged. Z-Score Range Boxes Breakout is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is tradin
Precision Sniper Pro for MetaTrader 5 Four pillars: EMA, RSI, MACD and ADX. Precision Sniper Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to close b
FREE
Stealth Trail Supertrend for MetaTrader 5 A supertrend that adapts its own multiplier. Stealth Trail Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the tre
Fibonacci Path Profile for MetaTrader 5 How price moved after similar retracements. Fibonacci Path Profile is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how pric
Strong Fade Signals for MetaTrader 5 Fade the overextended move, with a score. Strong Fade Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to close
FREE
Fan Principle Signals for MetaTrader 5 The classic fan principle, as clear signals. Fan Principle Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how price
McGinley Dynamic Fusion for MetaTrader 5 McGinley Dynamic crossovers with ATR levels. McGinley Dynamic Fusion is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend
Liquidity Entry Signals for MetaTrader 5 Entries where liquidity gets taken. Liquidity Entry Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator maps the reaction zones that matter right now: the nearest areas
Cardwell Range Pro for MetaTrader 5 RSI ranges that change with the market regime. Cardwell Range Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with clear extreme
Adaptive RSI Supertrend for MetaTrader 5 Trend and RSI momentum in one view. Adaptive RSI Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
Market Structure Target Tracker for MetaTrader 5 Swings, BOS, CHoCH and ATR targets. Market Structure Target Tracker is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and track
Smart TrendFlow Pro for MetaTrader 5 Channel breaks with a volatility heatmap. Smart TrendFlow Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is trading in and highlights per
Filter:
No reviews
Reply to review