Discussing the article: "Feature Neutralization in MQL5: Orthogonalizing Trading Signals Against Confound Factors"

Check out the new article: Feature Neutralization in MQL5: Orthogonalizing Trading Signals Against Confound Factors.

We implement feature neutralization so your signal is evaluated without volatility/trend confounds. The core is a native MQL5 rolling OLS engine using Gauss-Jordan elimination and out-of-sample residual scoring, with no DLLs. An EA and indicator integrate the residual and log diagnostics, while a Python companion validates numerics and runs bar-replay tests. Use it to isolate linear exposure and assess true signal contribution.

A trading signal that looks strong can still just be a repackaged bet on volatility or trend strength. A momentum reading grows mechanically with bigger bars, and "the market has been going up for two weeks" shows up in a plain moving-average slope for free. Feature neutralization is the check that tells the two apart: regress the raw signal on a small set of confound factors over a rolling window, and trade the residual rather than the raw value. The residual is, by construction, linearly uncorrelated with the confounds inside the window it was fitted on — what that does and does not establish about the trading sequence that follows is the subject of this article, not a detail left for the end.

This article implements the mechanism as a native MQL5 library: a rolling-window ordinary-least-squares engine with its own Gauss-Jordan solver, used by an Expert Advisor that can trade either the raw signal or the neutralized residual (a one-input switch, so the same compiled EA produces both backtests under identical settings), an indicator that plots both series, and a Python companion script that validates the solver, stress-tests it, and replays the backtest on data read either from a bundled CSV or directly from a MetaTrader 5 terminal.

The project is five files: NeutralizerEngine.mqh (the engine), FeatureNeutralizer_EA.mq5 (the Expert Advisor), FeatureNeutralizer_Ind.mq5 (the chart indicator), feature_neutralizer_companion.py (offline validation and figures), and XAUUSD_M5_2025-01-07_to_2025-01-10.csv (a fixed real-data snapshot, not required once a terminal is available — see the data-source section below). All five ship in one archive, MQL5.zip ; the Files table at the end of this article lists the path each one unpacks to.


Author: Sanmi Samuel Ojo