OPEN-SOURCE SCRIPT

Super Regression Trend

2 571
█ OVERVIEW
Super Regression Trend is an advanced trend-following indicator that combines classic linear regression with a SuperTrend mechanism based on RMSE (Root Mean Square Error). Instead of traditional ATR, it uses price deviations from the regression line, allowing for highly precise adaptation to current market volatility. The indicator is clean, dynamic, and equipped with optional risk management tools — automatic Take Profit and Stop Loss levels displayed after each trend reversal signal. Perfect for traders seeking solid trend confirmation with built-in position management support.

█ CONCEPT
The indicator was created to combine the advantages of linear regression (smooth trend tracking) with the reliability of the SuperTrend mechanism (trailing stop).
The key element is calculating RMSE based on deviations of the source price from the regression line over a specified period. The band around the regression (RMSE × multiplier) creates dynamic, trailing upper and lower levels. The trend changes only after price closes beyond this band — this allows the indicator to react quickly to new impulses while effectively filtering noise and false breakouts in consolidation.

█ FEATURES
Data source:
- Source price (default: close)
- Regression Length

Calculations:
- Linear regression line (ta.linreg)
- RMSE of deviations within the length window
- Upper and lower bands: regression ± (RMSE × Multiplier)

Trailing mechanism:
Levels are “pulled” in the direction opposite to the trend (minimized/maximized)
Trend change logic:
- Down → Up: close > upper band
- Up → Down: close < lower band

Visualization:
- SuperTrend line with breaks at reversal points
- Optional gradient fill between SuperTrend line and regression
- Optional bar coloring based on current trend
- “Buy” labels (green upward arrow) and “Sell” labels (red downward arrow) only on confirmed trend changes

Risk management:
- Optional automatic TP1/TP2/TP3 and SL levels after each signal
Two calculation modes:
- Candle Multiplier – multiplier of average candle body size (SMA(|open–close|))
- Percentage – percentage of the signal close price
Levels drawn as short horizontal lines
Persistent table in the top-right corner with current TP/SL values

Alerts:
- Buy Signal – triggers only on confirmed uptrend change
- Sell Signal – triggers only on confirmed downtrend change

█ HOW TO USE
Add to chart → paste the code in Pine Editor or search for “Super Regression Trend”.
Main settings:

- Regression Length → default 20 (regression window length)
- RMSE Multiplier → default 2 (key sensitivity parameter)
- Show SuperTrend Line / Fill to Regression / Color Bars → visual options
- Show TP/SL Levels → enable/disable risk management tools
- TP/SL Calculation Mode → “Candle Multiplier” or “Percentage”
- Multipliers/percentages for TP1–TP3 and SL → fully customizable

Interpretation:
- Green line and shading = uptrend
- Red line and shading = downtrend
- Higher RMSE Multiplier = fewer signals, higher quality
- Lower Multiplier = faster reaction, more signals (aggressive mode)

█ APPLICATIONS
Excellent for:
- Classic trend-following (enter with trend, exit on reversal)
- Momentum and breakout strategies
- Automated position management with optional TP/SL levels

Best combined with:
- Support/resistance levels, Pivot Points, psychological round numbers
- Confirmation from oscillators (RSI, Stochastic, MACD)
- Volume or volume profile analysis

Style adaptation:
- Scalping / daytrading → shorter regression length (10–20) and lower Multiplier (1.5–2.0)
- Swing / longer-term positions → longer regression (30–50) and higher Multiplier (2.0–3.0)

█ NOTES
- Works on all markets and timeframes
- Effectiveness depends on matching the RMSE Multiplier to the instrument’s volatility
- Higher Multiplier and Length values = fewer, but significantly more reliable signals

Penafian

Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.