Discussing the article: "Rolling Sharpe Ratio with Statistical Significance Bands in MQL5"

 

Check out the new article: Rolling Sharpe Ratio with Statistical Significance Bands in MQL5.

This article presents a custom MetaTrader 5 indicator that computes a rolling annualized Sharpe ratio and plots configurable z-score significance bands based on Lo's asymptotic standard error. It uses a circular return buffer with incremental variance to keep O(1) updates. We explain the n^(-1/2) uncertainty scaling, the inflation of intervals at high Sharpe values, and how to set per-instrument annualization for correct deployment.

Traders frequently treat a short-window Sharpe ratio (eg, 40–60 bars with SR ≈ 1.0–1.5) as evidence of alpha. Statistically, however, such point estimates are highly variable: sample Sharpe has a standard error that scales with 1/√n, so small n produces estimates dominated by noise. The problem is compounded in MetaTrader 5, where the indicator engine can force full recalculation with prev_calculated = 0 and deliver only a partial history; stateful rolling accumulators then produce "plausible" numbers computed from incomplete data. What's needed is an MetaTrader 5-native diagnostic that reports not only the rolling (annualized) Sharpe but also its uncertainty (±z·SE) so users can distinguish "confirmed edge" from "Sharpe inside noise," and an implementation that is resilient to MetaTrader 5's recalculation and viewport behaviors.

This article presents a custom MetaTrader 5 indicator, RollingSharpe.mq5, that plots three lines in a sub-window beneath the price chart: the rolling annualized Sharpe ratio, and an upper and lower confidence band at ±1.96⋅SEann​. Sections 1 through 3 derive the mathematics behind those three lines; Section 4 assembles them into the indicator; Section 5 provides the exact inp_Window and inp_PeriodsPerYear values your instrument and timeframe require so the bands are calibrated correctly from the first bar. Once built, reading the chart reduces to one rule: if the bands straddle zero, the visible Sharpe is statistical noise; if they do not, the Sharpe reading is significant at the chosen confidence level.

Author: Ushana Kevin Iorkumbul