Chandelier Exit (chandelier)
Chandelier Exit produces two price levels that measure a pullback from a recent extreme while accounting for volatility. The long level sits below the high of the window, while the short level sits above its low. Their distance from those extremes is based on ATR: it grows when recent movement is wider and contracts when movement is tighter.
length defines the window in which the extremes are found, atr_length sets the horizon of the volatility measure, and multiplier controls the applied distance. The block measures neither trend direction nor trend strength: it only exposes two thresholds for use in expressions and does not close a position itself. Because the extremes are recalculated over a rolling window, these are rolling levels that can move in either direction, not ratcheting stops.
Block declaration
A strategy can contain multiple [[chandelier]] blocks. Each block produces two numeric series expressed in price units: the long exit level identified by long_id and the short exit level identified by short_id.
The [[chandelier]] block does not have a source parameter because it always uses the candle high, low, and close prices. high and low determine the recent extremes; high, low, and close are used to calculate ATR.
Examples
Minimal setup
This block uses the defaults: 22 for length, 22 for atr_length, and 3.0 for multiplier.
[[chandelier]]
long_id = "chandelier_long"
short_id = "chandelier_short"Custom fixed setup
This block finds extremes over 10 candles, calculates ATR over 14 candles, and offsets the extremes by an ATR multiplier of 2.5.
[[chandelier]]
long_id = "chandelier_long"
short_id = "chandelier_short"
length = 10
atr_length = 14
multiplier = 2.5Finding the optimal parameters
This block explores several extreme windows, ATR lengths, and multipliers. One backtest runs for each combination in the grid.
[[chandelier]]
long_id = "chandelier_long"
short_id = "chandelier_short"
length.start = 10
length.stop = 30
length.step = 5
atr_length.start = 10
atr_length.stop = 30
atr_length.step = 5
multiplier.start = 1.5
multiplier.stop = 3.5
multiplier.step = 0.5Long and short exit conditions
This example creates two separate conditions. The first becomes true when the close falls below the long level; the second when the close rises above the short level. The following blocks, represented by ..., determine which action the strategy actually executes.
[[chandelier]]
long_id = "chandelier_long"
short_id = "chandelier_short"
[[condition]]
id = "long_exit_signal"
condition = "close < chandelier_long"
next_block_id = "..."
[[condition]]
id = "short_exit_signal"
condition = "close > chandelier_short"
next_block_id = "..."Dedicated symbol and timeframe
This Chandelier Exit block uses the daily candles from BINANCE:ETHUSDT. The high, low, and close prices come from this symbol and timeframe, independently of the primary symbol and timeframe defined in [backtest]. See Exchanges, Symbols and Timeframes for alignment rules.
[[chandelier]]
long_id = "chandelier_long"
short_id = "chandelier_short"
symbol = "BINANCE:ETHUSDT"
timeframe = "D"Parameters
| Parameter | Description |
|---|---|
long_idString Required | Identifier for the series representing the long-position exit level. |
short_idString Required | Identifier for the series representing the short-position exit level. |
lengthInteger Optional | Number of candles used to find the high for the long level and the low for the short level; must be between 1 and 10000.If length is omitted, the default value is 22.Usage: • Fixed: length = value• Grid search: – length.start = min_value– length.stop = max_value– length.step = value (optional, default 1) |
atr_lengthInteger Optional | Number of candles used to calculate ATR; must be between 1 and 10000.If atr_length is omitted, the default value is 22.Usage: • Fixed: atr_length = value• Grid search: – atr_length.start = min_value– atr_length.stop = max_value– atr_length.step = value (optional, default 1) |
multiplierDecimal Optional | Multiplier applied to ATR to offset the long and short levels from the recent extremes; must be strictly greater than 0.If multiplier is omitted, the default value is 3.0.Usage: • Fixed: multiplier = value• Grid search: – multiplier.start = min_value, with min_value > 0– multiplier.stop = max_value– multiplier.step = value (optional, default 1) |
symbolString or Array Optional | Market symbol(s) from which this block reads its candles (high, low, and close). If symbol is omitted, the block uses the primary symbol defined in [backtest]. For symbol formats, arrays, and alignment rules, see Exchanges, Symbols and Timeframes. |
timeframeString or Array Optional | Timeframe on which this indicator is calculated. If timeframe is omitted, the calculation uses the grid’s primary timeframe defined in [backtest].For accepted formats and timeframe alignment rules, see Exchanges, Symbols and Timeframes. |
The source key is not accepted in [[chandelier]]. The indicator always uses the high, low, and close price series from the selected market and timeframe.
Available variables
The identifiers below are available directly in expressions. The Chandelier Exit block exposes its two price series and, as read-only values on each identifier, its parameters, input sources, symbol, and timeframe.
Assume the block is configured as follows:
[[chandelier]]
long_id = "chandelier_long"
short_id = "chandelier_short"Then:
| Variable | Description |
|---|---|
chandelier_long orchandelier_long[0]Decimal | Current long exit level. |
chandelier_long[n]Decimal | Long exit level from n candles ago. |
chandelier_short orchandelier_short[0]Decimal | Current short exit level. |
chandelier_short[n]Decimal | Short exit level from n candles ago. |
chandelier_long.lengthchandelier_short.lengthDecimal | Window used to find recent extremes, exposed on each output. |
chandelier_long.atr_lengthchandelier_short.atr_lengthDecimal | ATR calculation length, exposed on each output. |
chandelier_long.multiplierchandelier_short.multiplierDecimal | ATR multiplier, exposed on each output. |
chandelier_long.high_sourcechandelier_long.low_sourcechandelier_long.close_sourcechandelier_short.high_sourcechandelier_short.low_sourcechandelier_short.close_sourceString | Names of the high, low, and close input series used by each output. |
chandelier_long.symbolchandelier_short.symbolString | Market symbol used by each output. |
chandelier_long.timeframechandelier_short.timeframeString | Timeframe used by each output. |
Notes
- Numeric variables support arithmetic, comparisons, and logical operators.
- Text variables are strings intended for equality and inequality checks.