Skip to content
All library documents

Using SAX Historical Analogs to Build a Price Forecast Fan

Article MQL5 code base

Summary

This indicator applies Symbolic Aggregate approXimation (SAX) to search for historical price windows resembling the latest closed-bar window. It z-normalizes each window to emphasize shape, compresses it into segment averages, and encodes those values as a short word. A lower-bounding word distance prunes candidates before the remaining windows are ranked by Euclidean distance. The forward outcomes of the closest precedents form a forecast fan showing the median and interquartile range, scaled by the ATR at each precedent.

A verdict panel reports sample size, match distances, forward moves, and the share of precedents that rose. The method withholds a directional call when the sample is too small or the evidence does not clear both its median-move and up-rate thresholds. The described validation compares the pruned search with brute force and reports identical matches, but the document gives no out-of-sample trading results. Its safeguards against lookahead and its scale adjustment improve the analysis design; historical analog similarity still does not establish predictive power, and results depend on the window, horizon, history, and thresholds selected.

Key ideas

  • SAX converts normalized price-window shapes into symbolic words that can be searched efficiently.
  • The search prunes candidates using a lower-bound distance, then ranks survivors by Euclidean distance.
  • Forward outcomes from historical matches are summarized in ATR units as a median and percentile band.
  • The verdict requires enough analogs and agreement across both the median move and up rate.
  • The described match validation does not establish profitable out-of-sample performance.

Tags

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