Skip to content

Free TradingView indicator

Chandelier Exit

ATR chandelier trailing stops hung from recent highs and lows, with ratcheting stop lines, direction flips and alerts.

Risk managementv1.0TradingView (Pine Script v6) Non-repainting signals Alerts

What it does

The Chandelier Exit is a volatility-based trailing stop. In a long trend it "hangs" a stop a fixed number of ATRs below the highest high of the lookback window, like a chandelier from a ceiling. In a short trend it sets the stop the same distance above the lowest low.

The indicator shows only the stop that applies to the current direction, ratchets it in the trade's favor, and flips direction when price closes through it.

How it works

  1. ATR is calculated over the lookback length (22 by default, about a month of daily bars).
  2. Long stop = highest high over the lookback − multiplier × ATR.
  3. Short stop = lowest low over the lookback + multiplier × ATR.
  4. While the previous close stays above the previous long stop, the long stop can only rise (it takes the higher of the new and previous values). The short stop can only fall while the previous close stays below it.
  5. Direction becomes long when the close rises above the previous short stop, and short when the close falls below the previous long stop.

With "Use close for extremes" on, the highest and lowest closes replace highs and lows, which makes the stop a little less sensitive to wicks. Flip labels and alerts require a closed bar.

How to use it

  • The main use is trade management: once in a position, the active line shows where a volatility-based stop-loss would sit if you trailed it.
  • A flip shows that price has moved further against the prior trend than its recent volatility would normally allow. Some traders use flips as entry ideas in the new direction, ideally with a trend filter.
  • The stop distance changes with ATR, so position size should change too. The Position Size Calculator helps keep risk per trade consistent.
  • Works on any liquid market. Lower multipliers suit short-term trading; 3.0 is a common swing setting on H4 and D1.

Settings

InputDefaultWhat it changes
Lookback / ATR length22Window for the extreme and the ATR.
ATR multiplier3.0Stop distance. Higher = fewer flips, larger risk per trade.
Use close for extremesOffHighs/lows or closes as the anchor.
Show direction-flip labelsOnLong/Short labels on flips.
Shade active stop zoneOnFill between price and the active stop.
Long / Short stop colorteal / redLine colors.

Limitations

  • As a trailing stop it gives back part of every move before flipping; the wider the multiplier, the more it gives back.
  • In sideways markets it can flip repeatedly, each time near the edge of the range.
  • The indicator works on closing prices. In live trading a stop order would be hit intrabar, and gaps or slippage can fill you well beyond the line.
  • ATR expands sharply after news, which can push the stop further away just when you might want it tighter.

Pine Script source

In TradingView open Pine Editor, paste the code, click Save and then Add to chart.

FXP_ChandelierExit.pine

56 lines

// © FXPIPS ONLINE — https://fxpips.online/tradingview-indicators/chandelier-exit/
// License: MIT. Educational tool — not financial advice. Trading involves substantial risk.
//@version=6
// ATR-based chandelier stops hung from the highest high (long) or lowest low (short) of the
// lookback window. Stops only ratchet in the trade's favor; direction flips confirm on bar close.
indicator("FXP Chandelier Exit", shorttitle = "FXP Chandelier", overlay = true)

// ── Inputs ─────────────────────────────────────────────────────────────
grpC     = "Calculation"
lookback = input.int(22, "Lookback / ATR length", minval = 1, group = grpC)
mult     = input.float(3.0, "ATR multiplier", minval = 0.1, step = 0.1, group = grpC)
useClose = input.bool(false, "Use close for extremes", group = grpC, tooltip = "Off = highest high / lowest low. On = highest / lowest close.")

grpV        = "Display"
showSignals = input.bool(true, "Show direction-flip labels", group = grpV)
showFill    = input.bool(true, "Shade active stop zone", group = grpV)
colLong     = input.color(#26a69a, "Long stop color", group = grpV)
colShort    = input.color(#ef5350, "Short stop color", group = grpV)

// ── Calculation ────────────────────────────────────────────────────────
atr       = ta.atr(lookback)
highClose = ta.highest(close, lookback)
highHigh  = ta.highest(high, lookback)
lowClose  = ta.lowest(close, lookback)
lowLow    = ta.lowest(low, lookback)

float longStop  = (useClose ? highClose : highHigh) - mult * atr
float shortStop = (useClose ? lowClose : lowLow) + mult * atr

longPrev  = nz(longStop[1], longStop)
shortPrev = nz(shortStop[1], shortStop)
longStop  := close[1] > longPrev ? math.max(longStop, longPrev) : longStop
shortStop := close[1] < shortPrev ? math.min(shortStop, shortPrev) : shortStop

var int dir = 1
dir := close > shortPrev ? 1 : close < longPrev ? -1 : dir

flipLong   = dir == 1 and dir[1] == -1
flipShort  = dir == -1 and dir[1] == 1
longSignal  = flipLong and barstate.isconfirmed
shortSignal = flipShort and barstate.isconfirmed

// ── Plots ──────────────────────────────────────────────────────────────
pLong  = plot(dir == 1 ? longStop : na, "Long stop", color = colLong, linewidth = 2, style = plot.style_linebr)
pShort = plot(dir == -1 ? shortStop : na, "Short stop", color = colShort, linewidth = 2, style = plot.style_linebr)
pMid   = plot(ohlc4, "Price midpoint", display = display.none)
fill(pMid, pLong, color = showFill ? color.new(colLong, 90) : na, title = "Long zone")
fill(pMid, pShort, color = showFill ? color.new(colShort, 90) : na, title = "Short zone")

plotshape(showSignals and longSignal, "Flip to long", style = shape.labelup, location = location.belowbar, color = colLong, text = "Long", textcolor = color.white, size = size.small)
plotshape(showSignals and shortSignal, "Flip to short", style = shape.labeldown, location = location.abovebar, color = colShort, text = "Short", textcolor = color.white, size = size.small)

// ── Alerts ─────────────────────────────────────────────────────────────
alertcondition(longSignal, "Chandelier flip to long", "Chandelier Exit flipped to long on {{ticker}} ({{interval}})")
alertcondition(shortSignal, "Chandelier flip to short", "Chandelier Exit flipped to short on {{ticker}} ({{interval}})")

Key inputs

Key inputs of Chandelier Exit
InputDefaultDescription
Lookback / ATR length22Bars for both the highest high / lowest low and the ATR.
ATR multiplier3.0Distance of the stop from the extreme, in ATRs.
Use close for extremesOffHang the stop from the highest or lowest close instead of the high or low.
Shade active stop zoneOnLight fill between price and the active stop.

Educational tools, not advice. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related tradingview indicators