Triple-Barrier Method and Meta-Labeling in Practice

The triple-barrier method labels trades by which of a profit target, stop or time limit is hit first. Meta-labeling then learns which signals to take.

Trigr Research6 min read
On this page
  1. What is wrong with fixed-horizon labels?
  2. How does the triple-barrier method work?
  3. What is meta-labeling?
  4. How does Trigr apply triple barriers and meta-labeling?
  5. When is meta-labeling the wrong tool?
  6. Next steps

TL;DR: The triple-barrier method labels each trade by whichever comes first: a profit target, a stop-loss or a time limit, with the target and stop scaled to recent volatility. Meta-labeling, also from López de Prado, keeps your strategy in charge of direction and trains a model only to decide which of its signals to take. Together they make ML answer a question that matches how you actually trade.

What is wrong with fixed-horizon labels?

The most common way to label market data for machine learning is the fixed horizon: look n bars ahead and label the bar +1 if the return is above a threshold, −1 if below, 0 otherwise. It is simple and it is misleading.

  • It ignores the path. A long trade that falls 6% and hits its stop on bar three, then recovers to finish the day up 1%, gets labeled a winner. Your account recorded a loss.
  • It uses a fixed threshold in a changing market. A 1% move is noise during a volatile week and a real move during a quiet one. The same threshold produces mostly zeros in calm periods and mostly ±1 in wild ones.
  • It does not match the strategy. Real strategies exit on targets, stops and time limits. A label that knows nothing about exits trains the model on a different game.

How does the triple-barrier method work?

López de Prado introduces the method in chapter 3 of Advances in Financial Machine Learning (Wiley, 2018). For each event, such as a bar where your strategy would enter, you place three barriers:

  1. Upper barrier (profit-take): entry price plus a multiple of recent volatility.
  2. Lower barrier (stop-loss): entry price minus a multiple of recent volatility.
  3. Vertical barrier (time): a maximum holding period in bars.

Then walk forward through the price path and see which barrier is touched first.

First touch Label Meaning
Upper barrier +1 The trade reached its target
Lower barrier −1 The trade hit its stop
Vertical barrier Sign of the return at expiry, or 0 The trade timed out

Volatility is usually an exponentially weighted standard deviation of recent returns. Because barrier widths move with it, a label means the same thing in a quiet market and a volatile one.

The method also records when each label resolved. That end time is essential downstream: purged cross-validation uses it to remove training samples that overlap the test window, and sample weighting uses it to measure how much labels overlap each other. Our purged walk-forward guide explains why.

Choosing barrier settings

  • Symmetric or asymmetric. Equal multiples for target and stop give a neutral label. Asymmetric settings encode a view, such as letting winners run.
  • Horizon. Longer time barriers produce fewer timeouts but more overlap between labels, which reduces the number of independent observations.
  • One barrier off. Setting the profit-take to zero, for example, gives "did the trade survive its stop within the horizon?", which is sometimes the question that matters.

Every setting you try is a trial. Changing barriers until the backtest looks good is overfitting like any other parameter search.

What is meta-labeling?

Meta-labeling, also from chapter 3 of the book, splits a trading decision into two parts:

  • Side: long or short. A primary model decides this. It can be a rule, an indicator crossover, a discretionary view or another model.
  • Size: whether to take the trade and how much. A secondary model, the meta-model, decides this.

To build the training set, you take only the bars where the primary strategy fires, label each one with the triple-barrier method in the direction the primary chose, and turn that into a binary label: 1 if the trade made money, 0 if it did not. The meta-model then learns which conditions separate the primary strategy's good trades from its bad ones.

Why does meta-labeling help?

  • It is an easier problem. Predicting market direction is extremely hard. Predicting whether a known setup works under current conditions is narrower and often more learnable.
  • It improves precision. A primary rule tuned for high recall catches most opportunities but many false positives. The meta-model's job is to filter them out, trading some recall for precision. scikit-learn's guide to precision, recall and F-measures covers the metrics.
  • It keeps the strategy interpretable. The entry logic remains yours. The model only says "skip this one".
  • It limits damage. A meta-model that learns nothing mostly lets trades through or blocks them; it cannot invent trades the primary never signaled.

What are the pitfalls?

  • Class imbalance. If most of the primary strategy's trades win, a meta-model that always says "take" scores high accuracy while adding nothing. Judge it against the majority-class base rate, not 50%.
  • Few events. A strategy that fires thirty times a year gives the meta-model very little to learn from. Expect noisy results.
  • Leakage through features. Meta-labels are only as honest as the features. Every input must be point-in-time.

How does Trigr apply triple barriers and meta-labeling?

Trigr's Optimize with ML in Studio runs in meta-labeling mode. The ML optimization docs describe the full pipeline; the labeling specifics are:

  • The primary model is your strategy. You build it in the no-code strategy builder: a trigger, filters, a signal and risk settings. Its entries are the events.
  • Labels start where fills happen. Trigr's backtester fills at the next bar's open after a signal, so each label is measured from that open, and the barrier width uses only volatility known before it. Bars where the strategy does not enter are not used as training events.
  • Volatility-scaled barriers. Profit-take and stop-loss barriers are set in units of an exponentially weighted volatility of bar returns, with a time barrier that depends on the timeframe.
  • Binary meta-labels. An event is labeled 1 if the trade in the strategy's direction made money by the time the first barrier was touched, 0 otherwise.
  • Censored events dropped. Recent events whose full horizon has not played out yet are excluded rather than labeled as timeouts.
  • Uniqueness weights. Overlapping labels are down-weighted by average uniqueness times return size.

The trained model acts as a binary gate: each of your strategy's entries is either taken or skipped. Trigr does not size positions from the model's predicted probability; position size still comes from your RISK node. The result shows the gated backtest, using out-of-sample predictions only, next to your original strategy, with the difference.

Two things are easy to misread, so to be explicit:

  • The meta-model does not change your exits. Take-profit, stop-loss, ATR trail and time stop remain as configured.
  • Model families (LightGBM, random forest, XGBoost) run with fixed parameters and the winner is chosen on purged walk-forward out-of-sample results. There is no hyperparameter tuning, and changing barrier settings is not part of an automated search.

The leak battery is also meta-aware. Its shuffled-label control and its accuracy ceiling are measured against the majority-class base rate rather than 50%, so an imbalanced gate is not falsely flagged as leaked just because "always take" already scores high accuracy. Whether the gate adds real value is judged by the out-of-sample gated backtest, the Deflated Sharpe Ratio and PBO, not by raw accuracy.

When is meta-labeling the wrong tool?

  • When the primary strategy has no edge at all. A filter can remove bad trades, but it rarely turns a losing idea into a winning one. Fix the idea first.
  • When the strategy trades rarely. Too few events means a noisy gate. Trigr flags low-power runs.
  • When you want direction from the model. Meta-labeling assumes the side comes from elsewhere.

Backtests are not guarantees; perps are leveraged and can lose more than expected. A gated backtest that beats the baseline is still a backtest, so forward-test before trusting it.

Next steps

To see how labels fit into the whole pipeline, from point-in-time features to leak checks, read machine learning for trading strategies without overfitting. If you want to run it from ChatGPT, Claude or Codex, connect your AI assistant and ask it to optimize a saved strategy.

Frequently asked questions

What is the triple-barrier method?

It is a labeling technique from Marcos López de Prado's Advances in Financial Machine Learning. Each event gets an upper profit-taking barrier, a lower stop-loss barrier and a vertical time barrier, and is labeled by whichever barrier the price touches first.

What is meta-labeling in trading?

Meta-labeling trains a secondary model to predict whether a primary strategy's trade will be profitable. The primary strategy decides direction; the meta-model decides whether to take the trade, and optionally how large to make it.

Why are triple-barrier barriers scaled by volatility?

A fixed 2% target means very different things in a quiet market and a volatile one. Scaling barriers to recent volatility keeps labels comparable across regimes, so the model learns about the setup rather than the volatility level.

Does Trigr use meta-labeling?

Yes. Trigr's Optimize with ML in Studio labels your strategy's own entries with volatility-scaled triple barriers and trains a model to take or skip each one. It uses the model as a binary gate and does not size positions from the predicted probability.

Put the idea to an honest test.

Describe a strategy in plain English or from your own AI assistant, backtest it on point-in-time data, and forward-test it on paper before any real money is involved.