1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
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
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
RG Structure v2.0 [Visual Edition] evaluates breaks and retests of these trendlines using scoring weights, violation penalties, and regime detection to generate entry and exit signals. The strategy manages risk with configurable percentage-based position sizing, stop-loss buffers scaled by ATR, and trailing stops. It draws trendlines, pivot markers, break zones, regime backgrounds, and trailing stops directly on the price chart. Inputs allow tuning of pivot sensitivity, scoring, retest windows, and risk parameters.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Lookback Window (N)
int
200
N
Pivot Left Bars
int
2
left
Pivot Right Bars
int
2
right
Max Pivots for Line Fitting
int
12
maxPivots
Violation Eval Step
int
4
evalStep
Min Pivot Touches
int
2
minTouches
Touch Tolerance (α × ATR)
float
0.10
tauMult
Span Reward Weight (ωs)
float
0.20
wSpan
Violation Penalty (λ)
float
1.50
lamViol
Break Penetration (βp × ATR)
float
0.10
breakPenATR
Break Confirmation (βc × ATR)
float
0.15
breakConfATR
Retest Buffer (γ × ATR)
float
0.20
retestATR
Show all 40 settings
Setting
Type
Default
Variable
Fail Buffer (δ × ATR)
float
0.20
failATR
Retest Window (M bars)
int
12
retestMaxBars
Regime Window (ER/Cross)
int
150
erLen
ER Trend Threshold
float
0.35
erTrendThr
ER Range Threshold
float
0.20
erRangeThr
Max Crossings for Trend
int
8
crossTrendMx
Min Crossings for Range
int
20
crossRangeMn
Risk % (A Setup)
float
1.0
riskPctA
Risk % (B Setup)
float
0.5
riskPctB
A Setup Q Threshold
float
0.70
qA
B Setup Q Threshold
float
0.60
qB
Max dGeom (ATR units)
float
2.5
dSafetyMax
Stop Buffer (× ATR)
float
0.20
stopBufATR
BE Trigger (R)
float
0.8
beTrigR
Partial Take Profit (R)
float
1.0
partialR
Partial Qty %
int
60
partialPct
Trail Start (R)
float
1.0
trailStartR
Trail Buffer (× ATR)
float
0.20
trailBufATR
Time Stop Bars
int
20
timeStopBars
Show Pivot Markers
bool
true
showPivots
Show Trendlines
bool
true
showTrendlines
Show Break/Retest Zones
bool
true
showZones
Show Trailing Stop
bool
true
showTrailStop
Show Regime Background
bool
true
showRegimeBG
Show Event Labels
bool
true
showLabels
Support Color
color
color.new(color.green, 20)
supColor
Resistance Color
color
color.new(color.red, 20)
resColor
Action Line Color
color
color.new(color.orange, 0)
actionColor
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.
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 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
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
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
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