Concept 08 / 52·Risk & Exits·Volatility stops
‹ BreakoutCommodity Channel Index (CCI) ›

Chandelier Exit in Pine Script

Chandelier stop · ATR trailing stop · highest-high ATR stop · LeBeau stop

A trailing stop hung 3 ATR below the highest high of the last 22 bars, so the stop rises with the trend, widens with volatility and never moves against the position.

Reads best on: Daily, 4-hour and 1-hour charts of trending markets: futures, forex majors, crypto and large caps. It gives poor results as a stand-alone rule in ranges and on charts below 5 minutes.
On this page: the Pine v6 script, checked, drawn on real NVDA bars. Backtest it free, costs charged, every trade on the chart.
01

Definition

The Chandelier Exit is a trailing stop hung from the highest high of a lookback window at a distance of a multiple of the average true range. For a long, the stop is the highest high of the last 22 bars minus 3 ATR; for a short, the lowest low plus 3 ATR. It belongs to the volatility stops family, with SuperTrend and the parabolic SAR, and its name is the picture: the stop hangs below the ceiling of the move like a chandelier, and it rises every time the ceiling rises.

The design ties the stop to the two things a trend produces: new extremes and its own volatility. Measuring from the highest high rather than from the close means a pullback is judged from the top of the move, so the stop asks whether price has fallen more than 3 average ranges from the best level reached. Measuring in ATR means the stop is wide in a volatile market and tight in a quiet one, without changing a setting. The ratchet completes it: the stop only moves in the trade's favour, so a wide bar cannot push it back down.

Chuck LeBeau designed the Chandelier Exit and it spread through the systematic trend-following community as one of the standard ways to leave a trend trade. The reference settings are a 22-bar lookback, roughly one trading month, and a multiple of 3 ATR, with the ATR measured over the same 22 bars. The library script draws it as a green line under price while the trend is up and a red line above price while it is down, flips when the close crosses the opposite stop, and marks and alerts on every flip.

On the chart the long stop steps up under an uptrend and goes flat during a pullback, since the highest high stands still and ATR barely changes. The distance between price and the stop is the room the trade has. When a close falls through the stop the script flips: the green line stops, a red line appears above price, hung from the lowest low plus 3 ATR, and it steps down as the downtrend makes new lows. In a range the flips come every few bars, which is the signal that the tool is being used in the wrong regime.

02

Reading the chart

Find the ceiling of the move, hang the stop below it, and watch it ratchet.

  1. In an uptrend, find the highest high of the last 22 bars. The stop sits 3 ATR below it, and the library script draws that level as a green line under price.
  2. Watch the line ratchet. Every new high lifts it, a pullback leaves it flat, and it never moves down while the trend holds; if a chart shows it dropping, the tool is not ratcheted.
  3. Read the gap between the close and the stop in ATR. Around 3 ATR just after a new high, shrinking as price pulls back; a gap near zero means the trade is one bar from its exit.
  4. Treat a close below the stop as the exit. The script flips on the confirmed close, not on a wick, so an intrabar spike through the line is not a signal.
  5. After a flip, read the mirror. A red line above price is the short stop, hung from the lowest low plus 3 ATR, and it steps down with each new low.
  6. Count the flips. One flip per trend is the tool working; flips every few bars mean a range, and trend stops lose their use until a trend returns.
03

The maths

The stop is the highest high minus an ATR multiple, ratcheted so that it never retreats, with a mirror for shorts.

LongRawt=HHn−m ATRn\mathrm{LongRaw}_t = \mathrm{HH}_n - m \, \mathrm{ATR}_n
LongStopt={max⁡(LongRawt, LongStopt−1)Ct−1>LongStopt−1LongRawtotherwise\mathrm{LongStop}_t = \begin{cases} \max(\mathrm{LongRaw}_t,\, \mathrm{LongStop}_{t-1}) & C_{t-1} > \mathrm{LongStop}_{t-1} \\ \mathrm{LongRaw}_t & \text{otherwise} \end{cases}
ShortRawt=LLn+m ATRn\mathrm{ShortRaw}_t = \mathrm{LL}_n + m \, \mathrm{ATR}_n
ShortStopt={min⁡(ShortRawt, ShortStopt−1)Ct−1<ShortStopt−1ShortRawtotherwise\mathrm{ShortStop}_t = \begin{cases} \min(\mathrm{ShortRaw}_t,\, \mathrm{ShortStop}_{t-1}) & C_{t-1} < \mathrm{ShortStop}_{t-1} \\ \mathrm{ShortRaw}_t & \text{otherwise} \end{cases}
Dirt={upCt>ShortStopt−1downCt<LongStopt−1Dirt−1otherwise\mathrm{Dir}_t = \begin{cases} \text{up} & C_t > \mathrm{ShortStop}_{t-1} \\ \text{down} & C_t < \mathrm{LongStop}_{t-1} \\ \mathrm{Dir}_{t-1} & \text{otherwise} \end{cases}
HHn\mathrm{HH}_nthe highest high of the last n bars, or the highest close when anchoring to closes
LLn\mathrm{LL}_nthe lowest low of the last n bars, or the lowest close when anchoring to closes
nnthe lookback, 22 by default, also the ATR length in the script
mmthe ATR multiplier, 3 by default
ATRn\mathrm{ATR}_nthe average true range over n bars
LongRawt\mathrm{LongRaw}_tthe raw long stop at bar t, the lookback high less the ATR multiple, before the ratchet
LongStopt\mathrm{LongStop}_tthe stop under a long position at bar t
LongStopt−1\mathrm{LongStop}_{t-1}the long stop of the previous bar
ShortRawt\mathrm{ShortRaw}_tthe raw short stop at bar t, the lookback low plus the ATR multiple, before the ratchet
ShortStopt\mathrm{ShortStop}_tthe stop above a short position at bar t
ShortStopt−1\mathrm{ShortStop}_{t-1}the short stop of the previous bar
CtC_tthe close of bar t
Ct−1C_{t-1}the close of the previous bar
Dirt\mathrm{Dir}_tthe direction the script is in, up or down, which selects the line drawn
Dirt−1\mathrm{Dir}_{t-1}the direction of the previous bar

LeBeau's original hangs the stop from the highest high since the trade was entered. The indicator form uses a fixed lookback, and the two agree once the trade is older than the window.

The library script can anchor to closes instead of highs and lows. The highest close is lower than the highest high, so that version hangs the stop a little lower, ignores wick spikes and exits later.

In the script the ATR length equals the lookback, 22 by default, so one input sets both; the original also used 22 for both.

The ratchet is conditional on the previous close being on the right side of the previous stop, which lets the stop reset to its raw value after a flip rather than carrying the old level.

04

Inputs that matter

InputTypicalWhat changing it does
Lookback22Shorter anchors the stop to a more recent extreme after a flip and makes its ATR react faster to wide bars; longer keeps the ceiling and the ATR steadier.
ATR multiplier3Lower tightens the stop and exits earlier with more whipsaws; higher gives the trend room and gives back more when it ends.
Anchor on highs and lowsonOff anchors to closes, which ignores wick spikes, hangs the stop a little lower and exits later.
05

In practice

  • As the trailing stop of a trend trade: the entry comes from any trigger and the stop moves to the Chandelier level on every bar, which is what the library's line shows.
  • As a flip trigger: the change from a green line under price to a red line above it is a trend change by definition, and the script marks and alerts on it.
  • As the exit of another system: pair it with an EMA cross or a breakout entry, so the entry decides when and the Chandelier decides how long, a followup the library offers.
  • As a trend-health read: a close far above the stop is a trade with room; a close a fraction of an ATR above it is a trade about to be tested.
  • As an initial risk measure: the distance from the entry price to the Chandelier level on the entry bar is the initial risk, and it sizes the position.
  • As a comparison for fixed trails: a percent trailing stop that is wider than the Chandelier in calm markets and tighter in volatile ones has the trade-off backwards.
06

Where it goes wrong

  • Setting the multiple too low. At 1 or 1.5 ATR the stop sits inside ordinary pullbacks and the trade is stopped on noise; start at 3 and lower it only with evidence.
  • Moving the stop back down by hand after a wide bar. The ratchet is the point; a stop that can retreat is not a trailing stop.
  • Using the flips as entries in a range. The Chandelier is an exit tool; in a range it flips every few bars and each flip is a loss.
  • Expecting the stop to jump after a volatility spike. A bigger ATR lowers the raw stop, so the ratchet holds it flat until price makes new highs.
07

Compared with

SuperTrend. SuperTrend hangs its band from the bar's midpoint at a fixed ATR multiple. The Chandelier hangs from the highest high of a window, so it measures the pullback from the top of the move and sits differently after a spike.

Parabolic SAR. The parabolic SAR accelerates toward price as a trend ages, so it tightens on time. The Chandelier tightens only on price and volatility, and gives a mature trend the same room as a young one.

Trailing Stop. A generic trailing stop trails the best price since entry by a chosen distance. The Chandelier is one specific recipe for that distance, an ATR multiple from a lookback high, with a ratchet built in.

Average True Range. ATR is the unit; the Chandelier is one of the things built from it. This article is about the stop and its ratchet, the ATR article about the measure itself, stops in general and position sizing.

08

Build it in Quant

Type one of these in the Quant desk, or click it. A request that fits a checked template is assembled on the spot without a credit; anything beyond the blanks goes to the copilot, which edits on top of the checked script.

Open Chandelier Exit on the workbench chart
Drawn on real data; then audit, backtest and refine in conversation.
Open in Quant →
09

Questions

  • How is the Chandelier different from SuperTrend?

    Both are ATR trailing lines that flip sides, but they hang from different points. SuperTrend measures from the bar's midpoint with a 3 ATR band, so it sits at a fixed distance from the current bar. The Chandelier measures from the highest high of the last 22 bars, so its distance from price grows during a pullback and it reacts to the move's ceiling, not to each bar.

  • What multiple and lookback should I use?

    22 and 3 are the reference and suit daily and 4-hour trend trades. Use 2 to 2.5 for shorter swings where a tighter exit is acceptable, and 3.5 to 4 for long-term trend following where surviving pullbacks matters more than giving back at the end. Change the lookback only if you want the ceiling measured over a different horizon.

  • Should the stop use highs or closes?

    Highs and lows are the original and the library default, and they measure the pullback from the true top. Closes give a stop that hangs a little lower, ignores wicks and exits later, because a spike no longer lifts the ceiling. Use closes on instruments with long wicks and noisy intrabar prints; use highs where the extremes are meaningful.

  • Why did the stop not rise after a big up bar?

    Because a big bar raises ATR as well as the high. The raw stop is the high minus 3 ATR, and if ATR grew more than the high did, the raw level fell; the ratchet then holds the stop at its previous value. The stop rises again once price makes further highs or ATR settles.

  • Can the Chandelier be an entry trigger?

    It can, and the library marks the flips, but it is designed as an exit. Flips lag the turn and fire constantly in ranges. Traders who enter on flips usually add a trend filter, a higher-timeframe direction or an ADX threshold, and accept that the entry is late in exchange for a stop that is defined from the first bar.

  • Does it work on intraday charts?

    On 1-hour and 4-hour charts of trending instruments it works as on daily bars, with the same settings. On 5-minute charts the ATR is small and the session's own rhythm dominates, so the stop is hit at the open and the close for reasons unrelated to the trend. Below 5 minutes it is a whipsaw generator.