Triple-Barrier Labeling
López de Prado's method for turning price paths into supervised-learning labels, a profit-taking barrier, a stop-loss barrier, and a time barrier, plus meta-labeling to separate the side of a bet from its size.
Prerequisites: Feature Engineering for Finance, Look-Ahead Bias
Before you can train a supervised model on markets you must decide what it is predicting, the label. The naive choice, "the sign of the return over the next days," is a poor label: it ignores the path taken to get there, assigns the same label to a smooth ride and a gut-wrenching drawdown that only recovers at the horizon, and takes no account of risk. Triple-barrier labeling is López de Prado's path-aware alternative. It labels each observation by which of three barriers the price touches first, mirroring how a real position with a profit target and a stop-loss actually resolves.
The three barriers
For an event at time with an estimate of local volatility , set:
- Upper (profit-taking) barrier at above entry.
- Lower (stop-loss) barrier at below entry.
- Vertical (time) barrier at .
The horizontal barriers are dynamic: they scale with the current volatility estimate , so a 2% move means something different in calm and turbulent markets. The label is determined by the first barrier the path touches:
Formally, with return path , the touch time is , and the label reads off the outcome at . The interval is the observation's label span, precisely the object that purging and embargoing operate on in Purged & Embargoed Cross-Validation, because overlapping spans leak information across CV folds.
Why path-awareness matters
A fixed-horizon return label says -at-day-10 is a win, even if the position was down on day 3 and would have been stopped out by any real risk manager. Triple-barrier labels resolve at the stop, so they encode the tradeable outcome, not an idealized end-point. Asymmetric multipliers () let you encode a target risk/reward. Scaling barriers by makes labels comparable across regimes, which is essential once you feed them to a model that assumes roughly stationary targets, see Feature Engineering for Finance.
Meta-labeling
The second idea is to separate the side of a bet from the size. Run a primary model (or a simple rule) that decides the direction, long or short. Then train a secondary, meta-labeling model whose target is binary: given that the primary model took a position, was it correct? The meta-model's label is
and it predicts . This decomposition is powerful for three reasons:
- Precision/recall control. The primary model sets recall (it takes many positions, catching most opportunities); the meta-model raises precision by vetoing the low-confidence ones. This tends to improve the F1 score more than trying to build one model that does both.
- Position sizing. The meta-model's probability output maps naturally to a bet size, trade big when is high, small or zero when low, a clean bridge to Position Sizing and fractional The Kelly Criterion.
- Model reuse. You can bolt meta-labeling onto an existing signal (even a discretionary or fundamental one) to learn when to trust it without rebuilding the primary logic.
Worked example
Daily bars, volatility estimate , symmetric multipliers , horizon days. The barriers sit at . At an event on Monday:
- Price rises by Wednesday → upper barrier touched first → label , span .
- Alternatively it falls by Tuesday → lower barrier → label , span .
- Alternatively it drifts to at Friday's close without touching either → vertical barrier → label (or if you label timeouts by direction), span .
Now the meta-layer: suppose the primary rule went long every Monday. The meta-model learns from features (volatility, momentum, order-flow) to predict whether that long will hit the upper barrier before the lower, and outputs a probability that becomes the position size. Note the label spans differ per observation and overlap neighbors, which is exactly why the classifier must be validated with purging and embargo, not naive k-fold.
Failure modes
- Overlapping labels ignored. Adjacent observations share label spans; validating with ordinary Cross-Validation for Time Series leaks and inflates accuracy. Purge and embargo.
- Look-ahead in . The volatility used to size barriers must be estimated only from data up to ; a full-sample or centered estimate is Look-Ahead Bias.
- Class imbalance. Timeouts and one-sided markets skew the label distribution; weight samples by their uniqueness (inverse of how many other labels overlap them) and by return magnitude.
- Barrier mis-specification. Barriers too tight relative to noise produce near-random labels; too wide and almost everything times out.
- Ignoring sample weights. Overlapping labels mean observations are not equally informative; López de Prado's average-uniqueness weighting corrects the redundancy.
In interviews
Expect "how would you label financial data for a classifier?" A strong answer rejects the naive fixed-horizon sign, describes the three barriers (profit-take, stop-loss, time) scaled by local volatility, and labels by which is touched first. Follow-ups probe meta-labeling, be ready to explain that the primary model picks the side and the meta-model picks the size by predicting whether the primary was right, improving precision and feeding position sizing. Close by connecting the label span to Purged & Embargoed Cross-Validation: because triple-barrier labels overlap in time, honest validation requires purging and embargoing.
Related concepts
Practice in interviews
Further reading
- López de Prado, Advances in Financial Machine Learning (Ch. 3)
- López de Prado, The 10 Reasons Most Machine Learning Funds Fail
- Prado & Lewis, Detection of False Investment Strategies