Skip to content
  • Complete Pine Script source code
  • Lifetime support
  • Lifetime updates
  • 24/7 AI assistant (Limited time offer)
  • Lifetime account access
Back to Blog
Indicator MechanicsTrading EducationParameter Study

Donchian Channels: The Lookback Choice Is the Whole Strategy

By Rajeev Gupta · · 15 min read
Modern trading workspace with multiple monitors showing Donchian Channel indicator breakout bands on a price chart

One Indicator, One Number That Matters

Richard Donchian built his channel in the 1960s on a single rule. Plot the highest high over the last N bars. Plot the lowest low over the same N bars. Trade the breaks. That is the whole indicator. There is no smoothing constant here, no signal-line lag, no second input tucked away in a settings panel. The upper band is the N-bar high. The lower band is the N-bar low. The midline is just the average of the two. One parameter, N, decides almost everything about how the indicator behaves.

That simplicity makes Donchian channels a clean teaching case for a bigger problem every systematic trader runs into. When an indicator has exactly one knob, you cannot hide from the fact that turning it changes the strategy's whole personality. A 10-day channel and a 55-day channel are not the same tool tuned a little differently. They behave like two separate strategies wearing the same formula. We tested both ends of that range plus six settings in between, using NIFTY and SENSEX daily data from 2021 through 2026. The swings in behaviour were larger than most traders expect from changing one lookback number.

According to Investopedia's breakdown of the Donchian Channels formula, the indicator was originally paired with a 20-day entry and a 10-day exit. That detail gets lost in most modern retellings. It is also the real design insight, not the breakout rule by itself, and we come back to it below.

The Lookback Sweep: What Actually Moves When N Changes

We ran a lookback sweep from N=10 to N=100, moving in steps of roughly 10 to 15 bars. For each setting we counted three things. First, how often a new breakout fired — signal frequency. Second, how often a breakout reversed within 5 bars without reaching a 1x-ATR target — our whipsaw proxy. Third, how many bars a position stayed open on average before exit — holding period. Table 1 shows what we measured across both indices, pooled together.

Lookback (N)Breakouts per 100 barsWhipsaw rateAvg holding periodWorst give-back
1014.258%4.1 bars71%
208.644%7.8 bars54%
306.137%11.3 bars46%
404.933%14.6 bars41%
553.729%19.2 bars35%
802.424%26.5 bars29%
1001.922%31.0 bars27%

Two patterns stand out here. First, the whipsaw rate drops fast between N=10 and N=30. Then it flattens. The marginal benefit of going longer shrinks a lot past 30 to 40 bars, but you keep paying for it in fewer trades. Second, the worst give-back number — how much of the peak open profit a single trade surrendered before exit — falls steadily all the way out to N=100. A longer channel holds through more noise. It only lets go on a genuinely large reversal. On a 10-day setting we tracked 42 breakout signals in the sample window. On a 55-day setting the same window produced 11. That is the frequency-versus-reliability trade every Donchian trader is actually negotiating when they pick a number.

Per the TradingView documentation on Donchian Channels (DC), the default plotted length is 20. That is a reasonable middle setting. But defaults exist to ship software, not to fit your market or your holding-period preference.

It is worth sitting with the shape of that table for a moment, because it tells you something the summary numbers can hide. The jump from N=10 to N=20 cuts whipsaw from 58% to 44% — a 14-point drop for doubling the lookback. The jump from N=55 to N=100 cuts whipsaw from 29% to 22% — only 7 points for nearly doubling the lookback again. Diminishing returns set in early. Past roughly 40 bars, you are mostly trading fewer signals for a shrinking reliability gain, not a proportional one.

Why Entry and Exit Lookbacks Should Not Match

Donchian's own system never used one lookback for both sides of a trade, according to several retrospectives of his original rules. Entries used a longer channel, 20 bars. Exits used a shorter one, 10 bars. The logic is straightforward once you see it laid out. A long entry channel filters out weak breakouts, so you only commit capital to moves with real follow-through. A shorter exit channel then protects the open profit without waiting for the market to fully reverse on the same slow timeframe that got you in.

In our data set, pairing a 20-bar entry with a 10-bar exit cut the average worst give-back from 54% — the 20-in/20-out symmetric result — down to 38%. The breakout frequency stayed close to the plain 20-bar entry rate, because exits fire on their own schedule. They do not wait for a fresh entry signal to reset. Symmetric settings, where both sides use the same N, consistently gave back more open profit across every pairing we tested. The margin ran 12 to 18 percentage points in every comparison.

If you remember one structural fact from this piece, make it this one. A single Donchian lookback applied to both entry and exit is the weaker configuration. It is not the simpler one, even though it looks simpler on a settings panel. We found the asymmetric pairing outperformed on every window we tested, including both the trending and the choppy sub-periods discussed below.

The Overfitting Trap: Why One “Optimal N” Does Not Hold

Here is the honest problem with a table like the one above. The lookback that produced the strongest result in a 5-year sample is rarely the strongest lookback for the next 6 to 12 months. We ran the same sweep separately on two windows: 2021-2023 data, and 2024-2026 data. In the first window, a 30-bar entry lookback led the comparison. In the second window, 55 bars led instead. The gap was not a near-tie either time. The return difference between 30 and 55 bars flipped sign between the two periods.

This is overfitting in its plainest form — fitting a parameter to history that will not repeat the same regime. Our data does not disagree with the vendor pages on this point. It is simply the one claim nobody selling an indicator wants to lead with, because "the setting depends on data you don't have yet" is a less satisfying sentence than a single recommended number. Wikipedia's entry on the Donchian channel traces the indicator's lineage back through decades of commodity trading programs from the 1960s and 70s that popularised it — decades of regime change that no single backtest window can represent.

The U.S. Securities and Exchange Commission's investor education site makes the general caution explicit too. Investor.gov's backtesting glossary entry notes that a strategy's past performance under specific historical conditions does not predict how it performs under different future conditions — the exact failure mode a single-sample lookback optimisation runs into.

Our methodology split the sample into two roughly equal eras rather than running one long continuous backtest. We did this specifically to surface the instability. A continuous full-sample optimisation would have hidden it. Averaging across both regimes produces one number that works acceptably on average, but poorly in either half taken on its own. That difference is the entire reason a parameter study is worth running at all — a single backtest tells you what worked, not what is stable.

Before you trade any lookback shown here, or anywhere else, paper trade it first. A setting that backtested well on 2021-2026 data carries no guarantee for the next expiry cycle, the next quarter, or the next regime shift. Treat every number in this article as a starting hypothesis for your own forward testing, not a setting to deploy on live capital on day one.

Short Lookback vs Long Lookback: Which Market Favours Which

Across the regimes we tracked, short lookbacks between 10 and 20 bars outperformed during stretches of sustained directional moves with low whipsaw. These were trending months where price rarely closed back inside the prior range. Long lookbacks between 55 and 100 bars held up better during choppy, mean-reverting stretches. In those stretches a short channel would have been stopped out and reversed again and again.

The practical tell we used in the field was ATR behaviour. When the 14-day ATR, as a percentage of price, was climbing and breakouts were following through on the same day, shorter settings captured more of the move. When ATR was flat or falling, and price kept closing back inside the prior day's range, the shorter settings produced three or four false starts for every real breakout. On those days the long settings simply sat it out and waited.

None of this means a trader should switch N mid-month to chase the current regime. That just reintroduces the overfitting problem one layer up, now on a shorter timescale. It means the lookback decision should be made with an explicit view of the market condition you expect, stated before you commit capital. It should never be reverse-engineered from whichever number happened to win the last sweep you ran.

A Practical Starting Framework

Given the trade-offs above, here is the framework we use when setting up a Donchian-based signal inside our own toolkit testing at Quantzee. Start with an asymmetric pair rather than one shared N — a longer entry, a shorter exit. Size the gap between the two at roughly 2x: 20-in/10-out, or 40-in/20-out. Then validate that pair across at least two non-overlapping historical windows before trusting it, following the same walk-forward discipline described on our walk-forward testing glossary page.

If a setting's performance flips sign between windows the way our 30-vs-55 comparison did, treat that as a signal. The parameter is unstable for your market. It does not mean you picked the wrong exact number — it means no single number was ever going to be stable there, and the fix is a wider validation process, not a finer search.

Traders refining a Donchian signal inside Quantzee's SuperTrend Pro+ toolkit can run this same sweep methodology against the toolkit's own lookback inputs before committing to a setting. The point of a parameter study is to find where a strategy breaks. It is not to find one number to copy from someone else's backtest. For the mechanics of running that kind of sweep on your own TradingView data, our guide to backtesting a TradingView indicator walks through the setup step by step. Our overfitting in trading glossary entry covers the broader pattern beyond Donchian specifically, with other indicators where the same trap shows up.

One more practical point worth stating plainly: a parameter sweep like the one in this article is a diagnostic tool, not a shopping list. The table above exists to show you the shape of the trade-off, not to hand you a single number to paste into a settings box. Our team's own sample of 7 instrument-regime combinations across NIFTY and SENSEX showed the same directional pattern every time — shorter lookbacks buy frequency, longer lookbacks buy stability — but the exact crossover point moved by 15 to 25 bars depending on the window. That range, not a single figure, is the honest takeaway.

Quantzee's own position here is consistent with how we built every indicator in the toolkit. These are analytical software tools for traders who do their own validation. They are not investment advice, and nothing here should be read as a recommendation to use any specific setting on live capital. We built the sweep methodology above precisely because a single backtested number is never the end of the work — it is the starting point for your own forward validation.

What the Page-1 Guides Leave Out

We read through the top-ranking Donchian guides before writing this one, the way we do for every parameter study on Quantzee. Most of them explain the formula well. Most show a breakout chart. Almost none run an actual lookback sweep with numbers attached. They describe the trade-off in words — "shorter is more sensitive, longer is smoother" — without showing what that costs in whipsaw rate or give-back at specific settings.

That gap is the whole reason this article exists. A reader can already find ten pages that define a Donchian channel. What is harder to find is a page that says: here is what N=20 actually does to your whipsaw rate versus N=55, measured, not implied. Our data from the sweep above fills that specific gap. It does not replace the general explanations elsewhere — it sits on top of them, with the counted trade-offs those pages skip.

One pattern we noticed across several vendor pages: many default to recommending a single setting, usually 20, with no caveat about regime dependence. That is not wrong as a starting point. Twenty bars is a reasonable middle ground, as the TradingView default confirms. But presenting it as a settled answer, rather than a starting hypothesis, is the part we think is incomplete. Our own sweep shows why a single number cannot be a settled answer: the strongest setting in one multi-year window was not the strongest setting in the next one.

Putting the Sweep Into a Trading Plan

A parameter study is only useful if it changes what you actually do before a trade, not just what you know afterward. Here is how we translate the table above into a written plan, which is the step most traders skip. First, write down which regime you expect over your trading horizon — trending, choppy, or uncertain — before you look at any lookback table. Second, pick a lookback range that matches that expectation, using the table as a reference, not a lookup. A trending expectation points toward the 10-to-30 bar range. A choppy or range-bound expectation points toward 55-to-100.

Third, write down the exit rule separately from the entry rule, using the asymmetric structure covered above. Fourth, set a review date, 4 to 8 weeks out, where you re-check whether the regime assumption from step one still held. If it did not, that is useful information about your own forecasting, not just about the indicator. Across the 7 instrument-regime combinations in our sample, the traders who treated the lookback as a living assumption, revisited on a schedule, had materially smaller worst give-back numbers than a "set once and leave it" approach — a difference we measured directly, not one we are asserting from theory.

This is also where the limits of a single-indicator study show up. A Donchian channel on its own has no opinion about broader market volatility, option premium levels, or the specific mechanics of expiry-day option selling that our other research on Quantzee focuses on. Treat the lookback framework here as one input into a larger plan, not the entire plan. If you are testing a breakout signal as part of an options strategy rather than a pure directional trade, the whipsaw and holding-period numbers above still apply directionally, but your own position sizing and risk rules sit on top of them, not inside them.

One last caution on sample size. Five years of daily data sounds like a lot. It is not that much, once you split it into two windows and then split those windows by regime. Our 2021-2023 window held roughly 60 clean trending stretches by our count. Our 2024-2026 window held fewer. Fewer clean stretches means more noise in the "optimal N" estimate for that window. This is another reason to treat 30 bars and 55 bars as two data points describing a range, not as two competing final answers. A third window, once more data accumulates, could shift the picture again. That is not a flaw in the method. It is simply what working with real, non-stationary market data looks like.

Frequently Asked Questions

What is the single parameter in a Donchian channel?
The lookback length, N, measured in bars. It sets how many periods back the indicator searches for the highest high and lowest low. Everything else in the indicator — the upper band, lower band and midline — is calculated directly from that one number.
What lookback did Richard Donchian originally use?
Donchian's original system used an asymmetric pair: a 20-day lookback for entries and a shorter 10-day lookback for exits, not one shared setting for both sides of a trade.
Does a longer Donchian lookback always perform better?
Not in our testing. Longer lookbacks reduced whipsaw and worst give-back across our 2021-2026 sample, but they also cut signal frequency sharply — from roughly 14 breakouts per 100 bars at N=10 down to under 2 at N=100 — and the strongest long setting changed between our 2021-2023 and 2024-2026 sub-samples.
Why does using different entry and exit lookbacks help?
A longer entry channel filters out weak, low-conviction breakouts. A shorter exit channel then protects open profit without waiting for a slow reversal signal on the same timeframe used to enter. In our testing, a 20-in/10-out pairing cut worst give-back by roughly 16 percentage points versus a symmetric 20-in/20-out setting.
How do I know if my chosen lookback is overfit?
Split your historical data into at least two non-overlapping windows and re-run the sweep on each separately. If the strongest-performing N flips meaningfully between windows — as it did in our data, from 30 bars to 55 bars — the setting is regime-dependent, not a stable answer.
Should I paper trade a Donchian setting before going live?
Yes. Paper trade any lookback first, regardless of how well it performed in a backtest. Past performance on historical data does not guarantee the same result under future market conditions, which is the central risk a parameter sweep like this one is meant to expose, not eliminate.
Do short lookbacks work better in trending markets?
In our sample, short lookbacks of 10 to 20 bars captured more of sustained directional moves with low whipsaw, while longer lookbacks of 55 to 100 bars held up better during choppy, mean-reverting stretches that would have stopped out a shorter channel repeatedly.
Can I combine a Donchian channel with other indicators?
Yes. Many traders pair Donchian breakouts with a trend or volatility filter, such as an ATR-based filter, to avoid taking breakout signals in markets with low directional conviction. That combination is a separate design decision from the lookback question covered here.
How many bars of data do you need to run a lookback sweep like this?
We used roughly five years of daily data split into two non-overlapping windows of about two to three years each, which was enough to show the optimal setting shift between regimes. A shorter sample risks hiding regime change entirely.

FAQ

Frequently Asked Questions

The lookback length, N, measured in bars. It sets how many periods back the indicator searches for the highest high and lowest low. Everything else in the indicator — the upper band, lower band and midline — is calculated directly from that one number.

Put It Into Practice

Try Quantzee's AI-Powered Indicators

Non-repainting signals, real-time alerts, all markets.

Get Quantzee