Symbolic Aggregate Approximation (SAX) in MQL5: Historical Analog Search and Forecasting
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-14 00:09:52 +00:00
Include/SAX initial commit 2026-07-12 02:54:19 +00:00
Indicators/SAX initial commit 2026-07-12 02:54:52 +00:00
Scripts/SAX initial commit 2026-07-12 02:55:21 +00:00
README.md Add README 2026-08-14 00:09:52 +00:00

SAX

Symbolic Aggregate Approximation in MQL5, used for historical analog search and forecasting.

Companion code for the MQL5 article: https://www.mql5.com/en/articles/23484

What it does

SAX turns a price window into a short string. The window is normalised, split into equal segments, each segment averaged, and each average mapped to a letter by breakpoints chosen so letters are equally likely under a normal.

Once windows are words, finding historical analogs is string matching instead of a full pairwise distance sweep, which is what makes the search cheap enough to run on a chart.

The analog search finds past windows resembling the present one and uses what happened next as a distribution of outcomes. SAXValidate.mq5 is the validation harness, and the article uses it to show whether the precedents carry information or just look convincing.

SAXAnalog.mq5 draws the fan cone of outcomes and a verdict panel.

Layout

Include/SAX/SAXTransform.mqh   the SAX transform
Include/SAX/SAXAnalogs.mqh     analog search over symbolised history
Indicators/SAX/SAXAnalog.mq5   fan cone and verdict panel
Scripts/SAX/SAXValidate.mq5    validation harness

Run SAXValidate.mq5 on your symbol before trusting the indicator on it.

Disclaimer

Educational code. Past behaviour of any model or dataset says nothing about future results. Test on your own data and broker conditions before drawing conclusions.