Indicator · Pine Script v6 · On the chart

Chandelier Exit

by mihakralj

This indicator plots Chandelier Exit levels on the price chart.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code45
Settings2inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

45 lines of Pine Script v6 from lib/reversals/chandelier/chandelier.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

chandelier.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("Chandelier Exit (CHANDELIER)", "CHANDELIER", overlay=true)

//@function Chandelier Exit — ATR-based trailing stops that hang from the highest high
//          (ExitLong) or rise from the lowest low (ExitShort) over a lookback period.
//          Uses SMA-seeded Wilder's RMA for ATR, matching Skender/TradingView convention.
//@param period Lookback for ATR and rolling HH/LL (default 22)
//@param multiplier ATR scaling factor (default 3.0)
//@returns [exitLong, exitShort] — two overlay stop levels
//@reference Charles Le Beau; Alexander Elder, "Come Into My Trading Room" (2002)
//@optimized O(1) per bar using ta.rma, ta.highest, ta.lowest
chandelier(simple int period = 22, simple float multiplier = 3.0) =>
    if period < 1
        runtime.error("Period must be >= 1")
    if multiplier <= 0
        runtime.error("Multiplier must be > 0")

    // True Range
    float tr = na(close[1]) ? high - low : math.max(high - low, math.max(math.abs(high - close[1]), math.abs(low - close[1])))

    // Wilder's ATR (RMA = EMA with alpha = 1/period, SMA-seeded)
    float atr = ta.rma(tr, period)

    // Rolling extremes over the lookback window
    float hh = ta.highest(high, period)
    float ll = ta.lowest(low, period)

    // Chandelier exits
    float exit_long  = hh - multiplier * atr
    float exit_short = ll + multiplier * atr

    [exit_long, exit_short]

// ── Inputs ──
int   i_period     = input.int(22, "Period", minval=1)
float i_multiplier = input.float(3.0, "Multiplier", minval=0.01, step=0.1)

// ── Calculation ──
[exit_long, exit_short] = chandelier(i_period, i_multiplier)

// ── Plot ──
plot(exit_long,  "Exit Long",  color=color.green, linewidth=2)
plot(exit_short, "Exit Short", color=color.red,   linewidth=2)

Overview

Chandelier Exit computes true range and a Wilder RMA of true range over a lookback, then subtracts a scaled ATR from the highest high for the long exit and adds it to the lowest low for the short exit. The period input sets both the ATR length and the rolling extreme window, while the multiplier scales the ATR distance. It draws two overlay lines and does not place orders or define trade exits.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Periodint22i_period
Multiplierfloat3.0i_multiplier
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Chandelier Exit

by everget
948 stars

This indicator plots an ATR-based Chandelier Exit trailing stop on the price chart. It tracks a long stop under recent highs and a short stop above recent lows, then switches direction when price crosses the opposite stop. Buy and sell labels mark those flips.

Indicator v6 Volatility & bandsTrend Repaints
Updated 10 days ago · GPL-3.0 GitHub repository of Chandelier Exit

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
330 stars

Range Filter [Alorse] is a technical indicator overlay for TradingView designed to filter market volatility and identify price trends. It calculates a smoothed range based on historical volatility using a configurable sampling period and multiplier applied to

Indicator v5 TrendVolatility & bands
Updated 2 months ago · None stated GitHub repository of Range Filter [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers