Loading…

Gradient Boosted Stumps

A single hand-tuned entry rule - RSI below thirty, moving average rising - is one split on one feature. It is easy to write and easy to explain, and it is also, almost always, close to the weakest possible predictor: barely better than guessing the average. Gradient boosting takes exactly that kind of weak split and chains dozens of them together, fitting each new one not to the original target but to the error the ensemble so far has left behind. The result routinely beats a single hand-tuned rule by a wide margin while each individual stump inside it stays trivially simple and inspectable. This header fits that chain against squared error, which is the right loss for predicting a continuous quantity - next-bar return, a fair-value gap, anything on a real number line - and is not a classifier. Training starts from the target's mean, then for a chosen number of rounds fits one decision stump (a single feature, a single threshold, two constant predictions either side of it) to the current residuals and adds a shrunk copy of that stump's prediction to the running total. The shrinkage factor (learning rate) is what keeps a boosted ensemble from simply memorising the training data the way an unconstrained single tree would. Each stump's split search uses the standard efficient identity for minimising squared error - maximising leftSum^2/leftCount + rightSum^2/rightCount over every candidate threshold - so fitting one stump against a modest bar-data feature matrix genuinely takes a fraction of a second, matching what "trains in seconds" promises rather than gesturing at it. A minimum leaf size is enforced so no split is accepted that would leave either side with too few samples to trust; when a feature is constant or minLeafSize rules out every candidate, the header falls back to a degenerate stump that contributes almost nothing rather than crashing or dividing by zero - the demo shows both of these edge cases explicitly, not just the case where everything works. Unlike the ask-tell optimisers elsewhere in this catalogue, training here is a single batch call: every row of the feature matrix and every label is known up front, and the loss (squared error against y) is fixed and internal rather than something an external caller supplies incrementally. Notes and limitations - Regression only. There is no classification loss (log-loss, hinge) here - feeding it a 0/1 target will train, but the predictions are unconstrained reals, not probabilities. - No built-in cross-validation, early stopping or out-of-bag error - the caller is entirely responsible for deciding how many stumps and what learning rate avoid overfitting a small bar-data sample. Compare training error against a genuinely held-out sample before trusting any result. - Split search cost grows with rows squared per feature (an insertion sort per feature, chosen for clarity over raw speed) - fine for the row counts a single-symbol bar dataset produces, not intended for very large matrices. - No missing-value handling. Every cell of X must be a real number; route data through FeatureBuilder.mqh or an equivalent alignment step first if your columns have different warm-up periods.

Script · MT5 · v1.0 · Free

About Gradient Boosted Stumps

Gradient Boosted Stumps is a script for MetaTrader 5. It has 3 settings, such as Rows, Num stumps and Learn rate. MQL source code included.

Files in the download: GradientBoostedStumps.mq5.mqh, GradientBoostedStumps.txt, GradientBoostedStumpsDemo.ex5, GradientBoostedStumpsDemo.mq5.

Settings

SettingDefaultWhat it does
Rows60Synthetic training rows
Num stumps25Boosting rounds for the main example
Learn rate0.3Shrinkage applied to every stump's contribution

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: RSI · Moving Average · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria