Skip to content
All library documents

Detecting OHLCV Bar Outliers with the Modified Z-Score

Article MQL5 articles

Summary

The document explains how unusually large candle features can distort rolling indicators and presents a robust method for flagging such bars. It measures body size, upper and lower wick lengths, and tick volume, then standardizes each feature against a rolling median and median absolute deviation (MAD). Taking the mean of the four absolute Modified Z-Scores yields a composite anomaly score; configurable thresholds distinguish milder from stronger flags.

The discussion compares robust statistics with the mean and standard deviation, explains the score’s normalization, and outlines a modular MQL5 implementation with chart markers and a histogram. It gives threshold examples and computational complexity estimates, but provides no empirical evaluation of detection accuracy or trading performance. A high score identifies unusual observations, not necessarily bad data: news and liquidity events can be genuine. The composite mean can also dilute a bar that is extreme in only one feature, a deliberate trade-off intended to reduce feature-specific false positives.

Key ideas

  • The median and MAD provide robust location and scale estimates that are less affected by extreme bars than the mean and standard deviation.
  • The method measures body, upper wick, lower wick, and tick volume as separate bar features.
  • It averages the absolute Modified Z-Scores across features to produce one composite anomaly score.
  • Thresholds control how sensitive the chart’s outlier markings are.
  • Detected anomalies may reflect real market events, so flags should not be treated automatically as data errors.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.