Skip to content
All library documents

Training a CNN-LSTM Price Model and Running It in MQL5 with ONNX

Article MQL5 articles

Summary

The article walks through a demonstration pipeline for forecasting financial prices: obtain EURUSD hourly data, scale closing prices, form rolling sequences, train a one-dimensional convolutional and LSTM network, export it to ONNX, and load the model in an MQL5 Expert Advisor. It also describes evaluating the model with a held-out portion of the data and applying predicted direction to position entry and exit logic, optionally with stop-loss and take-profit levels.

The reported training and validation losses are from a limited historical sample, and the article includes strategy tests for its chosen setup. These results do not establish reliable out-of-sample or live profitability. The authors explicitly frame the model and EA as demonstrations, not for real trading, and emphasize that obtaining an adequate model is harder than calling it from MQL5. The example’s preprocessing, forecast horizon, validation choices, and trading rules constrain how broadly its results can be applied.

Key ideas

  • The example trains a CNN-LSTM model on scaled sequences of EURUSD hourly closing prices.
  • A held-out data segment is used to monitor validation loss during training.
  • The trained network is exported to ONNX and loaded by an MQL5 Expert Advisor.
  • Predicted price direction controls entries and exits, with optional stop-loss and take-profit settings.
  • The article presents the model and EA as demonstrations and does not establish suitability for live trading.

Tags

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