OPEN-SOURCE SCRIPT

Linear Regression Scanner (KenshinC)

413
Linear Regression Scanner (KenshinC) + Slope Visual is a powerful real-time multi-symbol dashboard combined with advanced Linear Regression visualization. It analyzes up to 12 major cryptocurrency pairs simultaneously, displaying trend direction, price position relative to the regression midline, RSI(14), and precise slope values in a clean table. Additionally, it plots the Linear Regression Curve and dynamic slope direction arrows directly on the current chart for deeper visual insight.

🔍 WHAT MAKES IT ORIGINAL

1. True Multi-Symbol Linear Regression Engine — Simultaneously calculates full Linear Regression Channels (intercept, endpoint, deviation, and slope) for 12 symbols using request.security().
2. Dual Linear Regression System — Uses two independent regression calculations: one for the scanner table (default 100 bars) and one for on-chart visualization (default 150 bars) with slope arrows.
3. Slope-Based Trend & Momentum Arrows — Detects trend direction from regression slope and displays intuitive teal/orange arrows showing slope strength on every bar.
4. Price vs Regression Midline Positioning — Real-time comparison of price against the dynamic regression center line.
5. Professional All-in-One Dashboard — Clean, color-coded table with Trend, Price Position, RSI, and Slope — all updated on bar close.
6. Highly Customizable — Independent settings for scanner channel and on-chart regression curve.

⚙️ HOW IT WORKS

The scanner uses a custom get_channel() function to compute the best-fit Linear Regression line as follows:

mid = math.sum(src, len) / len
slope = ta.linreg(src, len, 0) - ta.linreg(src, len, 1)
intercept = mid - slope * math.floor(len / 2) + (1 - len % 2) / 2 * slope

This produces:
- The midline (average of the source over the chosen Channel Length)
- The true slope of the regression line (rate of change)
- Intercept and projected endpoint for accurate current-bar positioning
- Standard deviation around the line (ready for future deviation bands)

Trend is determined directly from the slope: positive slope = Bullish, negative slope = Bearish.
Price vs Middle compares the current price to the regression line value at the current bar.

For the on-chart visualization (inspired by emiliolb):
lrc = ta.linreg(close, lrc_len, 0)
lrprev = ta.linreg(close[1], lrc_len, 0)
slope_current = (lrc - lrprev)

This plots a smooth red Linear Regression Curve (default 150 bars) and displays slope direction with arrows: Teal ↑ for positive/strengthening slope (bullish momentum) and Orange ↓ for negative/strengthening slope (bearish momentum).

RSI(14) is calculated independently for each symbol to show overbought (>70) and oversold (<30) conditions.
The entire dashboard refreshes on every bar close using efficient array looping.

📖 HOW TO USE

Reading the Dashboard Table (Top Right):
- Symbol: Ticker name (e.g., BTCUSDT)
- Trend: Green = Bullish (positive slope), Red = Bearish (negative slope)
- Price VS Middle: Green = Price above regression midline (bullish positioning), Red = Below midline (bearish positioning)
- RSI: Lime Green (<30) = Oversold, Yellow (30–70) = Neutral, Red (>70) = Overbought
- Slope: Precise numerical value — the higher the positive number, the stronger the uptrend; the lower the negative number, the stronger the downtrend.

Reading On-Chart Visuals:
- Red Curve: Linear Regression Curve (default 150 bars) — serves as a dynamic trend baseline.
- Teal Arrows ↑: Positive and strengthening slope → bullish momentum.
- Orange Arrows ↓: Negative and strengthening slope → bearish momentum.

Suggested Trading Workflow:
1. Scan the table for Bullish symbols showing “Bullish” + “Above” + strong positive Slope.
2. Confirm RSI is not extremely overbought (>70).
3. Switch to the symbol and observe the Red LRC Curve together with Slope Arrows for precise timing.
4. Look for strong confluence: Positive slope + price above midline + teal arrows = high-probability trend continuation setup.
5. Best performance on 15m, 1H, and 4H timeframes.
6. Always combine with support/resistance levels, volume, or higher-timeframe analysis.

Best Practices:
- Use longer Channel Length (100+) for smoother, longer-term trend detection.
- Adjust Linear Regression Length (150) to control the smoothness of the on-chart curve and arrows.
- Works excellently on major USDT perpetual pairs.

⚙️ KEY SETTINGS REFERENCE

- Symbols: 12 pre-loaded major Binance USDT pairs (fully customizable)
- Linear Regression Slope Section: Show Curve, Show Arrows, Length (default 150), Color, Width
- Channel Settings: Source (default = low), Channel Length (default 100), RSI Length (default 14)
- Colors: Up Trend and Down Trend colors

🔔 Alerts

No built-in alerts yet. You can easily create manual alerts for slope direction changes, price crossing the regression midline, or RSI extremes.

⚠️ IMPORTANT NOTES

— On-chart Linear Regression Curve and Slope Arrows are calculated and displayed only for the current symbol you are viewing.
— The scanner table analyzes all 12 symbols independently in real time.
— All calculations are performed on bar close to prevent repainting.
— Slope values are not normalized across different assets — only compare them within the same symbol and timeframe.
— Strong slope signals indicate trend strength but do not guarantee future price movement.
— This indicator uses multiple request.security() calls. Avoid overloading the chart with too many other indicators.
— Past performance is not indicative of future results. This tool is for educational and analytical purposes only.
— Not financial advice. Always use proper risk management and trade at your own risk.

---

Made with passion by KenshinC
Happy trading & trend hunting! 🚀

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.