Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Keltner Breakout Strategy

A Pine Script v5 strategy built on EMA (close, 20), ATR (10) and Crossover (close, upper). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss. Each trade commits 10% of equity and pays 0.05% commission. 3 settings; defaults include EMA length 20, ATR length 10 and ATR multiplier 1.5.

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 Keltner Breakout Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
How did Keltner Breakout Strategy do on BTCUSDT 1D with default settings?
+3.54%
From 26 Jan 2024 to 21 Oct 2026, over 21 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
What alerts does Keltner Breakout Strategy have?
1
Breakout.
Does Keltner Breakout 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: 21 before, 21 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 Keltner Breakout Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 22.

BTCUSDT · 1D · default settings

  • Basis
  • Upper
  • Lower
  • 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 (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$10,354$20,253Equity from $10,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
+3.54%
$353.85
Buy and hold
+102.5%
same period
Closed trades
21
6 won · 15 lost
Profitable
28.6%
of closed trades
Profit factor
1.81
gross profit ÷ gross loss
Max drawdown
2.33%
−$243.63

One run with the author's default settings, $10,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.

Nothing to point out.

Settings

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

SettingDefaultType and rangeFeeds
EMA length20int · min 1basis
ATR length10int · min 1atr
ATR multiplier1.5float · min 0.1 · step 0.1upper lower

What it calculates

  • EMAclose, EMA length (20)basis · line 12
  • ATRATR length (10)atr · line 13
  • Crossoverclose, upperbreakout · line 17

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.

closecloseprice datalengthEMA lengthsetting · 20high · low · closehigh · low · closeprice dataatrLenATR lengthsetting · 10multATR multipliersetting · 1.5basisEMA→ basisatrATR→ atrbreakoutCrossover→ breakoutupper, lowerupper · lower2 valuesentry:LongOpen Longstrategy.entryexit:Trailexit Trailstrategy.exitplot:24Basisplotplot:25Upperplotplot:26Lowerplotfill:ChannelChannelfillalertcondition:29Breakoutalertcondition

Order rules

OrderFires whenBy defaultLine
Open Long longbreakoutOn20
Exit Trail stopstrategy.position_size > 0On22

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

Alerts

AlertCallMessageLine
BreakoutalertconditionClose crossed above the upper Keltner channel29

Does it repaint?

No

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

7/7trades 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 timingOrders fill at the next bar's open, after the signal bar has closed.

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+3.5%+102.5%2129%1.812.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.4%+5.5%1323%2.060.5%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.3%+9.8%1839%1.204.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+1.9%+8.4%1233%3.250.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+2.3%+16.7%2040%1.364.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+1.9%+21.5%1547%2.230.8%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.5%+148.3%2138%0.923.9%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.4%+17.1%1735%2.300.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 market838%$354.28
Sideways market1118%$30.34
Falling market250%−$30.78

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

How bad could the drawdown be?

3.1%

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

0%4%
All 21 trades
SideEntryExitBarsP&L
long25 Feb 2024 51,568.2016 Mar 2024 65,282.6020$264.68
long21 May 2024 71,446.6031 May 2024 67,211.7010−$61.81
long16 Jul 2024 64,724.1025 Jul 2024 63,748.809−$16.38
long20 Sep 2024 62,948.001 Oct 2024 62,700.1011−$5.03
long15 Oct 2024 66,084.0023 Oct 2024 65,474.308−$10.40
long29 Oct 2024 69,962.203 Nov 2024 68,184.205−$26.84
long7 Nov 2024 75,572.005 Dec 2024 93,355.5028$237.46
long16 Dec 2024 104,464.0019 Dec 2024 99,620.603−$49.12
long18 Jan 2025 104,077.0027 Jan 2025 101,266.009−$28.92
long23 Apr 2025 93,443.0029 May 2025 105,508.0036$131.88
long10 Jun 2025 110,263.0012 Jun 2025 106,231.002−$39.16
long11 Jul 2025 116,010.0025 Jul 2025 115,956.0014−$1.52
long14 Aug 2025 123,306.0015 Aug 2025 117,531.001−$49.68
long2 Oct 2025 118,595.0010 Oct 2025 118,503.008−$1.83
long6 Jan 2026 93,859.708 Jan 2026 90,004.802−$43.47
long14 Jan 2026 95,414.0019 Jan 2026 92,579.905−$31.59
long17 Mar 2026 74,884.7018 Mar 2026 70,530.801−$60.67
long14 Apr 2026 74,418.0029 Apr 2026 75,419.1015$12.70
long5 May 2026 79,861.0013 May 2026 79,043.908−$11.47
long20 Aug 2026 69,334.8010 Sep 2026 77,042.4021$112.35
long19 Sep 2026 80,883.907 Oct 2026 83,527.7018$32.67

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
Keltner Breakout Strategy this page—v5 strategy+3.5%212.3%
Trend Reversal - Potential pressure by BardiaB2atr emav4 strategy+133,960.0%51,504.8%
Simple Ema_ATR Strategy HulkTrading by TheHulkTradingema atrv4 strategy+2.2%1415.6%
[EKIN] ATR Exit Strategy by ekinbasarkomurema atrv5 strategy+781.7%302,960.8%
DEMA-EMA & VOLATILITY (VAMS) by Qorbanjfema atrv4 strategy+2,833,450.0%1915,721.0%
Super Z strategy - Thanks to Rafael Zioni by 03.freemanema atrv4 strategy−404,823.0%562,951,790.0%

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.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

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: 21 before, 21 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.

⋯// © Zeal Terminal-//@version=5+//@version=6strategy("Keltner Breakout Strategy", shorttitle = "Keltner Breakout", overlay = true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, commission_type = strategy.commission.percent, commission_value = 0.05, slippage = 1)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 10 msYes 1,000 bars in 26 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

Written by Zeal Terminal and published under the Mozilla Public License 2.0.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Zeal Terminal//@version=5strategy("Keltner Breakout Strategy", shorttitle = "Keltner Breakout", overlay = true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, commission_type = strategy.commission.percent, commission_value = 0.05, slippage = 1) // Not investment advice. Buys a close above the upper Keltner channel and// trails a stop at the channel basis.length = input.int(20, "EMA length", minval = 1)atrLen = input.int(10, "ATR length", minval = 1)mult   = input.float(1.5, "ATR multiplier", minval = 0.1, step = 0.1) basis = ta.ema(close, length)atr   = ta.atr(atrLen)upper = basis + mult * atrlower = basis - mult * atr breakout = ta.crossover(close, upper) if breakout    strategy.entry("Long", strategy.long)if strategy.position_size > 0    strategy.exit("Trail", "Long", stop = basis) plot(basis, "Basis", color = #ffb74d)u = plot(upper, "Upper", color = #26a69a)l = plot(lower, "Lower", color = #ef5350)fill(u, l, color = color.new(#42a5f5, 94), title = "Channel") alertcondition(breakout, "Breakout", "Close crossed above the upper Keltner channel")