TestMnistOnnx
This EA is a demonstration utility that uses an ONNX neural network model (MNIST) to classify hand-drawn digits on a canvas. The user draws a digit (0-9) on a 28x28 grid rendered via CCanvas, and the EA runs inference using OnnxRun to predict the digit. It has no trading functionality whatsoever — it is purely a machine learning inference demo.
Open the interactive view (equity curve, symbol switch)Key facts
Backtest results (H1, about 1 year)
Not backtested yet — this EA could not be converted automatically.
Strategy analysis
This EA contains no trading strategy whatsoever; it is an MNIST handwritten digit recognition demo tool based on an ONNX model. The strategy concept is to use a pre-trained convolutional neural network model to classify digits drawn by the user on a canvas. The entry condition is the user clicking the CLASSIFY button to trigger inference, and exit conditions are not applicable since there are no trading operations. Position sizing and money management are completely absent — this EA does not open, manage, or close any trades. The full pipeline is: the user draws a digit on the canvas with the mouse → pixel data is collected and average-pooled down to 28x28 → normalized to the 0-1 range → fed into the ONNX model for inference → softmax activation is applied and argmax yields the predicted digit. When model confidence falls below 0.8, the full probability distribution is printed for debugging reference.
Strengths
- Successfully demonstrates the complete ONNX model inference pipeline in MQL5, providing a reference example for applying machine learning in MetaTrader
- The interactive canvas design is intuitive — users can draw with the mouse and get real-time classification results, offering a good user experience
- Clear code structure with the PrepareMatrix function cleanly separating pixel collection, downsampling, and normalization into distinct logical steps
Weaknesses
- No trading functionality at all — as a published EA its practical value is limited; it would be more appropriate as a sample script or indicator
- Drawing precision is limited by integer division in GRID_STEP, which may cause edge pixel loss or inaccurate downsampling
- Lacks input validation and error handling — for example, after ONNX model load failure the user can still click the classify button, potentially leading to misleading results
Possible improvements
- Add UI state management for ONNX model load failure — disable the classify button and display an error message when the model is unavailable
- Optimize the downsampling algorithm by using bilinear interpolation instead of simple average pooling to improve handwritten digit recognition accuracy
- Add parameterized confidence threshold and visual UI indication for low-confidence results instead of only printing to the log
Risk assessment
Overall risk: Safe
- This EA does not execute any trading operations — there is no financial risk
- When ONNX inference fails, only an error log is printed; PredictNumber returns -1 but the UI still displays -1 as the prediction, which could mislead users
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
SHIFT_X | 100 | Canvas X-axis offset in pixels |
SHIFT_Y | 100 | Canvas Y-axis offset in pixels |
SIZE_X | 420 | Canvas total width in pixels |
SIZE_Y | 300 | Total canvas height in pixels |
SIZE_CAPT | 20 | Caption bar height in pixels |
ONNX_DEFAULT | 0 (implicit) | Default flags for ONNX model creation and execution |
Similar Machine Learning EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.