Quant Analytics: from scratch to pro · Machine learning in finance · Intermediate
Features and labels: fixed horizons and the triple barrier
A model is only as good as the question put to it. Features are what is known at the decision time; labels are the outcomes to learn. A fixed-horizon label ignores the path, the triple-barrier label follows it, and overlapping labels shrink the real sample size.
In this lesson
- Build features that use only information available at the decision time
- Label an outcome with a fixed horizon and with the triple-barrier method
- Set barrier widths from volatility
- Compute the effective sample size when labels overlap
Read first: Machine learning for market data: what it can and cannot do, Volatility: from daily moves to an annual figure
Most of the work in a market model is not the model. It is deciding what to feed it and what to ask it. A good model of a badly posed question is of no use, and a badly posed question leaks the future into the answer.
Features: what was known
A feature is a number computed from information available at the decision time: a return over the last 5 days, a volatility estimate, a spread, a distance from a moving average. The rule is strict: every input must have been known before the decision, as the data looked then. That includes revisions, time zones and bar timestamps; see look-ahead and data leaks.
Features are usually made stationary, for example returns and ratios instead of price levels, so the relationships the model learns do not depend on where the price happens to be.
Labels: what to predict
A label is the outcome attached to each sample. Two common choices:
Fixed horizon. Label a sample by the sign (or size) of the return over the next h days. It is easy, but it ignores the path. A price that rises 3% on day 3 and falls back by day 10 is labelled as a loser.
Triple barrier. Set three barriers around the entry price. An upper barrier (profit target) gives +1, a lower barrier (stop) gives -1, and a vertical barrier at a time limit ends the sample, labelled by the sign of the return or as 0. The first barrier touched decides the label. See the triple-barrier method and López de Prado (2018).
Barrier widths are set from recent volatility, so that the question means the same thing in calm and turbulent markets.
Worked example
Entry at 100. Daily volatility is 1.2%. Place barriers at 2 daily volatilities, a width of 2.4%: the upper barrier is 102.40, the lower 97.60. The time limit is 10 days, over which the typical move has a volatility of 1.2% x sqrt(10), which is 3.79%.
The price touches 102.6 on day 3, then drifts down and closes at 99.0 on day 10.
- Triple barrier: the upper barrier was hit first, so the label is +1.
- Fixed horizon: the 10-day return is -1.0%, so the label is negative.
The same path gives opposite labels. Neither is wrong; they ask different questions. The first asks whether a profit target is reached before a stop. The second asks where the price is on day 10. The question should match how the trade would be managed.
Overlapping labels
Take one sample per day with a 10-day label. Sample on day 1 covers days 1 to 10; the sample on day 2 covers days 2 to 11. They share 9 of 10 days, a 90% overlap. The labels are not independent. From 2,500 daily samples, the effective sample size is closer to 2,500 / 10, which is 250.
Consequences: standard errors computed as if the samples were independent are too small; random train and test splits put near-copies on both sides, which is leakage (see leakage and purged cross-validation); and a flexible model can memorise the overlapping outcomes. Remedies are to sample less often, to weight samples by how unique they are, and to purge overlap when validating.
Common mistakes
- Features that include the bar in which the decision is made.
- Fixed-percentage barriers across periods of very different volatility.
- Using a fixed-horizon label for a trade that is exited by stop or target.
- Counting overlapping samples as independent.
- Tuning barrier widths on the whole sample until accuracy looks good. Barriers are part of the model and must be selected inside the training data.
In practice
Write down, before any model is fitted, what is known at the decision, what the label is, which window it covers, and how the barriers are set. Analytics on FinUties applies measures like these to the markets it covers, so they are at hand when you read a chart.
Worked numbers
Each result is recomputed from the formula shown.
| What | Formula | Result |
|---|---|---|
| daily volatility | 0.012 | 1.2% |
| upper barrier | 100 * (1 + 2 * sigma_d) | 102.40 |
| lower barrier | 100 * (1 - 2 * sigma_d) | 97.60 |
| barrier width | 2 * sigma_d | 2.4% |
| 10-day volatility | sigma_d * sqrt(10) | 3.79% |
| return at the time limit | 99.0 / 100 - 1 | 1.0% |
| overlap between neighbouring 10-day labels | 9 / 10 | 90% |
| effective sample size | 2500 / 10 | 250 |
Check yourself
Entry at 100, daily volatility 1.2%, barriers at 2 daily volatilities. Where are the upper and lower barriers?
Upper: 100 x (1 + 2 x 0.012) = 102.40. Lower: 100 x (1 - 2 x 0.012) = 97.60.
The price touches 102.6 on day 3 and closes at 99.0 on day 10 (the time limit). What are the two labels?
Triple barrier: +1, the upper barrier was hit first, on day 3. Fixed 10-day horizon: the return is -1.0%, so the label is negative. The two labels disagree on the same path.
Why are barrier widths set from volatility and not as a fixed percentage?
A fixed 2.4% barrier is a large move in a quiet period and a small one in a turbulent period, so it would be hit at very different rates. Scaling by volatility keeps the question comparable across time.
Daily samples carry 10-day labels. With 2,500 samples, about how many independent labels are there?
About 2,500 / 10 = 250. Neighbouring labels share 9 of their 10 days, so they are 90% overlapped.
A feature uses the day's closing price, and the label starts from the same close. What is the risk?
If the decision would be made before the close, the feature uses information that was not available. The label must start after the last data point used by the features.
Key terms
Sources
- Advances in Financial Machine Learning. Wiley (Marcos López de Prado), 2018. Accessed 9 Nov 2026
- The Elements of Statistical Learning (2nd edition). Springer (Trevor Hastie, Robert Tibshirani, Jerome Friedman), 2009. Accessed 9 Nov 2026