Strategy · Pine Script v6 · On the chart

RG Structure Trading v4.0

by AllienNova

This strategy tracks pivot-constrained structural boundaries and executes breakout and retest trades directly on the price chart.

View on GitHub

GitHub stars5on the repository
Pine versionv6current
Lines of code654
Settings40inputs
LicenceNone stated
Last update7 weeks ago3 Sep 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

RG Structure Trading v4.0 fits robust trendline boundaries using pivot points, evaluates structural quality via a Q-Score metric, and filters entries through an Efficiency Ratio regime detector. Trades trigger on confirmed retests with candle rejection scoring, graded into tiers that scale risk. Exits utilize ATR-buffered stop losses, a breakeven mechanism, multi-stage partial profit-taking, and an ATR trailing stop alongside daily loss limits.

Details

Published by

AllienNova on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Breakout, Support & resistance, Trend

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.

Topics

aicredit-repairfintechtypescript

Settings

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

SettingTypeDefaultVariable
Pivot Confirmation Barsint2pivotConfirm
Max Pivots to Trackint12maxPivots
Touch Tolerance (ATR)float0.30touchTolerance
Violation Penalty λfloat2.0violationPenalty
Persistence Weight ωfloat0.20persistenceWeight
Minimum Touches (RANSAC)int3minTouches
Max Slope (ATR/bar)float0.02maxSlopeATR
Q-Score Grade A Thresholdfloat0.70qScoreA
Q-Score Grade B Thresholdfloat0.55qScoreB
Max Risk Geometry d_geom (ATR)float2.5maxRiskGeometry
Min Risk Geometry d_geom (ATR)float0.5minRiskGeometry
Efficiency Ratio Periodint20erPeriod
Show all 40 settings
SettingTypeDefaultVariable
ER Trend Thresholdfloat0.45erTrendThreshold
Cross Count Periodint20crossCountPeriod
Max Crossings for Trendint4maxCrossings
Penetration Buffer (ATR)float0.20penetrationBuffer
Close Confirmation Buffer (ATR)float0.40closeBuffer
Retest Window (bars)int12retestWindow
Retest Tolerance (ATR)float0.40retestTolerance
Min Rejection Score (0-4)int3minRejectionScore
Risk Grade A (%)float1.0riskPerTradeA
Risk Grade B (%)float0.5riskPerTradeB
Stop Buffer Beyond Safety (ATR)float0.20stopBuffer
Break Even at (R)float0.8breakEvenR
Partial Exit at (R)float1.0partialExitR
Partial Exit %float60.0partialExitPct
Trail Start at (R)float1.2trailStartR
Trail Buffer (ATR)float0.25trailBufferATR
Max Portfolio Heat (%)float6.0maxPortfolioHeat
Max Daily Loss (%)float3.0maxDailyLossPct
Max Consecutive Lossesint4maxConsecLosses
Max Bars in Tradeint40maxBarsInTrade
Time Stop Min Rfloat0.3timeStopMinR
Enable Drawdown ScalingbooltrueenableDDScaling
DD Threshold 1 (%)float5.0ddThreshold1
Scale at DD1float0.75ddScale1
DD Threshold 2 (%)float10.0ddThreshold2
Scale at DD2float0.50ddScale2
DD Threshold 3 (%)float15.0ddThreshold3
Scale at DD3float0.25ddScale3
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

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
43 stars

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-

Strategy v5 TrendBreakout Repaints
Updated 2 years ago · None stated GitHub repository of SOL 1m - Strategy Candle Bar

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