Quant techniques · financial machine learning

Triple-barrier labels: make a financial target follow the path

A classifier trained to predict whether tomorrow’s return is positive ignores whether the position first suffered a stop-sized loss, whether it reached a target early, or whether the opportunity simply expired. Triple-barrier labeling defines an event by the first of three outcomes: an upper profit barrier, a lower stop barrier, or a vertical time barrier.

Move the upper profit barrier

First-hit label in a fixed path

Toy path peaks at +4%, never hits the lower barrier, and expires at 0%; 1 means upper barrier hit.

Define the event before the label

For an event beginning at time t0t_0, let s∈{−1,+1}s\in\{-1,+1\} denote the trade side supplied by a primary signal, and let rt0,t=slog⁡(St/St0)r_{t_0,t}=s\log(S_t/S_{t_0}) be side-adjusted return. Choose a target scale σt0\sigma_{t_0}, often a volatility estimate known at entry, and multipliers u,ℓ>0u,\ell>0. The horizontal barriers are

rt0,t≥uσt0(profit taking),rt0,t≤−ℓσt0(stop loss).r_{t_0,t}\ge u\sigma_{t_0}\quad\text{(profit taking)},\qquad r_{t_0,t}\le-\ell\sigma_{t_0}\quad\text{(stop loss)}.

A vertical barrier sets the maximum holding time TvT_v. The event ends at the first barrier touched or at TvT_v. The label can encode the sign of the realised side-adjusted return, or a meta-label can record whether the primary signal’s proposed trade was profitable. State the convention explicitly: label definitions differ across implementations, especially for vertical exits and ties.

A worked path

Suppose entry price is 100, the side is long, the target volatility scale is 2%, and both horizontal multipliers are 1.5. The upper and lower price barriers are approximately 100e0.03=103.05100e^{0.03}=103.05 and 100e−0.03=97.04100e^{-0.03}=97.04. If the path reaches 98, then 101, then 103.20 before the vertical horizon, the profit barrier is hit first and the event closes there. A later fall below 97.04 is irrelevant because the trade would already have exited.

If neither horizontal barrier is touched by the vertical date, the time exit determines the outcome. That event is not automatically a zero-return observation: it has a realised mark-to-market return which can be positive or negative. How it is labelled depends on the modelling target.

Use information available at entry

The volatility target and barrier widths must be determined using only data available at t0t_0. Estimating the scale with future returns leaks information into the label construction and can create artificially clean classification results.

Why use three barriers?

A fixed-horizon label evaluates return only at a predetermined future time. It is simple, but it can miss the order of events along the path and gives a fixed percentage move different meaning in calm and volatile regimes. Triple barriers make the target closer to a trade outcome: risk and reward levels can scale with volatility, and the vertical barrier limits event duration.

This does not make the label a full execution simulation. OHLC bars may not reveal which barrier was hit first if both lie inside a bar’s range; use higher-frequency data or a conservative tie convention. Bid–ask spread, market impact, gaps, partial fills, and stop slippage also affect realised results and should be incorporated when relevant.

Meta-labeling separates direction from participation

A primary model may generate a side sts_t, perhaps from a trend signal or discretionary view. A secondary classifier receives features and asks whether to take that proposed trade; its target is often binary profitability under the primary side. Its probability can be mapped to position size under a separate risk rule.

This is not a way to turn a weak signal automatically into alpha. The primary model, secondary model, threshold, and sizing rule must be evaluated together out of sample. Training and evaluation labels often overlap in time because events have variable horizons; use event start and end times with purging and, where appropriate, embargoes, as described in the purged cross-validation post.

Common mistakes

  • Looking only at the close when high/low data show a barrier may have been crossed intrabar.
  • Treating a vertical exit as a neutral label without defining the target convention.
  • Using volatility measured over the event’s future path to set barriers at entry.
  • Forgetting that labels overlap and are not independent samples.
  • Reporting classifier accuracy without translating predictions into net strategy returns after costs, turnover, and sizing.

Practice

BarrierA short signal enters at 50. The side-adjusted return first rises above the stop threshold before reaching the profit threshold. Which barrier ends the event?
Show answer

The stop-loss barrier ends the event at its first touch. For a short side, side-adjusted return changes sign relative to the raw long return, so ensure the implementation maps upper and lower barriers to the trade direction consistently.

Time exitNeither horizontal barrier is hit by the vertical barrier. Is the realised return necessarily zero?
Show answer

No. The position is marked at the vertical exit price and can have a positive or negative return. The label depends on whether the task predicts sign, threshold crossing, or primary-signal profitability.

LeakageWhy can a training event whose start time is before a test event still need to be purged?
Show answer

Its label may use prices from after the test event begins. If the event intervals overlap, training and test labels share outcome information even though their feature timestamps are ordered.

Further reading: López de Prado (2018), Advances in Financial Machine Learning, Chapter 3, “Labeling.” Publisher chapter index.