Tathagat Agrawal

Trade Filter ML

A leakage-safe meta-labeling study with a pre-registered holdout, asking whether ML can filter a simple trading rule’s signals well enough to matter after costs.

November 2026 · Complete · Source on GitHub

Result: On a pre-registered holdout the filter improved all three strategies, but no gain was statistically distinguishable from zero.

The question

Simple trading rules such as breakouts and moving-average crossovers fire often and, after costs, mostly lose money. Meta-labeling trains a second model that looks at each signal when it fires and decides whether to take it. The question: can such a filter, using only information available at that moment, beat both the unfiltered rule and a random filter that keeps the same share of trades?

It is very easy to fool yourself here. Overlapping trades leak information between training and test folds, repeated tuning overfits the validation data, and a filter that keeps fewer trades can look better by chance alone. The project is built around not falling for any of these.

What I built

Result

On the holdout, the frozen filter improved the average trade for all three strategies, including the EMA crossover, which was never used during development. But every 95% interval includes zero, so the pre-registered success criteria were not met. I report it as a null result.

Dot plot of the change in average R per trade for three strategies on the holdout. All estimates are positive (+0.067, +0.035, +0.042), every 95% interval crosses zero, and the development estimates (diamonds) are higher.
Figure 1. Change in average R per unit of risk from filtering: holdout estimates with 95% intervals (dots) against the development estimates (diamonds).

The negative control asks a stricter question: does the model beat filters that throw away the same share of trades at random? It did for the Donchian breakout, narrowly missed the 95% criterion for the EMA crossover, and did not for Bollinger + RSI.

Three histograms of the average R of 2,000 random filters per strategy, each with a vertical line for the model filter, which beats 99.6%, 81.6% and 94.8% of them.
Figure 2. The model filter (line) against 2,000 random filters that keep the same share of trades (bars).
StrategyTrades keptChange in R95% low95% highBeats randomAUC
Donchian breakout31%+0.067-0.014+0.14699.6%0.52
Bollinger + RSI fade23%+0.035-0.068+0.17481.6%0.52
EMA crossover (held out)52%+0.042-0.031+0.14294.8%0.50
Table 1. Holdout results, January 2025 to October 2026. "Change in R" is the filtered minus the unfiltered average trade, per unit of risk.

What I learned

In development, a small signal from volatility, trend strength and volume at the moment of the signal beat random filters of the same size. On the holdout it pointed the same way at about half the size and could not be confirmed. Neither the filter nor any setting I tested makes these strategies reliably profitable after costs. Building the guardrails first is what made it possible to say that with confidence instead of publishing an overfit backtest.

Built with

Experiment design and honest validation, Gradient boosting (LightGBM, XGBoost), scikit-learn, Probability calibration, Hyperparameter search with Optuna, Experiment tracking with MLflow, Explainability with SHAP, pandas and NumPy, Market data (yfinance, CCXT, NSE), Performance and risk metrics (Sharpe, drawdown, deflated Sharpe), Python