Calculates multi-period logarithmic regression trend channels and deviation bands across up to twenty selectable lookback lengths directly on the price chart.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
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
186 lines of Pine Script v5 from Advanced Trend Detection Strategy.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Advanced Trend Detection Strategy evaluates channel slopes and Pearson's correlation coefficient to detect market trends and generate strategy entries. Key user settings configure channel lengths, deviation multipliers, line extensions, and display parameters. Because calculations evaluate on the final bar using historical lookbacks, visual channel plots and historical signal placement repaint, and the strategy operates without a default stop loss.
Multi-length logarithmic linear regression channels
Configurable upper and lower standard deviation bands
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Length 1
int
50
lengthInput1
Length 2
int
100
lengthInput2
Length 3
int
150
lengthInput3
Length 4
int
200
lengthInput4
Length 5
int
250
lengthInput5
Length 6
int
300
lengthInput6
Length 7
int
350
lengthInput7
Length 8
int
400
lengthInput8
Length 9
int
450
lengthInput9
Length 10
int
500
lengthInput10
Length 11
int
550
lengthInput11
Length 12
int
600
lengthInput12
Show all 32 settings
Setting
Type
Default
Variable
Length 13
int
650
lengthInput13
Length 14
int
700
lengthInput14
Length 15
int
750
lengthInput15
Length 16
int
800
lengthInput16
Length 17
int
850
lengthInput17
Length 18
int
900
lengthInput18
Length 19
int
950
lengthInput19
Length 20
int
1000
lengthInput20
Source
source
close
sourceInput
Upper Deviation
bool
true
useUpperDevInput
upperMultInput
float
2.0
upperMultInput
Lower Deviation
bool
true
useLowerDevInput
lowerMultInput
float
2.0
lowerMultInput
Show Pearson's R
bool
true
showPearsonInput
Extend Lines Left
bool
false
extendLeftInput
Extend Lines Right
bool
true
extendRightInput
colorUpper
color
color.new(color.blue, 85)
colorUpper
colorLower
color
color.new(color.red, 85)
colorLower
SMA Color
color
color.blue
smaColor
SMA Width
int
1
smaWidth
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.
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
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
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. When price breaks out of the static channel for a confirmed number of
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
This strategy executes trades on short-term cryptocurrency charts using a combination of pivot support and resistance levels and a multi-pole smoothed trend filter. Entries trigger when price crosses the smoothed trend line and confirms above or below a short-
This strategy trades Donchian breakouts measured on weekly bars while orders execute on the chart timeframe. It allows long and short entries when price breaks the prior weekly channel and exits against the shorter weekly channel. Position size risks a set per