EA-45593 · Machine Learning

MatrixMachineLearning

This script implements a Hopfield-like recurrent neural network using MQL5 matrix operations to predict binary price direction from tick data. It trains a weight matrix on historical tick deltas, tests convergence on backtest and forward-test data, and outputs a binary forecast vector. It is a research/demo script and does not execute any trades.

Open the interactive view (equity curve, symbol switch)

Key facts

RiskSafe
Rating★★★☆☆
TypeUtility tool
TimeframesM1, Tick
IndicatorsHopfield Network, Convolution (Price Differencing), Tanh Activation
Author—

Backtest results (H1, about 1 year)

Not backtested yet — this EA could not be converted automatically.

Strategy analysis

The strategy concept is based on a Hopfield associative memory network, binarizing continuous price change deltas into +1/-1 sequences as neuron input patterns. Entry conditions are derived by training a weight matrix using Hebbian learning (weights are the cumulative outer product of input and response vectors), then running forward and backward propagation iteratively until the network converges to a stable state. Exit conditions are not applicable in this script since it only generates prediction signals without executing any trades. Position sizing and money management are completely absent; the script merely outputs binary forecast vectors for human or programmatic reference. The innovation lies in applying Hopfield networks to binarized financial time series forecasting, but binarization discards significant price magnitude information and network capacity is limited by the predictor size. Convergence is not guaranteed—there is a maximum iteration limit (LIMIT=100), and results are output even when the network fails to converge.

Strengths

  • Uses native MQL5 matrix operations for neural network implementation, keeping code concise and efficient
  • Hebbian learning rule for weight training requires no backpropagation or gradient computation, keeping computational cost low
  • Provides both backtest and forward-test validation to help assess model generalization
  • Online prediction feature can fetch new tick data in real-time and generate forecasts
  • Network convergence detection (ACCURACY threshold and iteration cap) prevents infinite loops

Weaknesses

  • Binarization of price changes discards magnitude information, retaining only direction, resulting in coarse prediction granularity
  • Hopfield network storage capacity is limited; increasing predictor dimensionality easily leads to spurious stable states
  • No trade execution logic whatsoever—it is only a research demo script, cannot be directly used in live trading
  • Lacks rigorous model evaluation metrics; using only dot product match count for accuracy is insufficient
  • Does not account for real trading factors such as costs, slippage, and spreads
  • Forward-test accuracy is only 58.5%, barely above random chance, casting doubt on actual predictive power

Possible improvements

  • Introduce additional features (e.g., volume, multi-timeframe data) instead of single binarized price deltas to enrich input information
  • Add cross-validation and sliding window training mechanisms to avoid overfitting and adapt to changing market conditions
  • Add a complete risk management module and trade execution logic to enable actual automated trading

Risk assessment

Overall risk: Safe

  • The script does not execute any trades, only generates prediction signals, so there is no direct financial risk
  • The network outputs results even when it fails to converge, potentially producing misleading prediction signals
  • Insufficient validation of input data effectiveness (e.g., handling of insufficient tick data is simplistic)

Evaluation scores

Code quality4.0
Strategy logic3.0
Risk management1.0
Robustness2.0
Innovation4.0
Documentation3.0
Overall2.8

Parameters

ParameterDefaultDescription
TicksToLoad100Total number of tick data to load
TicksToTest50Number of ticks for forward testing
PredictorSize20Number of neurons in the predictor (input layer)
ForecastSize10Number of neurons in the response (output layer)
DebugLogfalseEnable debug log output

Similar Machine Learning EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.