NEWCard payments are live · from $18/month, USDT also acceptedSee plans
COINPRED / STRATEGY LIBRARY

BTC Linear Regression Channel Breakout: Go long when the close clears the upper band, short when it breaks the lower

An open-source breakout strategy published by chanu_lev10k (MPL 2.0), with LonesomeTheBlue also named in the source header. It fits a linear-regression mid-line and a standard-deviation channel, goes long when the close clears the upper band, and goes short when it breaks the lower band. Take-profit defaults to 11% and the stop is off. The author's chart is BYBIT:BTCUSD.P on the 8-hour timeframe. The rules follow the source; this page has no invented backtest figures.

Illustrated guidesPine Script®Included with monthly & annual plans
← All strategies
chanu_lev10k · 3.0 · 2026-11-27 · Breakouts
BTC Linear Regression Channel Breakout: Go long when the close clears the upper band, short when it breaks the lower

What the strategy is trying to do

This is an open-source script published by chanu_lev10k, titled “Linear Regression Channel Breakout Strategy.” The header credits both LonesomeTheBlue and chanu_lev10k, so the channel drawing follows LonesomeTheBlue's linear-regression channel, with entries and percentage exits added by the publisher. It fits a regression line over a recent window, builds upper and lower bands from a deviation multiple, and trades a close through those bands. The author's chart is BYBIT:BTCUSD.P on the 8-hour timeframe, so this entry is filed under BTC. The script does not hard-code a symbol and will load on other charts, but the guide and the image follow that publication chart.

The strategy declaration only sets overlay=true. It does not set position size or commission, so Pine's defaults apply: a fixed quantity of 1. On a bitcoin perpetual, one unit can be a large notional, so set size and fees in the strategy properties before you read the tester.

The author's linear regression channel breakout strategy on a BYBIT:BTCUSD.P 8-hour chart, with the channel, direction labels, and entry/exit marks visible
Author chart: BYBIT:BTCUSD.P (Bitcoin / U.S. Dollar Perpetual), 8-hour timeframe, from the author's publication page. The regression channel, direction labels, and entry/exit marks are visible; this only shows the layout and is not evidence of performance.

How the indicators are calculated

  • Channel length defaults to 20, and Source defaults to the close.
  • The mid-line uses the mean of Source over the window. Slope is ta.linreg(src, len, 0) minus ta.linreg(src, len, 1). The intercept and the far end of the line are derived from that slope and the window length. dev is the root-mean-square of each point's distance to that line.
  • The bands are the far-end price y2_ plus or minus dev × Deviation. Deviation defaults to 2.3.
  • The script also draws the three channel lines, colors them by the sign of the slope, and can add Fibonacci levels or keep a broken channel as a dotted leftover. Those are display only and do not drive orders.
  • longCondition is written as “slope down and close above the upper band, or slope up and close above the upper band.” The close test is the same in both branches, so a long fires whenever the close is above the upper band; slope does not filter direction. Shorts are the same: a close below the lower band is enough.

Entry rules

  • Long (order name Long): the close is above the upper band y2_ + dev × Deviation.
  • Short (order name Short): the close is below the lower band y2_ − dev × Deviation.
  • The source does not require a flat book, and it does not set pyramiding, so Pine's default is no add-on in the same direction. An opposite entry usually flattens the current trade and reverses. What actually fills still depends on your order settings.
  • The source does not wait for barstate.isconfirmed. On an 8-hour chart, whether the close has cleared a band can still change before the bar ends.

Exits and position size

  • Take-profit is on by default; the stop is off. The take-profit is Take Profit % (default 11%) away from the average entry, and the stop is Stop Loss % (default 10%) the other way, but only if that switch is enabled.
  • Long and short exits are separate strategy.exit orders, named Long/Short Take Profit and Long/Short Stop Loss. They are placed only when the matching switch is on.
  • There is no separate close when price breaks back through the channel. An opposite signal is handled by an opposite entry, not by a standalone close.
  • Size defaults to one unit, not a fraction of equity. Set the quantity and commission in the properties before you run it on a bitcoin perpetual.

Inputs (source defaults)

InputDefaultRole
SourceclosePrice used to fit the regression channel.
Length20Lookback for the regression, minimum 10.
Deviation2.3Width of the upper and lower bands around the mid-line.
Extend LinestrueExtends the channel to the right; display only.
Show Fibonacci LevelsfalseDraws Fibonacci levels inside the channel; display only.
Show Broken ChanneltrueKeeps the old lines after the channel is broken the other way.
Enable Stop LossfalsePlaces a percentage stop from the average entry.
Enable Take ProfittruePlaces a percentage take-profit from the average entry.
Stop Loss %10.0Stop distance, used only if the stop is enabled.
Take Profit %11.0Take-profit distance, on by default.

Things to know before using it

  • Entries do not depend on the slope. The source writes both slope cases into the condition, but they collapse to whether the close has cleared the upper or lower band.
  • There is no stop by default, only an 11% take-profit. A breakout that reverses without reaching that target can stay open until an opposite entry flips the position.
  • The default size is one unit, and no commission is set. On a chart such as BYBIT:BTCUSD.P, change both before you trade or test.
  • The channel, Fibonacci lines, and direction labels are display only. Some comments are in Korean; that does not change the logic as written.
  • The header keeps copyright notices for both LonesomeTheBlue and chanu_lev10k; keep both if you redistribute the file.

Installing it on TradingView

  1. Download the .pine file from Coinpred (active membership required, see below), or check the original page for a newer version.
  2. Open the Pine Editor, create a blank script, paste the full source, and save.
  3. Click Add to chart. To match the author image, start with BYBIT:BTCUSD.P on the 8-hour timeframe.
  4. Set the quantity and commission in the strategy properties, review the stop and take-profit switches, then inspect fills in the Strategy Tester.
  5. Past tester results do not guarantee future returns.

About backtest figures

Source, license and version

  • Source: https://www.tradingview.com/script/7USLDe0j/
  • Author: chanu_lev10k (the source header also names LonesomeTheBlue). Source version 3.0 (Pine v5), scriptAccess=open_no_auth.
  • License: Mozilla Public License 2.0. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified full source.
  • Members can download the .pine file on this page to study the rules. Judge the risk yourself, and follow your venue's rules.

Source, license and version

Licensed under MPL 2.0 per the source header, © LonesomeTheBlue © chanu_lev10k. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified source.

View original source ↗

Check the script license and your TradingView account features. Historical results do not guarantee future performance.

More strategies

All strategies →