Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Chandelier Exit ZLSMA Strategy

A Pine Script v5 strategy built on ATR (1), Highest (haClose, 1) and Lowest (haClose, 1). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10% of equity and pays 0.075 commission. 8 settings; defaults include ATR Period 1, ATR Multiplier 2 and ZLSMA Length 50.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Chandelier Exit ZLSMA Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
How did Chandelier Exit ZLSMA Strategy do on BTCUSDT 1D with default settings?
+2.38%
From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Chandelier Exit ZLSMA Strategy run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 8 before, 12 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Chandelier Exit ZLSMA Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Chandelier Exit ZLSMA Strategy run in Zeal Terminal?
Yes
It compiles in 45 ms and runs 1,000 bars in 67 ms, in the browser.

BTCUSDT · 1D · default settings

  • ZLSMA
  • LONG
  • SHORT
  • LONG EXIT
  • SHORT EXIT
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (8)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,024$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
+2.38%
$23.79
Buy and hold
+102.5%
same period
Closed trades
8
4 won · 4 lost
Profitable
50.0%
of closed trades
Profit factor
1.98
gross profit ÷ gross loss
Max drawdown
2.15%
−$21.94

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
ATR Period1intatr longStop shortStop
ATR Multiplier2float · step 0.1atr
Show Buy/Sell Labels ?Created by Chandelier Exit (CE)falseboolBuy Label Sell Label
Show Signal Labels ?trueboolLONG SHORT LONG EXIT SHORT EXIT
Use Close Price for Extrema ?trueboollongStop shortStop
Enable Rising/Decreasing HighlightningfalseboolzColor
ZLSMA Length50intlsma lsma2
Offset0intlsma lsma2

What it calculates

  • ATRATR Period (1)atr · line 27
  • HighesthaClose, ATR Period (1)longStop · line 28
  • LowesthaClose, ATR Period (1)shortStop · line 31
  • LinreghaClose, ZLSMA Length (50), Offset (0)lsma · line 42
  • Linreglsma, ZLSMA Length (50), Offset (0)lsma2 · line 43
  • CrossunderhaClose, zlsmaexitLong · line 52
  • CrossoverhaClose, zlsmaexitShort · line 54

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

high · low · closehigh · low · closeprice datamultATR Multipliersetting · 2lengthATR Periodsetting · 1zlsmaLengthZLSMA Lengthsetting · 50offsetOffsetsetting · 0closecloseprice datalowlowprice datahighhighprice dataopenopenprice dataatrATR→ atrlongStopHighest→ longStopshortStopLowest→ shortStoplsmaLinreg→ lsmalsma2Linreg→ lsma2exitLongCrossunder→ exitLongexitShortCrossover→ exitShorthaClosehaClosevaluelongStopPrevlongStopPrevvalueshortStopPrevshortStopPrevvaluedirdirvalueeqeqvaluezlsmazlsmavaluezColorzColorvalueenterLongenterLongconditionenterShortenterShortconditionbuySignal, sellSignal, changeCondbuySignal · sellSignal …3 conditionsmaximumYellowRed, rajah, magicMint, languidLavender, maximumBluePurple, skyBlue, lightGray, quickSilver, mediumAquamarine, carrotOrangeColourmaximumYellowRed · rajah +8close:longClose longstrategy.closeclose:shortClose shortstrategy.closeentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryplotshape:37Buy Labelplotshapeplotshape:39Sell Labelplotshapeplot:47ZLSMAplotplotshape:96LONGplotshapeplotshape:97SHORTplotshapeplotshape:98LONG EXITplotshapeplotshape:99SHORT EXITplotshapebarcolor:100barcolorbarcolor

Order rules

OrderFires whenBy defaultLine
Close long(exitLong and strategy.position_size > 0)On103
Close short(exitShort and strategy.position_size < 0)On106
Open long long(enterLong)On109
Open short short(enterShort)On112

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

2/2trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingprocess_orders_on_close = true: orders fill at the signal bar's close.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+2.4%+102.5%850%1.982.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.7%+5.5%922%0.331.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.4%+9.8%1457%1.284.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−1.7%+8.4%1331%0.302.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+2.4%+16.7%367%2.711.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+2.0%+21.5%6100%—0.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.3%+148.3%850%0.802.8%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.3%+17.1%944%1.820.5%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1100%$21.39
Sideways market540%−$9.00
Falling market250%$11.40

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

2.4%

The 95th percentile of the worst drawdown when the same 8 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.0% to 2.4%; the tick is what actually happened, 1.8%. Order luck alone moves it this much.

0%3%
All 8 trades
SideEntryExitBarsP&L
long29 Oct 2024 72,736.403 Nov 2024 68,776.005−$5.59
long7 Nov 2024 75,857.9019 Nov 2024 92,310.8012$21.39
long22 Apr 2025 93,443.001 May 2025 96,489.909$3.16
long11 Aug 2025 118,686.0020 Aug 2025 114,271.009−$3.94
short21 Aug 2025 112,500.0022 Aug 2025 116,936.001−$4.15
short16 Dec 2025 87,863.4014 Jan 2026 96,951.8029−$10.61
short20 Jan 2026 88,427.7010 Feb 2026 68,841.3021$22.01
long3 May 2026 78,568.604 May 2026 79,861.001$1.53

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Chandelier Exit ZLSMA Strategy this page—v5 strategy+2.4%82.2%
Aggresive Scalper-Swing Crypto Strategy by exlux99lowest highest atrv4 strategy−7.4%316.0%
Donchian Channels Strategy by KrisWaters by kriswatershighest lowest atrv4 strategy+55.8%2123.3%
Chandelier Exit - Strategy by melihtunaatr highest lowestv4 strategy−34.8%1143.2%
ETF trader by FX_mindsatr lowest highestv4 strategy+78.3%1732.7%
Chandelier Exit by Zeal Terminalatr highest lowestv5 indicatorindicator

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 7 settings use the untyped input() (line 17, 19, 20, 21, 22, 23, 24). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 17: input() → input.int()
  • Line 19: input() → input.bool()
  • Line 20: input() → input.bool()
  • Line 21: input() → input.bool()
  • Line 22: input() → input.bool()
  • Line 23: input() → input.int()
  • Line 24: input() → input.int()
⋯// -- Inputs ---length = input(title='ATR Period', defval=1)+length = input.int(title='ATR Period', defval=1)mult = input.float(title='ATR Multiplier', step=0.1, defval=2)-showLabels = input(title='Show Buy/Sell Labels ?', tooltip='Created by Chandelier Exit (CE)', defval=false)+showLabels = input.bool(title='Show Buy/Sell Labels ?', tooltip='Created by Chandelier Exit (CE)', defval=false)-isSignalLabelEnabled = input(title='Show Signal Labels ?', defval=true)+isSignalLabelEnabled = input.bool(title='Show Signal Labels ?', defval=true)-useClose = input(title='Use Close Price for Extrema ?', defval=true)+useClose = input.bool(title='Use Close Price for Extrema ?', defval=true)-zcolorchange = input(title='Enable Rising/Decreasing Highlightning', defval=false)+zcolorchange = input.bool(title='Enable Rising/Decreasing Highlightning', defval=false)-zlsmaLength = input(title='ZLSMA Length', defval=50)+zlsmaLength = input.int(title='ZLSMA Length', defval=50)-offset = input(title='Offset', defval=0)+offset = input.int(title='Offset', defval=0)// -- CE - Credits to @everget --⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 8 before, 12 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 45 msYes 1,000 bars in 67 msNot measured
PineTSNot testedNot testedNot measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © simwaistrategy('Chandelier Exit ZLSMA Strategy', shorttitle='CE_ZLSMA', overlay = true, initial_capital = 1000, default_qty_value = 10, default_qty_type = strategy.percent_of_equity, calc_on_every_tick = false, process_orders_on_close = true, commission_value = 0.075)// -- Colors --color maximumYellowRed = color.rgb(255, 203, 98) // yellowcolor rajah = color.rgb(242, 166, 84) // orangecolor magicMint = color.rgb(171, 237, 198)color languidLavender = color.rgb(232, 215, 255)color maximumBluePurple = color.rgb(181, 161, 226)color skyBlue = color.rgb(144, 226, 244)color lightGray = color.rgb(214, 214, 214)color quickSilver = color.rgb(163, 163, 163)color mediumAquamarine = color.rgb(104, 223, 153)color carrotOrange = color.rgb(239, 146, 46)// -- Inputs --length = input(title='ATR Period', defval=1)mult = input.float(title='ATR Multiplier', step=0.1, defval=2)showLabels = input(title='Show Buy/Sell Labels ?', tooltip='Created by Chandelier Exit (CE)', defval=false)isSignalLabelEnabled = input(title='Show Signal Labels ?', defval=true)useClose = input(title='Use Close Price for Extrema ?', defval=true)zcolorchange = input(title='Enable Rising/Decreasing Highlightning', defval=false)zlsmaLength = input(title='ZLSMA Length', defval=50)offset = input(title='Offset', defval=0)// -- CE - Credits to @everget --float haClose = float(1) / 4 * (open[1] + high[1] + low[1] + close[1])atr = mult * ta.atr(length)[1]longStop = (useClose ? ta.highest(haClose, length) : ta.highest(haClose, length)) - atrlongStopPrev = nz(longStop[1], longStop)longStop := haClose > longStopPrev ? math.max(longStop, longStopPrev) : longStopshortStop = (useClose ? ta.lowest(haClose, length) : ta.lowest(haClose, length)) + atrshortStopPrev = nz(shortStop[1], shortStop)shortStop := haClose < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStopvar int dir = 1dir := haClose > shortStopPrev ? 1 : haClose < longStopPrev ? -1 : dirbuySignal = dir == 1 and dir[1] == -1plotshape(buySignal and showLabels ? longStop : na, title='Buy Label', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=mediumAquamarine, textcolor=color.white)sellSignal = dir == -1 and dir[1] == 1plotshape(sellSignal and showLabels ? shortStop : na, title='Sell Label', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=carrotOrange, textcolor=color.white)changeCond = dir != dir[1]// -- ZLSMA - Credits to @netweaver2011 --lsma = ta.linreg(haClose, zlsmaLength, offset)lsma2 = ta.linreg(lsma, zlsmaLength, offset)eq = lsma - lsma2zlsma = lsma + eqzColor = zcolorchange ? zlsma > zlsma[1] ? magicMint : rajah : languidLavenderplot(zlsma, title='ZLSMA', linewidth=2, color=zColor)// -- Signals --var string isTradeOpen = ''var string signalCache = ''bool enterLong = buySignal and ta.crossover(haClose, zlsma) bool exitLong = ta.crossunder(haClose, zlsma) bool enterShort = sellSignal and ta.crossunder(haClose, zlsma)bool exitShort = ta.crossover(haClose, zlsma)if (signalCache == 'long entry')    signalCache := ''    enterLong := trueelse if (signalCache == 'short entry')    signalCache := ''    enterShort := trueif (isTradeOpen == '')    if (exitShort and (not enterLong))        exitShort := false    if (exitLong and (not enterShort))        exitLong := false       if (enterLong and exitShort)        isTradeOpen := 'long'        exitShort := false    else if (enterShort and exitLong)        isTradeOpen := 'short'        exitLong := false    else if (enterLong)        isTradeOpen := 'long'    else if (enterShort)        isTradeOpen := 'short'else if (isTradeOpen == 'long')    if (exitShort)        exitShort := false    if (enterLong)        enterLong := false    if (enterShort and exitLong)        enterShort := false        signalCache := 'short entry'    if (exitLong)        isTradeOpen := ''else if (isTradeOpen == 'short')    if (exitLong)        exitLong := false    if (enterShort)        enterShort := false    if (enterLong and exitShort)        enterLong := false        signalCache := 'long entry'    if (exitShort)        isTradeOpen := ''plotshape((isSignalLabelEnabled and enterLong) ? zlsma : na, title='LONG', text='L', style=shape.labelup, color=mediumAquamarine, textcolor=color.white, size=size.tiny, location=location.absolute)plotshape((isSignalLabelEnabled and enterShort) ? zlsma : na, title='SHORT', text='S', style=shape.labeldown, color=carrotOrange, textcolor=color.white, size=size.tiny, location=location.absolute)plotshape((isSignalLabelEnabled and exitLong) ? zlsma : na, title='LONG EXIT', style=shape.circle, color=magicMint, size=size.tiny, location=location.absolute)plotshape((isSignalLabelEnabled and exitShort) ? zlsma : na, title='SHORT EXIT', style=shape.circle, color=rajah, size=size.tiny, location=location.absolute)barcolor(color=isTradeOpen == 'long' ? mediumAquamarine : isTradeOpen == 'short' ? carrotOrange : na)// -- Long Exits --if (exitLong and strategy.position_size > 0)    strategy.close('long', comment='EXIT_LONG')// -- Short Exits --if (exitShort and strategy.position_size < 0)    strategy.close('short', comment='EXIT_SHORT')// -- Long Entries --if (enterLong)    strategy.entry('long', strategy.long, comment='ENTER_LONG')// -- Short Entries --if (enterShort)    strategy.entry('short', strategy.short, comment='ENTER_SHORT')