Skip to content
All library documents

Building a Self-Optimizing MQL5 Expert Advisor with Neural Networks

Article MQL5 articles

Summary

This article outlines an MQL5 Expert Advisor architecture that periodically rebuilds and trains a multilayer perceptron, then uses its forecasts while later optimization runs. It describes a workflow of creating the network, preparing and normalizing input and target data, training the model, generating predictions, and repeating data preparation and training on a timer. The proposed implementation uses ALGLIB functions for network construction and training, with Levenberg–Marquardt or L-BFGS selected according to network size.

The article demonstrates the approach on two non-trading tasks: binary-to-decimal conversion and prime-number detection. Its reported prime-number example correctly classifies many evaluation cases overall but detects fewer than half of the primes, and a larger network performs worse in the cited run. These examples illustrate that network structure and training quality remain unresolved choices. The article presents a software layout and feasibility exploration, not evidence of a profitable trading system; it gives no market backtest, trading rules, or assessment of out-of-sample performance.

Key ideas

  • A timer-driven workflow can periodically prepare data and retrain a neural network inside an Expert Advisor.
  • The network can continue supplying forecasts while a later optimization cycle runs.
  • ALGLIB provides multilayer perceptron creation, processing, error measurement, and training routines in MQL5.
  • The article tests the setup on conversion and prime-detection tasks rather than financial market data.
  • Its examples show that adding hidden layers does not guarantee better results, and network design remains an open problem.

Tags

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