Keltner channel breakout strategy

On GC futures, the Keltner channel breakout lost $99,016 after costs and ran a $100,000 account down to its margin on October 18, 2024. The run stops there.

BreakoutIntraday5-minute barsBacktested Nov 6, 2026

Keltner channel breakout backtest, the result

Contract

Gold

  • −$99K

    Net after costs

    After $82,336 in fees and slippage

  • 2 of 9

    Years that made money

    January 2016 to October 2024

  • −$99.6K

    Largest drawdown

    Peak to trough, 1 contract

  • −$29

    Average trade

    3,419 trades

Keltner channel breakout on GC, net after costs by month, from January 2016 to October 2024: −$99,016; buying and holding one GC contract: +$221,560

Net after costs by month, January 2016 to October 2024.

Keltner channel breakout rules

Draw a channel 2 ATRs either side of a 20-bar EMA, trade the first close outside it, and exit back at the EMA.

A drawing of the rules on a made-up day, not a result.

  1. The middle line is the 20-bar EMA of the five-minute close and the channel lies 2 ATR(10) either side, the ATR being Wilder's average of the true range, on every close of the Globex session.
  2. A close above the upper line buys and a close below the lower line sells short, on bars that close in the day session before its exit minute.
  3. The position is closed when a one-second close comes back to the EMA, or at the exit minute: 13:30 New York on GC (day session 8:20-13:30), 15:45 on NQ (9:30-16:00).
Decides on
5-minute bars
Holds
Nothing overnight
Parameters
bands 2, warmup 20, open minute 570, exit minute 945, bar minutes 5

Results by year

It made money in 2 of 9 years on GC. Its best year was 2020, +$6,316, and its worst 2022, −$19,130. The account was closed out on October 18, 2024, so the years stop there.

Net after costs by year on GC, with trades, win rate, largest drawdown and buying and holding the same contract
YearNetTradesWin rateDrawdownBuy and hold
2016−$15,29341431%−$17,637+$6,888
2017−$14,33036928%−$15,998+$13,120
2018−$8,27538532%−$9,084−$5,270
2019−$2,08537032%−$9,462+$19,820
2020+$6,31637034%−$15,947+$30,139
2021−$6,38037237%−$12,497−$8,111
2022−$19,13038931%−$31,242−$4,541
2023+$9641433%−$14,529+$13,369
2024, Jan to Oct−$39,93533628%−$44,541+$43,279

Keltner channel breakout backtest results

On GC it lost $16,680 before costs, then paid $82,336 in fees and slippage.

Net = before costs − fees − slippage
GC: −$16,680 − $13,956 − $68,380 = −$99,016
Every figure of the Keltner channel breakout backtest, by contract
FigureGCNQ
Net after costs−$99,016+$51,977
Before costs−$16,680+$176,550
Fees$13,956$18,738
Slippage$68,380$105,835
Trades3,4195,285
Trades a year402503
Win rate32%36%
Profit factor0.841.03
Average trade−$29$10
Average trade, 95% interval−$46 to −$12−$23 to $45
Sharpe ratio-1.080.17
Largest drawdown−$99,634−$93,122
Time in the market5%6%
Buying and holding the contract+$221,560+$401,004

The whole interval is under zero: after costs, the average trade lost money.

Keltner channel breakout code and Pine Script

The strategy as the backtest ran it, and the Pine Script our compiler wrote from it for TradingView.

Keltner channel breakout
keltner_channel_breakout.py
1from atlantive import BUY, EMA, NEW_YORK, SELL, Bars, Session, Strategy2 3 4class KeltnerChannelBreakout(Strategy):5    """Keltner channel breakout, EMA(20) +/- 2 ATR(10), on five-minute bars, traded in the day session.6 7    The middle line is the 20-bar EMA of the five-minute close (alpha 2 / 21) and the channel lies8    2 ATR(10) either side, the ATR being Wilder's average of the true range (alpha 1 / 10), on every9    close of the Globex session. A close above the upper line buys and a close below the lower line10    sells short, on bars that close in the day session before its exit minute. The position is11    closed when a one-second close comes back to the EMA (as of the last five-minute close), or at12    the exit minute: 8:20 to 13:30 New York on gold, 9:30 to 15:45 on the Nasdaq-100. Nothing is13    read before 20 bars have closed on the contract. The clock is one-second bars; the five-minute14    bars are built from them, by their start time.15    """16 17    data = "bars"18 19    class Params:20        bands: float = 2.021        warmup: int = 2022        open_minute: int = 57023        exit_minute: int = 94524        bar_minutes: int = 525        clip: int = 126 27    class State:28        clock: Session(zone=NEW_YORK)29        bars: Bars(interval_ns=1_000_000_000)30        middle: EMA(alpha=0.09523809523809523)31        atr: EMA(alpha=0.1)32        mid: float33        prev_close: float34        seen: int35        bar_key: int36        bar_minute: int37        bar_high: float38        bar_low: float39        bar_close: float40 41    def on_event(self, view, ev, orders):42        self.clock.update(ev)43        if not self.bars.update(ev):44            return45        minute = self.clock.prev_minute46        second = self.clock.prev_second47        day = self.clock.prev_day48        high = float(self.bars.prev_high)49        low = float(self.bars.prev_low)50        close = float(self.bars.prev_close)51        key = (day * 1440 + minute) // 552        if key != self.bar_key:53            if self.bar_key != 0:54                tr = self.bar_high - self.bar_low55                if self.seen > 0:56                    tr = max(tr, abs(self.bar_high - self.prev_close), abs(self.bar_low - self.prev_close))57                self.middle.update(self.bar_close)58                self.atr.update(tr)59                self.prev_close = self.bar_close60                self.seen += 161                self.mid = self.middle.value62                if self.seen >= self.p.warmup:63                    width = self.p.bands * self.atr.value64                    ends = self.bar_minute + self.p.bar_minutes65                    in_day = self.bar_minute >= self.p.open_minute and ends < self.p.exit_minute66                    if in_day and view.position == 0:67                        if self.bar_close > self.mid + width:68                            orders.ioc(side=BUY, qty=self.p.clip)69                        elif self.bar_close < self.mid - width:70                            orders.ioc(side=SELL, qty=self.p.clip)71            self.bar_key = key72            self.bar_minute = minute - minute % 573            self.bar_high = high74            self.bar_low = low75        else:76            self.bar_high = max(self.bar_high, high)77            self.bar_low = min(self.bar_low, low)78        self.bar_close = close79        late = second + 1 >= self.p.exit_minute * 60 or minute < self.p.open_minute80        if view.position > 0:81            if close <= self.mid or late:82                orders.ioc(side=SELL, qty=abs(view.position))83        elif view.position < 0:84            if close >= self.mid or late:85                orders.ioc(side=BUY, qty=abs(view.position))
1//@version=62// KeltnerChannelBreakout, exported from Atlantive.3// Chart simulation: decisions use completed bars; market orders fill at the next bar open.4// Native fills, fees, data gaps and session boundaries can differ. Re-test on the target symbol.5// Use standard time-based candles and the strategy's timeframe, not synthetic chart prices.6// Pine v6 trims old trade records at its order limit; the strategy keeps calculating.7// Margin is explicitly disabled to retain the native signal simulation's sizing.8strategy("KeltnerChannelBreakout", overlay=true, initial_capital=100000.0, commission_type=strategy.commission.cash_per_contract, commission_value=1.96, default_qty_type=strategy.fixed, default_qty_value=1, calc_on_every_tick=false, process_orders_on_close=false, slippage=0, margin_long=0, margin_short=0)9 10if timeframe.in_seconds() != 111    runtime.error("KeltnerChannelBreakout was exported for the 1 second timeframe; set the chart to 1S.")12 13bands = input.float(2.0, "bands")14warmup = input.int(20, "warmup", minval=-9007199254740991, maxval=9007199254740991)15open_minute = input.int(500, "open_minute", minval=-9007199254740991, maxval=9007199254740991)16exit_minute = input.int(810, "exit_minute", minval=-9007199254740991, maxval=9007199254740991)17bar_minutes = input.int(5, "bar_minutes", minval=-9007199254740991, maxval=9007199254740991)18clip = input.int(1, "clip", minval=-9007199254740991, maxval=9007199254740991)19 20_q_safe_int(x) =>21    if math.abs(x) > 900719925474099122        runtime.error("an integer left the exact chart range; this run cannot be compared faithfully")23    int(x)24_q_int(x) => _q_safe_int(x < 0 ? math.ceil(x) : math.floor(x))25_q_iadd(a, b) => _q_safe_int(a + b)26_q_isub(a, b) => _q_safe_int(a - b)27_q_imul(a, b) =>28    if a != 0 and math.abs(b) > 9007199254740991 / math.abs(a)29        runtime.error("an integer multiplication left the exact chart range; this run cannot be compared faithfully")30    _q_safe_int(a * b)31_q_ifloordiv(a, b) =>32    _q_r = a % b33    _q_q = (a - _q_r) / b34    _q_safe_int(_q_r != 0 and ((_q_r < 0) != (b < 0)) ? _q_q - 1 : _q_q)35_q_imod(a, b) => _q_safe_int(a - b * _q_ifloordiv(a, b))36 37_q_high = _q_int(math.round(high * 1000000000.0))38_q_low = _q_int(math.round(low * 1000000000.0))39_q_close = _q_int(math.round(close * 1000000000.0))40 41var float mid = 0.042var float prev_close = 0.043var int seen = 044var int bar_key = 045var int bar_minute = 046var float bar_high = 0.047var float bar_low = 0.048var float bar_close = 0.049// clock: completed chart bar's opening timestamp (America/New_York).50_q_clock_prev_minute = hour(time, "America/New_York") * 60 + minute(time, "America/New_York")51_q_clock_prev_second = _q_clock_prev_minute * 60 + second(time, "America/New_York")52_q_clock_prev_weekday = (dayofweek(time, "America/New_York") + 5) % 753_q_clock_prev_day = int(timestamp("UTC", year(time, "America/New_York"), month(time, "America/New_York"), dayofmonth(time, "America/New_York"), 0, 0) / 86400000)54// Current clock: this chart bar's scheduled close, known without a future bar.55// A native next event after a data gap can carry a later time.56_q_clock_minute = hour(time_close, "America/New_York") * 60 + minute(time_close, "America/New_York")57_q_clock_second = _q_clock_minute * 60 + second(time_close, "America/New_York")58_q_clock_weekday = (dayofweek(time_close, "America/New_York") + 5) % 759_q_clock_day = int(timestamp("UTC", year(time_close, "America/New_York"), month(time_close, "America/New_York"), dayofmonth(time_close, "America/New_York"), 0, 0) / 86400000)60_q_clock_seen = 161var float _q_middle_value = 0.062var bool _q_middle_seeded = false63var int _q_middle_skipped = 064var int _q_middle_frozen = 065var float _q_atr_value = 0.066var bool _q_atr_seeded = false67var int _q_atr_skipped = 068var int _q_atr_frozen = 069int minute_l = na70int second_l = na71int day = na72float high_l = na73float low_l = na74float close_l = na75int key = na76float tr = na77float width = na78int ends = na79bool in_day = false80bool late = false81 82minute_l := _q_int(_q_clock_prev_minute)83second_l := _q_int(_q_clock_prev_second)84day := _q_int(_q_clock_prev_day)85high_l := _q_high * 1.086low_l := _q_low * 1.087close_l := _q_close * 1.088key := _q_int(_q_ifloordiv(_q_iadd(_q_imul(day, 1440), minute_l), 5))89if key != bar_key90    if bar_key != 091        tr := bar_high - bar_low92        if seen > 093            tr := math.max(tr, math.max(math.abs(bar_high - prev_close), math.abs(bar_low - prev_close)))94        _q_sample1 = bar_close95        if na(_q_sample1) or math.abs(_q_sample1) > 1.7976931348623157e30896            _q_middle_skipped := _q_middle_skipped + 197        else98            if not _q_middle_seeded99                _q_middle_value := _q_sample1100                _q_middle_seeded := true101            else102                _q_moved2 = _q_middle_value + 0.09523809523809523 * (_q_sample1 - _q_middle_value)103                if _q_moved2 == _q_middle_value and _q_sample1 != _q_middle_value104                    _q_middle_frozen := _q_middle_frozen + 1105                _q_middle_value := _q_moved2106        _q_sample3 = tr107        if na(_q_sample3) or math.abs(_q_sample3) > 1.7976931348623157e308108            _q_atr_skipped := _q_atr_skipped + 1109        else110            if not _q_atr_seeded111                _q_atr_value := _q_sample3112                _q_atr_seeded := true113            else114                _q_moved4 = _q_atr_value + 0.1 * (_q_sample3 - _q_atr_value)115                if _q_moved4 == _q_atr_value and _q_sample3 != _q_atr_value116                    _q_atr_frozen := _q_atr_frozen + 1117                _q_atr_value := _q_moved4118        prev_close := bar_close119        seen := _q_int(_q_iadd(seen, 1))120        mid := _q_middle_value121        if seen >= warmup122            width := bands * _q_atr_value123            ends := _q_int(_q_iadd(bar_minute, bar_minutes))124            in_day := bar_minute >= open_minute and ends < exit_minute125            if in_day and _q_int(strategy.position_size) == 0126                if bar_close > mid + width127                    _q_qty5 = _q_int(clip)128                    if _q_qty5 <= 0129                        runtime.error("market order quantity must be a positive whole unit")130                    _q_pos5 = _q_int(strategy.position_size)131                    if _q_pos5 > 0 or _q_pos5 < 0 and _q_qty5 < -_q_pos5132                        runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")133                    strategy.order("q1", strategy.long, _q_qty5)134                else if bar_close < mid - width135                    _q_qty6 = _q_int(clip)136                    if _q_qty6 <= 0137                        runtime.error("market order quantity must be a positive whole unit")138                    _q_pos6 = _q_int(strategy.position_size)139                    if _q_pos6 < 0 or _q_pos6 > 0 and _q_qty6 < _q_pos6140                        runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")141                    strategy.order("q2", strategy.short, _q_qty6)142    bar_key := _q_int(key)143    bar_minute := _q_int(_q_isub(minute_l, _q_imod(minute_l, 5)))144    bar_high := high_l145    bar_low := low_l146else147    bar_high := math.max(bar_high, high_l)148    bar_low := math.min(bar_low, low_l)149bar_close := close_l150late := _q_iadd(second_l, 1) >= _q_imul(exit_minute, 60) or minute_l < open_minute151if _q_int(strategy.position_size) > 0152    if close_l <= mid or late153        _q_qty7 = _q_int(math.abs(_q_int(strategy.position_size)))154        if _q_qty7 <= 0155            runtime.error("market order quantity must be a positive whole unit")156        _q_pos7 = _q_int(strategy.position_size)157        if _q_pos7 < 0 or _q_pos7 > 0 and _q_qty7 < _q_pos7158            runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")159        strategy.order("q3", strategy.short, _q_qty7)160else if _q_int(strategy.position_size) < 0161    if close_l >= mid or late162        _q_qty8 = _q_int(math.abs(_q_int(strategy.position_size)))163        if _q_qty8 <= 0164            runtime.error("market order quantity must be a positive whole unit")165        _q_pos8 = _q_int(strategy.position_size)166        if _q_pos8 > 0 or _q_pos8 < 0 and _q_qty8 < -_q_pos8167            runtime.error("this order would add to or partially reduce a position, so its trade ledger would not be faithful")168        strategy.order("q4", strategy.long, _q_qty8)

How it was tested

The published rules, never tuned on the data, with real costs on every fill. Every strategy here is tested the same way.

Market data
CME Globex 5-minute bars, Jan 2, 2016 to Jul 31, 2026
Rules
As published, with the published parameters, never tuned on this data
Size
1 contract on every trade
Contract
The most traded one, rolled as the market moved
Fees
The broker's $0.50 a side, plus CME's and the NFA's fees when the window opens
Slippage
1 tick a side on ES, 2 in NQ's regular session and 3 outside it, 1 on other markets, where it was not measured
Stops and entries
Tested on 1-second closes and filled at the next bar
Contracts traded
GC: 54 contracts, GCG6 to GCQ6NQ: 43 contracts, NQH6 to NQU6
Costs paid
GC: $13,956 in fees, $68,380 in slippageNQ: $18,738 in fees, $105,835 in slippage
Warm-up
None: each contract reads only its own bars
Flagged days
GC: NoneNQ: None Days the data holds too few bars for. Flagged, not removed.

Could you pass
a prop firm challenge
with the Keltner channel breakout?

A backtest says whether a strategy makes money. Our AI runs its trades through the rules of every prop firm account, then tells you which one it would pass and at what size.

No card needed. Free credits every month.

  • Most money: Blue Guardian Futures Direct 50K, $5,084
  • Best payout odds: Funded Futures Family Straight to Funded 50K, 98%
  • Fastest pass: Phidias Express to Live 50K, 11 days
Blue Guardian Futures Direct 50K
Most money

$5,084

Median net across 2,000 simulated runs

Evaluation
None
First payout
97%
Fees paid
$1,521

Median net across 2,000 simulated runs

Best 5%$13,143Worst 5%−$412
Day 060120180
Example: ES opening range breakout

Questions about the Keltner channel breakout

What is the Keltner channel breakout?

Draw a channel 2 ATRs either side of a 20-bar EMA, trade the first close outside it, and exit back at the EMA. The rules follow Chester W. Keltner (the channel); the EMA and ATR version is credited to Linda Bradford Raschke, How to Make Money in Commodities (1960). Atlantive backtested it on CME futures from January 2016 to July 2026 after costs.

Is the Keltner channel breakout profitable on GC futures?

Not in this backtest: on GC futures from January 2016 to October 2024 it lost $99,016 after costs, over 3,419 trades, positive in 2 of 9 years; on NQ it made $51,977. Buying and holding one GC contract over the same window made $221,560. The average trade was −$29, its 95% interval −$46 to −$12. These are hypothetical results of a backtest, not of trading.

What are the Keltner channel breakout's rules?

The middle line is the 20-bar EMA of the five-minute close and the channel lies 2 ATR(10) either side, the ATR being Wilder's average of the true range, on every close of the Globex session. A close above the upper line buys and a close below the lower line sells short, on bars that close in the day session before its exit minute. The position is closed when a one-second close comes back to the EMA, or at the exit minute: 13:30 New York on GC (day session 8:20-13:30), 15:45 on NQ (9:30-16:00). The rules follow Chester W. Keltner (the channel); the EMA and ATR version is credited to Linda Bradford Raschke, How to Make Money in Commodities (1960). Its parameters are the published ones, never tuned on the data it was tested on.

How was the Keltner channel breakout backtested?

On CME Globex data from January 2016 to July 2026, one contract, on 5-minute bars, rolled to the most traded contract as the market moved, with the broker's and CME's fees and the slippage measured on each market. Stops and entries were tested on 1-second closes and filled at the next bar. Nothing was fitted to the data.

Can I run the Keltner channel breakout in TradingView?

Yes. The page carries its Pine Script, written by Atlantive's compiler from the same code the backtest ran, for TradingView's strategy tester. A chart's fills and fees can differ from the backtest's, so test it again on the symbol you trade.

Can I change the Keltner channel breakout and test it again?

Yes. Rerun it in Atlantive: a new chat opens with the strategy's rules in the box, for you to read, change and send. The agent writes the code, backtests it on the market and window you name, and reports the result with its costs.

Rerun it in Atlantive. Change the market, the dates or a rule, then send it.

A new chat opens with this in the box

Backtest a Keltner channel breakout, EMA(20) +/- 2 ATR(10), on five-minute bars on GC, 2016-01-02 to 2026-07-31, one contract on a $100,000 account with default costs: enter on a five-minute close outside the channel in the day session, exit at the EMA on one-second closes or at the session's exit.

Never sent for you

May we measure this visit?

With your consent, Google Analytics and PostHog count visits to these pages. You can separately allow Google Ads to measure visits from our ads. Visit measurement starts only after you choose. Cookie policy