Concept

Decision Trees

Decision Trees are Machine Learning concepts. The Library holds 1 implementation — a working definition you can pull into Quant.

Top Decision Trees indicator

The top custom implementation, built on the original standard Decision Trees formula.

1 total

What are decision trees?

A decision tree predicts by asking a sequence of yes/no questions about the input features, such as whether RSI is below 30 or whether relative volume exceeds 1.5, and routing each observation down branches until it reaches a leaf that stores a prediction: a class label, a probability, or a numeric value. Training grows the tree greedily, choosing at each node the feature and threshold that best separate the outcomes, and recursing until a stopping rule such as maximum depth or minimum leaf size is hit. The CART formulation by Breiman, Friedman, Olshen, and Stone (1984) is the basis of most modern implementations.

Trees appeal to traders for two reasons. They are readable: a fitted tree is literally a set of if-then rules, close in spirit to how discretionary checklists are written, so a model's logic can be audited line by line. And they are undemanding: no feature scaling, native handling of nonlinear thresholds and feature interactions, and tolerance for mixed input types. The weakness is instability. A single deep tree fits noise aggressively, and small changes in training data can produce a structurally different tree, which is why standalone trees are mostly a teaching device and a building block. Ensembles such as random forests and gradient boosting exist largely to fix the single tree's variance problem.

How it's calculated

Each split is chosen to maximize the reduction in an impurity measure. For classification the common measures are Gini impurity and entropy; for regression, variance.

Gini(node) = 1 - sum(p_c^2)
Entropy(node) = -sum(p_c * log2(p_c))
Gain(split) = I(parent) - (n_L / n) * I(left) - (n_R / n) * I(right)
p_c: proportion of class c among observations in the node
I(.): the impurity measure in use (Gini, entropy, or variance)
n: number of observations in the parent node
n_L, n_R: observations sent to the left and right child by the candidate split

The tree grows by repeatedly taking the split with the highest gain, then pruning or depth limits control overfitting.

Gini and entropy usually produce similar trees; the choice rarely matters as much as depth and leaf-size limits.

How traders use it

  • Rule extraction: a shallow tree (depth 2 to 4) fitted to labeled bars yields a handful of explicit conditions, effectively an automated setup screener whose rules a human can veto or refine.
  • As the base learner in ensembles: in practice most tree value in trading comes through forests and boosted models, where hundreds of constrained trees are combined and the single tree's instability is averaged away.
  • Regime splitting: a tree trained to predict volatility or trend state produces interpretable thresholds, such as a specific reading on a volatility measure, that can gate other strategies.
  • Feature triage: even when the final model is different, the features a tree splits on early are candidates worth keeping during feature selection.
  • Knowing the limits: trees predict constants within regions, cannot extrapolate beyond training ranges, and a deep tree on noisy returns will fit that noise, so raw price levels as features fail quietly at new highs.

Decision trees vs. tree ensembles

Random Forest: A forest averages many randomized trees, trading the single tree's readability for far lower variance. If interpretability is the goal, use one shallow tree; if accuracy is the goal, the ensemble usually wins.

Gradient Boosting: Boosting grows small trees sequentially, each correcting the last, and typically outperforms both a single tree and a forest on tabular data when tuned, at the cost of more sensitivity to noise and hyperparameters.

Concept family

Machine Learning

32 concepts mapped · 32 in the Library

Decision Trees FAQ

Are decision trees good enough to trade on their own?

Rarely. A single tree is high-variance, and on low signal-to-noise market data its splits often encode chance patterns. Shallow trees are useful for interpretable rule discovery; for actual prediction, ensembles of trees are the standard.

How deep should a tree be for market data?

Shallow. Depths of 2 to 5 with generous minimum leaf sizes are common, because each additional level doubles the number of regions available to fit noise. If a deep tree is needed to see any edge, the edge is probably not there.

Do trees need normalized features?

No. Splits compare a feature against a threshold, so monotonic rescaling changes nothing. What does matter is stationarity: features whose typical scale drifts over years, like raw price, produce thresholds that stop making sense.

Why do two training runs give me different trees?

Greedy splitting is sensitive to small data changes: when two candidate splits have nearly equal gain, a few different rows flip the choice and everything below that node changes. This instability is inherent and is the main argument for ensembling.

Build Decision Trees your way.

Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.