Linear regression channel strategy: rules, repainting, timeframes
A linear regression channel is traded either by fading a band touch back toward the centre line or by following a close outside a band. The drawn channel repaints because every new bar refits the whole line, so a testable rule uses only the band value known at each bar's close. Test both rules, net of costs, across neighbouring lengths.
By Soren Huang · Published · updated · Editorial policy
Contents
- How do you trade a linear regression channel, and does it repaint?
- How are the regression line and the standard deviation bands calculated?
- How is a linear regression channel different from Bollinger Bands?
- Does repainting affect backtests?
- Reversion or breakout: which rule should you test?
- Which timeframes and lengths suit a linear regression channel?
- What does a finished test of a channel-type rule look like?
- Frequently asked questions
- References
How do you trade a linear regression channel, and does it repaint?
A linear regression channel is traded in one of two ways: fade a touch of the upper or lower band back toward the centre line, or follow a close outside a band. The drawn channel repaints, because each new bar refits the whole line, so a testable rule uses only the band value known at each bar's close.
A linear regression channel is a straight line fitted through the last N closing prices, with one band above and one band below it at a fixed distance. The line is the "fair" path of price over that window; the bands mark how far price has usually strayed from it. Think of a ruler laid along a hillside: the ruler shows the slope, and the bands are two fence lines running parallel to the ruler. The linear regression indicator page defines the line itself, so this article spends its words on how to trade and test it. For where channel tools sit among the other tools you can test, see the guide to technical analysis tools and indicators.
Both trading rules read the same two bands. A reversion rule treats the bands as rubber walls: price at the upper band is stretched, so you sell and aim for the line. A breakout rule treats the bands as doors: a close beyond the upper band means the move is stronger than the window expected, so you buy and stay until price closes back inside. The repaint question has a short answer. The picture on your chart redraws its entire length every bar, so the band that appears to have sat under a low ten bars ago was not there at the time. The value of the band at that bar's close, computed from the bars up to that close, is the only number a rule can act on, and that number never changes afterwards.
How are the regression line and the standard deviation bands calculated?
The channel is a straight best-fit line through the last N closes, with two parallel bands a chosen number of standard deviations above and below it. Best-fit means the line that makes the total of the squared vertical distances from each close to the line as small as possible; this is the least-squares line you may know from a spreadsheet trend line. Each close has a distance from the line, positive if the close is above it and negative if below. The standard deviation is the typical size of those distances, so it measures how tightly or loosely the closes hug the line.
The one formula to know is:
band = line value ± k × standard deviation of the distances from the line
Here line value is the height of the fitted line at a given bar, k is the multiplier you choose (2 is the most common setting), and the standard deviation of the distances is the scatter of the closes around the line over the window. Because the scatter is one number for the whole window, both bands run parallel to the line at a constant distance. The standard deviation indicator computes the same scatter measure around a moving average instead of a sloped line.
A standard error channel is the same construction with the band distance taken from the standard error of the regression, which is the same scatter measure with a small adjustment for the number of points fitted. On a window of 100 bars the two widths are nearly equal, so a rule written for one transfers to the other with little change. The linear regression indicator that many platforms plot as a single line is simply the end value of this fitted line at each bar, which is why it looks like a fast moving average.
How is a linear regression channel different from Bollinger Bands?
Bollinger Bands bend with a moving average and change width bar by bar, while a regression channel is one straight sloped line with bands of constant width over its window, so the two give different signals on the same prices even at the same length and multiplier. Bollinger Bands measure scatter around a moving average, which curves as price curves; the regression channel measures scatter around a straight line, which only tilts. In a steady trend the regression line sits close to price and its bands are narrow, while a moving average lags behind price and the Bollinger Bands sit off-centre. In a sideways market the opposite happens: the moving average follows the wobble and the regression line cuts straight through it.
| Feature | Linear regression channel | Bollinger Bands |
|---|---|---|
| Centre line | Straight least-squares line over the window | Simple moving average, curves with price |
| Band width | One value for the whole window, bands parallel | Recomputed every bar, bands widen and narrow |
| Behaviour in a trend | Line tracks the slope; bands stay narrow | Average lags; price rides one band |
| Behaviour in a range | Line nearly flat; touches at both bands | Bands pinch, then flare on the next move |
| Redraws past values | Yes, whole line refits each bar | No, each bar's value is final |
The last row matters most for testing. A Bollinger Band value printed under a bar stays there forever; the regression channel over that same bar will move the next day. A third channel type, the Donchian channel breakout, uses the highest high and lowest low of the window with no statistics at all, and like Bollinger Bands it does not redraw.
Does repainting affect backtests?
Repainting only ruins a backtest when the test uses the current drawn channel to judge past bars; a backtest that stores the band value computed at each bar's close and never revises it is free of the leak. Repainting is the redrawing of an indicator's past values after new bars arrive. For a regression channel it is built in: adding bar 101 to a 100-bar window drops bar 1, refits the line, and shifts every point of the channel, including the points over bars that already closed. A rule that reads the channel as it is drawn today therefore knows where the bands "will end up", which is information from the future.
The fix is the same one used against every look-ahead leak: compute the band at bar t from bars t−N+1 to t only, record it, and act on the next bar. A one-bar check tells you which kind of test you have:
- Run the backtest and note the upper band value the rule saw at one chosen bar.
- Load ten more bars of data and read the drawn upper band over that same bar.
- If the two numbers differ and your test used the drawn one, the test is leaking. If your test stored the first number and ignores the redraw, it is clean.
Doing this by hand once is enough to know how your platform behaves. AlphaPrime (Valynox) freezes an indicator value at the bar close that produced it and fills on the following bar, so a channel band inside its backtesting is never read from a line that a later bar has moved, and commission and slippage are charged on every one of those fills.
Reversion or breakout: which rule should you test?
The same two bands support two opposite rules, and the honest approach is to write both as exact rules with long and short sides, test both, and expect only one to survive costs on a given market and bar size. A band touch is a sell signal to the reversion trader and a hold-or-buy signal to the breakout trader. The indicator does not decide which is right; the market's behaviour over the window does. Park and Irwin (2007) review decades of tests of technical rules and find that results depend heavily on the costs charged and the period tested, which is exactly why both rules need a test rather than a belief.
| Rule part | Reversion rule | Breakout rule |
|---|---|---|
| Long entry | Close at or below the lower band; buy at the next open | First close above the upper band; buy at the next open |
| Short entry | Close at or above the upper band; sell at the next open | First close below the lower band; sell at the next open |
| Exit | Close crosses the regression line, or opposite band | Close back inside the channel |
| Markets it needs | Sideways, scatter steady | Trending, moves that keep going |
| Typical failure | Fading a trend that keeps running | Paying costs on false breaks in a range |
Write the rules to the letter before the first run. A reversion entry at the lower band often looks like the second low of a double bottom pattern; the method there, turning a chart shape into exact conditions, applies to channel touches too. A common refinement is to allow reversion trades only against a stretched oscillator, for example a short at the upper band only when the RSI indicator is above 70. Add such a filter as a separate test so you can see what it changed.
Which timeframes and lengths suit a linear regression channel?
Length matters more than the clock: a short window turns the channel into a noisy trend-follower, a long window makes it a slow mean-reversion frame, and the bar size only sets how much one round-trip cost takes out of each trade. A 30-bar channel on daily bars and a 30-bar channel on 5-minute bars behave alike in shape; what differs is the band width in money against the cost of a trade.
| Window length | What the channel does | Rule it tends to suit |
|---|---|---|
| Around 20 to 50 bars | Tilts quickly, bands narrow, many touches | Breakout, with a cost check |
| Around 50 to 100 bars | Moderate slope, fewer touches | Either; test both |
| 100 bars or more | Slow slope, wide bands, rare touches | Reversion |
A parameter plateau is a stretch of neighbouring settings that all give a similar result. Pardo (2008) makes this the central test of an optimization: a setting worth keeping sits in the middle of a plateau, because a small change in the market will shift the best setting a little, and a plateau survives that shift while a single spike does not. Run lengths from about 20 to 200 in steps and look at the whole row, not the top value.
Hypothetical example
Suppose a 2-standard-deviation band sits on average 10 points from the line on one bar size, and commission plus slippage for a round trip costs the equivalent of 1 point. A reversion trade from band to line targets 10 points and pays 1, so cost is a tenth of the target. On a faster bar size the same channel's band might sit 2 points from the line while the round trip still costs 1 point; now cost is half the target, and the rule has almost no room. Choose bar sizes where the first case holds.
What does a finished test of a channel-type rule look like?
A channel rule is judged like any other candidate: net of commission and slippage, with its drawdown next to its profit, and with the selection it came from stated. The run below shows that shape. The data was ES daily bars from 2019-01-02 to 2025-06-30, traded long and short with one contract, charging $20 commission and $25 slippage on each trade. The rule is a stand-in built from standard indicators, not a regression channel, so the numbers illustrate how to read a report rather than how a channel performs. The candidate shown is the one the search kept out of 1,024 it tried, chosen for its return against its drawdown; keeping the best of many after the fact flatters the result, and it is not something a reader can expect to repeat.
Source: AlphaPrime product engine (CPU), run 2026-10-31. ES daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $25 slippage per trade.
| Number | Result |
|---|---|
| Net profit (closed trades) | $75,845 |
| Max drawdown | $34,512.5 |
| Trades | 129 |
| Win rate | 60.47% |
| Profit factor | 1.588 |
| Average trade | $587.95 |
| Time in market | 31.61% |
Read it in this order. The max drawdown of $34,512.5 against the net profit of $75,845 says the worst stretch cost close to half of everything the run made. The 129 trades over six and a half years is a thin sample for a per-trade figure, so the average trade of $587.95 carries wide uncertainty. And the count of 1,024 candidates is the number Bailey, Borwein, López de Prado and Zhu (2014) warn about: the best of that many tries is inflated by selection, and only data the search never touched can say by how much. A channel rule you build yourself deserves the same three readings.

Your next step: pick one market and one bar size, write the reversion rule and the breakout rule with band values frozen at each bar's close, run lengths from 20 to 200 with your real commission and slippage, and keep a candidate only if it sits on a plateau. Then set aside the most recent months of your data and run the kept rule on them once.
Frequently asked questions
Does a linear regression channel repaint?
Yes. Every new bar refits the line through the whole window, so the channel drawn over past bars moves. The value of the band at each bar's close, computed from the bars up to that close, does not move. A backtest or a live rule must use that frozen value and act on the next bar.
What is a standard error channel?
A standard error channel is a linear regression channel whose band distance is a multiple of the standard error of the regression instead of the standard deviation of the distances from the line. The two measures differ only by a small adjustment for the number of points fitted. On a window of 100 bars the band widths are nearly the same, so rules transfer between them with little change.
What length should I use for a linear regression channel?
Run a range of lengths, for example 20 to 200, on your market and bar size and keep a length from the middle of a plateau where neighbouring settings give similar results. Short windows around 20 to 50 bars tilt fast and suit breakout rules; windows of 100 bars or more are slow and suit reversion rules. A single length that stands out from its neighbours is more likely luck than edge.
Is the linear regression indicator the same as the channel?
The linear regression indicator plots the end value of the fitted line at each bar, which makes it look like a fast moving average. The channel adds the two bands and, on a chart, draws the full line across the window. The indicator's value at each bar is frozen; the channel's drawing over past bars is not.
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.
- Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies (2nd ed.). John Wiley & Sons.
- Park, C.-H., & Irwin, S. H. (2007). What Do We Know About the Profitability of Technical Analysis? Journal of Economic Surveys, 21(4), 786–826.

