SAX Forecaster: Predictive Market Analysis with Symbolic Strings

SAX Forecaster: Predictive Market Analysis with Symbolic Strings
Download ALL MT5 indicators (5742)
YouTube Video Thumbnail



Similar MetaTrader Tools

SAX Forecaster: Predictive Market Analysis with Symbolic Strings

Info

The SAX Forecaster: Predictive Market Analysis with Symbolic Strings is a Indicator for MetaTrader 5 that overviewthe sax forecaster moves beyond traditional numerical chart analysis to leverage symbolic aggregate approximation (sax). Introduced by Jessica Lin, Eamonn Keogh, and colleagues in 2003, SAX transforms time-series price data into short strings of letters, enabling the application of text-based data mining techniques.

Usage

This tool is typically used for enhancing chart analysis and decision making.

Platform

This Indicator works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Indicators folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use SAX Forecaster: Predictive Market Analysis with Symbolic Strings

1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.

2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.

3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.

4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.

Frequently Asked Questions

Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."

Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).

Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.

What this tool does

OverviewThe SAX Forecaster moves beyond traditional numerical chart analysis to leverage Symbolic Aggregate approXimation (SAX).

Typical Use Case

This Indicator excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Indicator works on MetaTrader 5. Place the file in the MQL5/Indicators folder and restart the terminal.

Description & Settings

Related: EMA Predictive3 - another powerful indicator for MetaTrader 5 traders.

Overview

The SAX Forecaster moves beyond traditional numerical chart analysis to leverage Symbolic Aggregate approXimation (SAX). Introduced by Jessica Lin, Eamonn Keogh, and colleagues in 2003, SAX transforms time-series price data into short strings of letters, enabling the application of text-based data mining techniques. This indicator applies SAX to identify historical periods with similar price patterns and forecast potential future market behavior.

Also recommended: NX Bars: Predictive Signal Indicator - similar indicator with strong performance on MetaTrader 5.


The indicator encodes the current market window, searches historical data for analogous patterns, and analyzes the subsequent outcomes. These results are visualized as a forecast fan cone on the chart, accompanied by a verdict panel detailing the statistical significance.

The SAX transformation involves three primary steps:

Z-normalisation: This process standardizes the price window, preserving only the shape of the price movement. This ensures that similar patterns on different instruments or at different volatility levels are recognized.

Piecewise Aggregate Approximation (PAA): The normalized window is divided into a specified number of segments (w), and each segment is replaced by its average value. This dimensionality reduction smooths out noise and simplifies the data.

Discretisation: Each segment's average is mapped to a letter using predefined breakpoints based on a normal distribution. This ensures that each letter has an equal a priori probability of occurrence.

The SAX pipeline involves z-normalisation, PAA, and then mapping to letters using Gaussian breakpoints.

A key component enhancing the search efficiency is MINDIST, a distance measure that provides a provable lower bound for the Euclidean distance between two SAX words. This allows for the efficient pruning of dissimilar historical patterns before performing a more detailed Euclidean distance calculation on the remaining candidates.

Important Consideration: The z-normalisation step inherently removes price level and volatility information. While the indicator attempts to compensate by measuring outcomes in volatility units, users should be aware that this limitation exists. The indicator may frequently report "no edge" on markets exhibiting random walk behavior, which is an accurate reflection rather than a malfunction.

Indicator Visualizations

The indicator generates two primary visual elements, both updated upon the close of a new bar:

The Fan Cone: This displays the distribution of future outcomes from historical analogs. A solid line indicates the median future movement, with dotted lines representing the 25th and 75th percentiles. The widening of the cone signifies decreasing agreement among precedents. The fan cone is displayed only when a bullish or bearish verdict is issued.

The Verdict Panel: This panel provides a statistical summary of the forecast:

Word: The SAX encoding of the current market window.
Analogs: The number of historical precedents found and their average match distance.
fwd H: The median future move over the forecast horizon, expressed in ATR multiples and percentage.
band: The range between the 25th and 75th percentiles of future moves (the cone's width).
up rate: The proportion of precedents that resulted in an upward price movement.
VERDICT: Indicates 'Bullish', 'Bearish', 'no edge', 'too few analogs', or 'no data'.

The verdict requires strong evidence, demanding that the median move exceeds an edge threshold in ATR terms and the up rate shows a clear bias beyond a neutral band. Failure to meet either criterion results in a 'no edge' verdict.

Key Features

Integrity of Construction

No Lookahead: Ensures that outcomes are based on historical data only, preventing any future information from influencing the analysis.

ATR-Normalised Outcomes: Forward movements are measured relative to the prevailing ATR at the time of the match, allowing for comparable analysis across different volatility regimes.

Honest Verdicts: The indicator withholds a forecast and suppresses the cone when the sample size is insufficient or the directional bias is not decisive.

Authentic SAX Implementation

The indicator utilizes a complete SAX implementation, including z-normalisation, PAA (handling fractional cases), Gaussian breakpoints, and the MINDIST lower-bounding method. It supports alphabet sizes from 2 to 10, with pre-cached breakpoints.

Flat windows are reported as such, avoiding the creation of meaningless SAX words. A brute-force Euclidean metric is available for verification purposes.

Real-time Performance

The search process runs once per closed bar, ensuring efficiency. The forming bar is excluded from both the query and precedent sets. The panel is dynamically sized for optimal readability across different font sizes and themes.

Recommended Setup

Symbol: Any liquid instrument.
Timeframe: M30 to H4, to ensure sufficient historical data.
History: 6000 bars recommended for a robust precedent set.
Panel theme: Match your chart background (Dark or Light).

File Structure

The indicator comprises one main EA file and two header files, organized within a SAX subfolder.

Main File: SAXAnalog.mq5 (The indicator logic, search execution, and drawing of forecast elements).
Header Files: SAXTransform.mqh (Handles the SAX transformation) and SAXAnalogs.mqh (Manages the analog search and verdict calculation).

Input Parameters

InpWinLen: Query window length (e.g., 48 bars).
InpHorizon: Forecast horizon in bars (e.g., 12 bars).
InpWordLen, InpAlphabet: SAX resolution parameters (e.g., 8, 4).
InpMaxAnalogs, InpMinAnalogs: Controls the number of precedents considered (e.g., 50, 10).
InpEdgeATR: Conviction threshold in ATR multiples (e.g., 0.25).
InpMetric: The distance metric used (MINDIST or Euclid).
InpATRPeriod: Period for ATR calculation (e.g., 14).
InpMaxHistory: Maximum historical bars to scan (e.g., 6000 bars).
Colours, corner, theme: Customization options for appearance.

Research Basis

This implementation is based on the foundational SAX research by Jessica Lin, Eamonn Keogh, and colleagues. SAX is a pattern recognition tool, not a predictive oracle. Its strength lies in identifying periods where multiple historical precedents strongly align, providing a disciplined and honest assessment of market behavior.

Further applications of the SAX library include using SAX words as features in machine learning models, anomaly detection through motif and discord discovery, and building Markov transition models. A companion article details the theoretical underpinnings and validation of the SAX implementation in MQL5.

You may also like: em a predictive2 ht f - excellent alternative for indicator users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_plots 0
#include <SAX\SAXAnalogs.mqh>
input int             InpWinLen    = 48;
input int             InpHorizon   = 12;
input int             InpWordLen   = 8;

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.