Using an ONNX Model to Classify Handwritten Digits in an Expert Advisor
Summary
This example describes embedding a pretrained ONNX classifier in an Expert Advisor to recognize digits drawn by a user. The model is trained for the MNIST task, which uses 28-by-28 grayscale images. A user draws a digit in an on-screen grid and activates classification; the program passes the prepared image matrix to the model and selects the class with the largest output score.
Because the model output is not already softmax-normalized, the example applies softmax before interpreting the scores as probabilities. It prints the full probability vector when the top score is below 0.8, which can reveal uncertain or uninformative inputs; an empty grid is given as an example. The text describes a software and machine-learning integration technique, not a trading signal or investment method. It gives no classification accuracy, validation procedure, or live-trading use case, so it does not establish model reliability beyond illustrating the workflow.
Key ideas
- The example uses an ONNX MNIST model to classify a user-drawn digit.
- Input is prepared as a 28-by-28 grayscale image matrix before inference.
- Softmax is applied to the model output before selecting the highest-scoring digit class.
- The program displays the probability vector when the top score is below 0.8.
- No accuracy or validation results are reported, and the example is not a trading strategy.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.