Skip to content
All library documents

Building a One-Step AutoARIMA Price Forecast in MQL5

Article MQL5 articles

Summary

This article presents an MQL5 routine that takes recent closing prices, ordered with the newest first, and returns a one-step-ahead close forecast. It estimates differencing order with a variance-based heuristic, differences the series, fits ARMA candidates over a bounded range of autoregressive and moving-average orders, and chooses among them using corrected Akaike information criterion. Coefficients are estimated by minimizing squared errors with gradient updates and Adam; the forecast is then transformed back to price levels and rounded to the instrument’s tick size.

The article supplies implementation details and describes diagnostics such as the selected model, information criterion, error sum, last price, and forecast. It gives an example of running the routine on a recent candle history when a new bar forms, but does not report out-of-sample accuracy or demonstrate trading profitability. The differencing rule is heuristic, the candidate grid is deliberately limited for runtime, and the method focuses on a single forecast horizon; these choices constrain how confidently its output should be interpreted.

Key ideas

  • The routine automates a one-step ARIMA forecast from a newest-first array of closing prices.
  • Differencing order is chosen with variance comparisons rather than a formal stationarity test.
  • ARMA parameters are fitted by minimizing squared errors with gradient-based updates and Adam.
  • Corrected AIC is used to choose among a bounded set of candidate autoregressive and moving-average orders.
  • The forecast is returned in price units and rounded to the instrument’s tick size.
  • The article describes implementation, but provides no out-of-sample forecast or trading-performance validation.

Tags

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