Meta-labeling and the triple-barrier method, explained without code

You trained a model to predict whether price will be higher in ten bars. It is right 58% of the time. And the strategy built on it loses money — because "higher in ten bars" was never the question a trade asks.

Most machine-learning trading models are built on a label that no trade ever experiences: the return over a fixed horizon. A real trade has a stop and a target, and it ends at whichever one is touched first — or at a time limit if neither is. A model that predicts the ten-bar return can be right about the destination and wrong about the route, and the route is what stops you out.

Two techniques from Marcos López de Prado's Advances in Financial Machine Learning (2018) fix this. The triple-barrier method makes the label describe the trade. Meta-labeling splits the decision into two questions — which way, and whether to act — and lets a second model answer the second one. Both are widely cited and rarely explained plainly. This is the plain version.

What is wrong with fixed-horizon labels

Label each bar with "did price rise over the next N bars?" and three things go wrong at once:

The triple-barrier method

Instead of a horizon, define each label by three barriers around the entry price, and record which one is touched first:

  1. The upper barrier — a profit target. Touched first: label +1.
  2. The lower barrier — a stop. Touched first: label −1.
  3. The vertical barrier — a time limit. Reached with neither touched: label 0, or the sign of the return at expiry, depending on how you want to treat a trade that went nowhere.

Now the label is the outcome of the trade you would actually have taken. A +1 means the target was hit before the stop. A model trained on it is trained to predict what matters.

Set the barriers in volatility units

The single most important detail, and the one most often skipped: express the barrier widths as multiples of recent volatility — ATR, or the rolling standard deviation of returns — not as fixed percentages. A target of 2× ATR and a stop of 1× ATR is the same trade in a quiet week and a wild one. A target of 2% is two different trades. In our experience this one change matters more to the quality of the resulting model than the rest of the method put together.

The catch: overlapping outcomes

Labels built this way span several bars, and consecutive labels overlap — bar 100's trade and bar 101's trade share almost all of their path. That makes adjacent rows near-duplicates, which inflates any validation that splits them casually. It is the reason the purge and embargo gaps exist; López de Prado introduced them in the same book for exactly this problem. Triple-barrier labels without a purge gap are a leak with a nice name.

Meta-labeling: splitting the problem in two

Suppose you already have something that says which way to trade — a moving-average cross, a breakout rule, a first model. Call it the primary model. It has an opinion on every bar, and its opinion is right some of the time. Meta-labeling adds a second model with a narrower job: given that the primary model wants to trade, should we?

Two models, two different jobs
Primary modelMeta-model
Question askedWhich direction?Should we take this particular signal?
Trained onEvery barOnly the bars where the primary model fired
LabelTriple-barrier outcome of the tradeWhether the primary model's trade would have been profitable
OutputLong / short / flatAct / skip, with a probability
Optimised forRecall — find the opportunitiesPrecision — filter out the bad ones
Can it reverse a trade?YesNo; it can only veto

Why splitting helps

Direction and conviction are different problems with different features. Direction depends on trend, momentum, and structure. Whether a given trend signal is worth taking depends on volatility, time of day, how recently the same signal failed, and what the wider market is doing — features that would only confuse a direction model. Giving the second question its own model, its own features and its own label lets each be simple.

It also produces something a single model does not: a probability attached to each trade. That probability can size the position — larger when the meta-model is confident, smaller or zero when it is not — which is the connection to bet sizing that López de Prado draws in the same chapter.

Where it goes wrong

  1. The meta-model sees a lopsided target. If the primary model is right 40% of the time, the meta-label is 40% ones and 60% zeros, and a lazy meta-model learns to say "skip" always. Judge it on precision and MCC, never on accuracy, or it will look excellent while doing nothing.
  2. Too few rows. The meta-model trains only on the bars where the primary model fired. A primary model that fires 200 times in ten years leaves 200 rows to learn from, which is not many. The sample-size guide applies with extra force.
  3. Barriers tuned to flatter the result. If you choose the target and stop widths by looking at which produces the best backtest, you have overfit the definition of the problem, which is worse than overfitting a model because no validation split will catch it. Set the barriers from the strategy's logic and leave them.
  4. Leaking through the primary model. If the primary model's signals were themselves generated with hindsight — a repainting indicator, a fill at the signal bar — the meta-model learns to trust a liar.

Putting the two together

The combined pipeline, in order: define barriers in volatility units; label every bar by which barrier its trade would have hit; train a primary model on those labels with a chronological, purged split; record where it fires; build meta-labels from whether those trades were profitable after costs; train a meta-model on those rows with its own features; trade only when the primary model fires and the meta-model approves, sized by its probability; walk the whole thing forward. Judge the gate on precision and MCC in the report, and if you have several candidate gates, the ensemble guide covers letting them vote.

It sounds like a lot. It is a lot, in code — which is why most people who cite the book have not done it.

How Wise Apple does this

In Wise Apple, both techniques are settings rather than projects. Triple-Barrier Labels defines every label by target, stop and time barriers, with each barrier's width expressed as an ATR multiple or a return-volatility multiple, so the label means the same trade in every regime. Meta-Labeling adds the second phase: any model on the bench can serve as the gate, it trains only on the bars where the primary model fired, and its label is whether that trade was profitable net of entry fees. The Embargo Bars setting supplies the purge gap the overlapping labels demand, and the gate's precision and MCC are reported separately from the primary model's, so a gate that has learned to say "skip" is visible for what it is.

Questions traders ask about meta-labeling and triple-barrier labels

What is the triple-barrier method in trading?

A way of labelling training data for a trading model, introduced in López de Prado's Advances in Financial Machine Learning. Instead of asking whether price rose over a fixed horizon, each label records which of three barriers a trade would have touched first: a profit target (+1), a stop (−1), or a time limit (0). The label then describes the outcome of the trade you would actually have taken, path included.

What is meta-labeling?

A second model trained on a narrower question: given that a primary model or rule wants to trade, should we take this particular signal? It trains only on the bars where the primary model fired, its label is whether that trade was profitable, and it can veto but not reverse. The result is a probability per trade that can filter signals and size positions.

Why should barrier widths be set in volatility units?

Because a 2% move is a large move in a quiet market and noise in a volatile one. Barriers set as multiples of ATR or rolling standard deviation describe the same trade in every regime, so the model learns direction rather than learning to predict volatility. It is the most important detail in the method.

Does meta-labeling improve accuracy or precision?

Precision. The meta-model's job is to remove the primary model's bad signals, so it raises the share of taken trades that win at the cost of taking fewer. Judge it on precision and the Matthews correlation coefficient, not accuracy — with an imbalanced meta-label, a model that always says "skip" scores high accuracy while doing nothing.