Skip to content
All library documents

Isolation Forest for Detecting Anomalous Market Bars

Article MQL5 articles

Summary

The article explains Isolation Forest, which identifies unusual observations by repeatedly splitting feature space at random and measuring how quickly each point becomes isolated. It describes the anomaly score, the correction for tree branches that stop before points are separated, and a seeded random generator that makes runs reproducible. The implementation uses causal, scale-free price features and evaluates whether the detector finds information beyond simple return magnitude.

Market examples include extreme gold and Bitcoin sessions, while shuffled and random-walk null models help assess what the method flags without meaningful structure. The article also describes calibration on a training percentile, an out-of-sample threshold check, and a proposed anomaly gate for a breakout strategy. These results illustrate implementation and diagnostic methods rather than establishing a profitable trading edge; an unsupervised detector will rank unusual bars even in random data.

Key ideas

  • Isolation Forest scores points by their average depth in randomly partitioned trees.
  • A correction for truncated branches makes path lengths comparable across trees.
  • A seedable generator and fixed draw patterns support exact reproducibility and cross-implementation checks.
  • Null models help determine whether flagged bars reveal structure beyond ordinary random variation.
  • An anomaly score can gate strategy decisions, but the described backtest does not establish predictive value.

Tags

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