VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Indicators and signals

Keltner channel: calculation, settings and strategy testing

A Keltner channel is an EMA with bands a multiple of the ATR above and below it, for example a 20-bar EMA with bands 2 times a 10-bar ATR away. Test it as a breakout rule or a mean-reversion rule with a small grid chosen in advance, with costs included and confirmed on unseen data.

By · Published · updated · Editorial policy

Contents
  1. How is the Keltner channel calculated?
  2. Keltner vs Bollinger bands: what is actually different?
  3. Which Keltner channel settings should you test?
  4. How do you test a Keltner breakout strategy?
  5. How do you test Keltner mean-reversion rules?
  6. How many settings can you try before a good result means nothing?
  7. Frequently asked questions
  8. References

A Keltner channel is an exponential moving average (EMA) with bands a multiple of the Average True Range (ATR) above and below it. A common setting is a 20-bar EMA, a 10-bar ATR and a multiplier of 2. Test it as a breakout or mean-reversion rule on a small grid fixed in advance, after costs, on unseen data.

How is the Keltner channel calculated?

The Keltner channel is three lines: an EMA in the middle and two bands a fixed number of ATRs away from it. An exponential moving average (EMA) is a moving average that gives recent bars more weight, so it turns faster than a simple average of the same length. Average True Range (ATR) is the average size of each bar's true range over a set number of bars. True range is the largest of three distances: high minus low, high minus the previous close, and the previous close minus low.

  1. Calculate the EMA of the closing price over n bars. This is the midline.
  2. Calculate the ATR over m bars.
  3. Add and subtract the ATR, multiplied by a factor k, from the midline.

Band = EMA ± k × ATR

Here EMA is the midline value on that bar. ATR is the average bar size on that bar. k is the multiplier you choose, for example 2. The plus sign gives the upper band and the minus sign gives the lower band.

The original version described by Chester Keltner used a simple average of the typical price and the average high-low range. Most charting software today uses the EMA and ATR version. Because true range includes the previous close, a gap between sessions widens the bands on the next bar. On intraday data, your session settings therefore change the channel.

Hypothetical example

An index future has a 20-bar EMA of 18,000 points and a 10-bar ATR of 120 points. With a multiplier of 2, the upper band is 18,000 + 240 = 18,240 and the lower band is 18,000 − 240 = 17,760. The next bar closes at 18,260, above the upper band. A breakout rule would signal on that close and enter at the open of the following bar.

A Keltner channel with an EMA midline and bands two ATRs above and below it. One bar closes above the upper band, which is the signal, and the entry is at the open of the next bar Signal on close, enter next bar EMA with bands at ±2 ATR EMA + 2 × ATR EMA EMA − 2 × ATR Signal Entry A close above the band is the signal. So: enter at the next bar's open.
A Keltner channel: an EMA midline with bands two ATRs above and below. The signal comes on the close, and the entry comes on the next bar.

Keltner vs Bollinger bands: what is actually different?

The real difference is the width: Keltner width follows the size of each bar, while Bollinger bands width follows how far closing prices spread from their average. Both indicators draw bands around an average. Bollinger bands are usually a 20-bar simple moving average with bands two standard deviations of the close away from it. A standard deviation is a measure of how far closing prices typically sit from their average: small when closes cluster, large when they scatter.

Keltner channelBollinger bands
MidlineEMA (usually)Simple moving average (usually)
Width measureATR: average bar size, including gapsStandard deviation of closing prices
Prices usedHigh, low and previous closeClose only
Steady trend with small barsStays narrow, so closes outside the band are commonWidens, because closes drift far from the average
One very large barWidth rises and fades graduallyWidth jumps, then drops when the bar leaves the window

The two can work together. When the Bollinger bands move inside the Keltner channel, closes are tightly grouped compared with the normal bar size. Some traders read this "squeeze" as a quiet period that may come before a larger move. That is a third rule you can test, separate from the two below.

In a smooth uptrend made of small bars, the Bollinger bands widen while the Keltner channel stays narrow, so price closes above the Keltner upper band but stays inside the Bollinger bands Keltner stays narrow in a trend Smooth uptrend, small bars Bollinger Keltner Bollinger Price breaks Keltner, not Bollinger. So: test the rule on both bands.
In a smooth trend with small bars, Bollinger bands widen while the Keltner channel stays narrow. The same price can break one band and not the other.

Which Keltner channel settings should you test?

Test a small grid of EMA length, ATR length and multiplier, and fix that grid before the first run. The multiplier has the most direct effect on how often price reaches a band, and so on how many trades you get. Common defaults are a 20-bar EMA, a 10-bar ATR and a multiplier of 2. The ranges below are common starting points, not recommended values.

SettingWhat it controlsRange many traders testEffect of a larger value
EMA length (n)How fast the midline follows price10 to 50 barsSlower midline and later exits on midline rules
ATR length (m)How fast the band width reacts10 to 20 barsSmoother width that reacts less to a single bar
Multiplier (k)Distance from midline to band1.0 to 3.0Fewer signals, each needing a larger move
Bar sizeWhat one "bar" meansChoose one before testingFewer trades per year

Use coarse steps, such as 0.5 for the multiplier and 10 bars for the EMA. Fine steps add many variants that differ only by noise. Keep the bar size fixed during a search. Changing bar size changes every other setting's meaning, so a new bar size is a new test.

How do you test a Keltner breakout strategy?

A breakout test buys strength and sells weakness. It only works if the market trends often enough to pay for the false breakouts in between. Write the rules completely before testing:

  1. Entry: go long when a bar closes above the upper band. Go short when a bar closes below the lower band.
  2. Execution: enter at the next bar's open. A rule that decides on the close and also fills on that close uses a price you could not have traded.
  3. Exit: choose one exit and keep it fixed. Examples are a close back across the midline, a close beyond the opposite band, or a stop a set number of ATRs from entry.
  4. Sessions: decide whether signals are allowed in every session or only the main session.
  5. Costs: include commission and slippage on every trade. See trading costs in backtests for how to compare them with the average trade.

The usual weak point is a sideways market. Price closes just outside the band, then falls back, again and again. Many breakout systems show many small losses and fewer large wins. Check the longest losing streak and the worst drawdown, not only the net result. Also look at results year by year. A test whose profit comes from one or two strong trend years depends on those years repeating.

How do you test Keltner mean-reversion rules?

A mean-reversion test bets that a close outside the band will return toward the midline. It works in ranges and loses most in strong trends. In a strong trend, price can keep closing near or beyond the band for many bars.

  1. Entry: go long when a bar closes below the lower band. Go short when a bar closes above the upper band. A stricter version waits for the next bar to close back inside the channel.
  2. Target: exit at the midline.
  3. Stop: use a stop a set number of ATRs beyond the entry, or a time stop that exits after a fixed number of bars.
  4. Execution and costs: use the same next-bar fills and cost settings as the breakout test, so the two can be compared.

Never test this rule without a stop. One trend day against an open position can erase many small wins. Compare the worst single trade with the average winning trade. If the worst trade equals twenty average wins, the rule is fragile, even if the win rate looks high.

Hypothetical example

ATR is 20 points and the multiplier is 1.0, so the lower band is 20 points below the midline. A long entry at the band can gain at most about 20 points if price returns to the midline. In practice it often gains less, because the midline moves toward price during the trade. A round-trip cost of 2 points takes about 10% of that best case. With a multiplier of 2.0, the best case is about 40 points and the same cost is about 5%.

The example shows why small multipliers create many trades with thin margins. Mean-reversion results are often more sensitive to the slippage estimate than breakout results. Rerun the test with double slippage before you trust it. The double-slippage rerun is one changed input in the backtesting settings for fees and slippage of AlphaPrime (Valynox), applied the same way to every Keltner candidate.

How many settings can you try before a good result means nothing?

Every extra variant you test raises the chance that the best one is luck. Count your variants, look for a broad region of good settings, and confirm the result on out-of-sample data. Out-of-sample data is price history that the search never used when choosing the settings. Research on backtest overfitting shows that the best of many tested variants usually looks better in the backtest than it does afterwards (Bailey, Borwein, López de Prado and Zhu, 2014). The Sharpe ratio is average return divided by how much returns swing; the deflated Sharpe ratio lowers that score according to how many variants you tried, so a winner picked from many tries must clear a higher bar (Bailey and López de Prado, 2014).

Hypothetical example

Five EMA lengths (10, 20, 30, 40, 50) × five multipliers (1.0, 1.5, 2.0, 2.5, 3.0) × two ATR lengths (10, 20) × two rule types (breakout, mean reversion) = 100 variants. If you then try three bar sizes, you have tested 300 variants. Report the 300, not only the winner.

Plot the net result after costs for every pair of EMA length and multiplier. A good result sits inside a plateau, where neighbouring settings also make money. A single bright cell surrounded by losses is the market's noise that happened to fit one setting.

Two hypothetical heatmaps of net result after costs over EMA length and multiplier: on the left a broad plateau where 9 of 25 settings are profitable, on the right one isolated profitable cell surrounded by losing cells Trust a plateau, not a peak Hypothetical net, EMA × multiplier Plateau Isolated peak 9 / 25 in profit 1 / 25 in profit A lone best cell is often luck. So: pick from the plateau's middle.
Hypothetical heatmaps. A broad plateau of good settings (left) is easier to trust than one isolated best cell (right).

Walk-forward analysis repeats the selection on rolling windows and keeps only the out-of-sample results. It tests the way you choose settings, not one lucky choice. Harvey and Liu (2015) argue for raising the bar a result must clear as the number of tests grows. In AlphaPrime, strategy generation takes parameter ranges, entry and exit conditions and search constraints as inputs. This fixes the grid and the rules before any result appears.

What this means if you use AlphaPrime: set the parameter ranges, fees, slippage and sessions before the search starts. Judge any channel rule by its out-of-sample results and its neighbouring settings, not by the top line of the ranking.

Frequently asked questions

What are the best Keltner channel settings?

No single setting is best for every market and bar size. The common default is a 20-bar EMA, a 10-bar ATR and a multiplier of 2. Use it as the centre of a small test grid, not as an answer. Prefer a setting whose neighbours also test well after costs.

Is the Keltner channel better than Bollinger bands?

Neither is better in general. They measure different things. Keltner width follows average bar size, and Bollinger width follows how far closes spread from their average. Test the same rule on both and keep the one that holds up out of sample.

Is a Keltner channel a breakout or a mean-reversion indicator?

It can be used for both, and the rule decides which. Buying a close above the upper band is a breakout rule. Buying a close below the lower band and exiting at the midline is a mean-reversion rule. Test them as two separate strategies with their own exits and stops.

Can I use a Keltner channel on intraday futures bars?

Yes, the calculation works on any bar size. On intraday data, the gap between sessions enters the true range of the first bar after the break, so the bands widen there. Decide whether your data includes night sessions before testing, and keep that choice fixed.

References

  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
  • Bailey, D. H., & López de Prado, M. (2014). The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting and Non-Normality. The Journal of Portfolio Management, 40(5), 94–107.
  • Harvey, C. R., & Liu, Y. (2015). Backtesting. The Journal of Portfolio Management, 42(1), 13–28.