Strategy · Pine Script v6 · On the chart

Chained Linear Regression Reversal Strategy

by TradersPost

The Chained Linear Regression Reversal Strategy plots linear regression channels with upper and lower standard deviation bands directly on the price chart across a user-defined time window.

View on GitHub

GitHub stars218on the repository
Pine versionv6current
Lines of code1,100
Settings24inputs
LicenceNone stated
Last update3 months ago23 Jul 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

When price breaks out of the static channel for a confirmed number of bars, a dynamic regression tracking channel starts and locks into a new static channel once its Pearson correlation drops below a set threshold. Trades execute based on channel signals using fixed point-based stop loss and take profit orders.

Details

Published by

TradersPost on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Trend, Support & resistance, Mean reversion, Breakout

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Start Timetimetimestamp("2024-01-01 00:00")startTime
End Timetimetimestamp("2024-12-31 23:59")endTime
Ignore WicksboolfalseignoreWicks
Price SourcesourceclosepriceSource
Regression ModestringBothregressionMode
Upper DeviationbooltrueshowUpperChannel
upperDeviationfloat3.0upperDeviation
Lower DeviationbooltrueshowLowerChannel
lowerDeviationfloat3.0lowerDeviation
Breakout Confirmation Barsint1breakoutConfirmation
Lock R Thresholdfloat0.85lockRThreshold
Min Bars Before Lockint5minBarsBeforeLock
Show all 24 settings
SettingTypeDefaultVariable
Max Bars Timeoutint50maxBarsTimeout
Enable StrategybooltrueenableStrategy
Stop Loss (Points)float10.0stopLossPoints
Take Profit (Points)float20.0takeProfitPoints
Uptrend Colorcolor#26a69auptrendColor
Downtrend Colorcolor#ef5350downtrendColor
Show Entry RegressionsbooltrueshowEntryRegressions
Entry Regression Colorcolor#ff9800entryRegressionColor
Fill Transparencyint93fillTransparency
Line Widthint2lineWidth
Show Statistics TableboolfalseshowStatsTable
Table PositionstringTop RighttablePosition
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

1 stars

This strategy identifies pivot-based Darvas Box levels on the price chart and trades re-entries following box sweeps. A long position arms when the price dips below the lower boundary and triggers when it closes back inside, provided the price is above a highe

Strategy v6 Support & resistanceBreakout
Updated 2 months ago · None stated GitHub repository of TN Sovereign Darvas Box v6

This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr

Strategy v6 BreakoutTrend
Updated today · AGPL-3.0 GitHub repository of Forven S01509 - Simple Donchian 20/10 Breakout
257 stars

This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos

Strategy v6 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of Best Chart 1m Strategy Candle Bar
106 stars

Calculates multi-period logarithmic regression trend channels and deviation bands across up to twenty selectable lookback lengths directly on the price chart. It evaluates channel slopes and Pearson's correlation coefficient to detect market trends and generat

Strategy v5 TrendSupport & resistance Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced Trend Detection Strategy

This trend breakout strategy plots Donchian Channels consisting of upper, lower, and middle bands directly on the main price chart. Long positions enter when price touches the upper channel and pulls back to or below the middle band, placing a stop loss at the

Strategy v6 TrendBreakout
Updated 2 months ago · MPL-2.0 GitHub repository of Donchian Strategy - Dynamic TP, Fixed SL, 1% Risk, Daily Target

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers