Discussing the article: "Beyond the Mean and Standard Deviation: A Robust Statistics Library for MQL5 Indicators"

 

Check out the new article: Beyond the Mean and Standard Deviation: A Robust Statistics Library for MQL5 Indicators.

Price outliers distort indicators based on the mean and standard deviation. This article delivers a robust MQL5 library (RobustStats.mqh) implementing the median, 1.4826-scaled MAD, and Theil–Sen slope, plus three drop‑in indicators that replace Bollinger Bands, the linear regression channel, and the z‑score oscillator. A comparison overlay and a breakdown‑point measurement on EURUSD show how the robust instruments hold their shape when a single spike moves the classical ones.

This article builds the fix from robust statistics, the branch of statistics designed for exactly this situation: a small library and three drop-in indicators that use it. In place of the mean we use the median; in place of the standard deviation we use the median absolute deviation (MAD); and in place of the least-squares slope we use the Theil-Sen slope, the median of all pairwise slopes. Each of these has a property the classical estimator lacks, a high breakdown point: the fraction of the data you can corrupt before the estimate becomes meaningless. For the median and MAD that fraction is 50%; for the mean and standard deviation it is zero.

You will get a single-source-of-truth include, RobustStats.mqh. It computes both the robust estimators and their classical twins over one shared window, so the two can be compared apples-to-apples. On top of it sit three indicators: a Theil-Sen trend channel, a median/MAD band, and a MAD-normalized oscillator, each a direct replacement for a familiar classical tool. A fourth indicator overlays the classical and robust bands together so the difference is visible on the candles, and a script measures the breakdown point on real price data so the difference is visible in numbers. The aim is reproducible engineering: estimators that compile, run, and behave exactly as the theory says, with the evidence to prove it, not a claim that any of this is more profitable to trade.

Beyond the Mean and Standard Deviation: A Robust Statistics Library for MQL5 Indicators

Author: Adeolu Kayode Gbadebo