Discussing the article: "Neural Additive Models for Fully Interpretable Signal Attribution in MQL5"

Check out the new article: Neural Additive Models for Fully Interpretable Signal Attribution in MQL5.

Build and deploy a Neural Additive Model natively in MQL5: one small network per feature, additive output, and no post-hoc explainability. The article provides a PyTorch trainer, two‑output ONNX export (signal and contributions), an include wrapper using OnnxCreateFromBuffer/OnnxRun, and an EA that prints real per‑feature contributions each bar. It covers identical feature math for training/export, threshold measurement, Strategy Tester results, and edge cases such as NaNs and out‑of‑distribution inputs.

Every explainability technique applied to a trading model after the fact makes a promise it can't quite keep. SHAP values approximate what a black-box network is doing by perturbing inputs and averaging the effect. Partial dependence plots average over a background dataset and hope the interactions wash out. Both are useful, and both are guesses about a model whose real internal computation nobody can point to directly.

A Neural Additive Model (NAM) sidesteps the guessing entirely. Instead of one dense network where every input is tangled with every other input by the second layer, a NAM assigns each feature its own small subnetwork, and the final prediction is nothing more than the sum of what those subnetworks output. There is no approximation step because there is nothing to approximate — the contribution of feature i to the prediction is literally the output of subnetwork i. Plot it, and you are looking at the model's own internal arithmetic, not a reconstruction of it.

This article implements the architecture for MetaTrader 5. It trains a five-feature NAM in PyTorch, exports it to ONNX, and runs it in an Expert Advisor that reads both the signal and each feature's exact contribution on every closed bar. Three files ship with this article — an include class wrapping the ONNX model, the EA itself, and the Python training/export script — each walked through with its actual code below, not just described in prose.

Author: Adesewa Tolulope Gbadebo