Discussing the article: "A Thin gRPC Inference Client: Serving a Live Python Model to MetaTrader 5 Without ONNX"

Check out the new article: A Thin gRPC Inference Client: Serving a Live Python Model to MetaTrader 5 Without ONNX.

Learn how to connect a LightGBM pipeline with a custom feature transformer to an MQL5 Expert Advisor without converting it to ONNX. The article covers the gRPC service, REST gateway, WebRequest() client, signal and risk logic, and probability indicator. An offline replay approximates the EA’s decisions and compares confidence thresholds across in-sample and out-of-sample data, since WebRequest() fails in the Strategy Tester.

The usual route from a trained scikit-learn model to a live MetaTrader 5 chart is ONNX: export the model, load it with OnnxCreate(), and run inference inside the terminal. That route is hard to beat for a plain function from a fixed feature vector to an output, but it gets awkward once custom code sits in front of the model. The model is a LightGBM classifier, but its input pipeline matters more. A custom transformer converts a window of raw closes into three features: a rolling z-score of log returns, ATR-normalized momentum, and a percentile-ranked volatility regime bucket.

Exporting the transformer requires extra work because skl2onnx has no converter for the custom class. You would need to register one, rewrite the rolling statistics and percentile rank with ONNX operators, and maintain that implementation alongside the Python original. This article takes the other route: the trained pipeline stays in a Python process, and the Expert Advisor asks it for predictions over the network.

Author: Olamide Daniel Adebayo