Skip to content
All library documents

MQL4 Matrix Algebra for Polynomial Regression

Article MQL5 articles

Summary

The article explains the design of an MQL4 library for common matrix operations. It stores each matrix as a row-major, one-dimensional array and keeps row and column counts separately, then groups functions for resizing, row and column manipulation, initialization, validation, arithmetic, solving linear systems, determinants, rank, inversion, and file input and output. Approximate comparisons use a configurable tolerance to account for floating-point error.

The example applies the library to polynomial regression on candlestick closing prices. It builds a matrix from sums of powers of the input values, forms a right-hand-side vector, and solves the resulting linear system with Gauss-Jordan batch solving to obtain polynomial coefficients. The article describes the implementation and example workflow, but does not provide a quantitative evaluation of forecast quality or trading performance. It presents the library as an algebra utility for MQL4 developers, so users still need to assess numerical stability and regression fit for their own data and intended use.

Key ideas

  • Matrices are stored row by row in a one-dimensional array, with dimensions maintained separately.
  • The library offers common matrix operations, checks, and numerical routines for MQL4 programs.
  • Floating-point values are compared using a nonnegative tolerance.
  • Polynomial regression is demonstrated by constructing and solving a linear system from price observations.
  • The example illustrates implementation, not evidence of predictive or trading performance.

Tags

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