Concept
Model Stacking
Model Stacking is a Machine Learning concept. The Library holds 1 implementation — a working definition you can pull into Quant.
Top Model Stacking indicator
The top custom implementation, built on the original standard Model Stacking formula.
1 total
What is model stacking?
Model stacking, also called stacked generalization, combines several predictive models by training a second-level model on their outputs. A set of base learners, for example a random forest, a gradient boosting model, and a linear classifier, each produce a prediction for the same target; a meta-learner then takes those predictions as inputs and learns how to blend them into a final output. Unlike simple averaging or ensemble voting, the combiner can learn that one base model deserves more weight overall, or more weight in particular conditions.
The idea was introduced by David Wolpert in 1992 under the name stacked generalization. The critical mechanical detail is that the meta-learner must be trained on out-of-fold predictions: each base model predicts rows it never trained on, and only those predictions feed the second level. If the meta-learner instead sees in-sample base predictions, it learns to trust models exactly where they memorized the data, which is a direct route to model overfitting.
Traders care because market models built from different logic, trend-following features versus mean-reversion features versus volatility features, tend to fail at different times. A stack lets the second level exploit that complementarity rather than forcing a fixed blending rule. The cost is an extra layer of complexity and an extra layer of things that can silently leak future information, so the validation burden is heavier than for any single model.
How traders use it
- Blending heterogeneous signal models: base learners trained on distinct feature groups (momentum, volume, volatility) feed a small meta-learner, often logistic regression, that outputs one probability per bar.
- Combining timeframes: base models predict the same label from different lookback horizons, and the stack learns which horizon carries weight in the current environment.
- Regularizing the combiner: practitioners usually keep the meta-learner deliberately simple, since a flexible second level can overfit the base predictions, which are already correlated with each other.
- Diagnostics: if the stack barely beats its best base model out of sample, the base models are probably making the same errors; diversity of inputs and model families matters more than adding layers.
- Validation: the whole pipeline, base models plus meta-learner, must be evaluated with walk-forward analysis as one unit, since tuning any layer against the test period contaminates the result.
Model stacking vs. related ensemble ideas
Ensemble Voting of Signals: Voting combines outputs with a fixed rule such as a majority count or an average. Stacking replaces the fixed rule with a learned one, which can capture context-dependent trust but adds another model that can overfit.
Bagging: Bagging averages many copies of the same model type trained on resampled data to reduce variance. Stacking combines different model types and learns the combination, targeting complementary strengths rather than noise cancellation alone.
Gradient Boosting: Boosting builds models sequentially, each correcting the errors of the previous ones within a single training procedure. Stacking trains base models independently and merges them afterward with a separate learner.
Concept family
Machine Learning
32 concepts mapped · 32 in the Library
Model Stacking FAQ
Does model stacking actually improve trading models?
Sometimes, and usually modestly. The gain comes from base models with genuinely different error patterns; stacking near-duplicates adds complexity without benefit. On noisy financial data the improvement is often smaller than what better features or cleaner labels would deliver.
What should the meta-learner be?
Something simple. Logistic or ridge regression is the common choice because the meta-features are few, highly correlated, and already informative. A flexible meta-learner tends to overfit the quirks of the base predictions.
Why do stacked models need out-of-fold predictions?
Because in-sample base predictions are unrealistically accurate, the meta-learner would learn to lean on whichever base model memorized the training data best. Out-of-fold predictions show the meta-learner what base models look like on unseen data, which is what it will face live.
Is stacking worth it for small datasets?
Usually not. Every layer consumes data, and with few observations the meta-learner's weights are estimated from noise. With limited history, a fixed average of two or three diverse models is often the more robust choice.
Build Model Stacking your way.
Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.
