# 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.