Skip to content
All library documents

Using PatchTST to Forecast OHLC Bars with a Transformer Model

Article MQL5 articles

Summary

The article walks through adapting a supervised PatchTST time-series model for use from an MQL5 expert advisor. It explains the model’s use of reversible instance normalization to normalize inputs and restore forecast scale, decomposition into trend and residual components, and patching that groups adjacent observations before transformer encoding. The example uses open, high, low, and close as input features, takes a historical context window, and produces forecasts for future bars. The article also describes modifying the model’s patch extraction so it can be exported to ONNX, then invoking the exported model from MQL5 and drawing predicted bars on a chart.

The evidence presented is an implementation walkthrough, not a measured forecast evaluation: the excerpt shows how to generate and display output but gives no accuracy comparison, trading backtest, or profitability result. The author notes that the ONNX-compatible patching replacement uses a loop and may be less efficient during training. The example therefore demonstrates an integration path, while the model’s predictive value for a market or trading decision remains unestablished.

Key ideas

  • PatchTST groups consecutive time-series observations into patches for transformer processing.
  • Reversible instance normalization is used to address changes in the scale and distribution of input data.
  • The example forecasts future open, high, low, and close values from a window of historical bars.
  • The model is adapted for ONNX export and called from an MQL5 expert advisor.
  • The walkthrough demonstrates integration and visualization but does not report forecast accuracy or trading results.

Tags

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