OPEN-SOURCE SCRIPT

Angular Resistance & Breakout/Breakdown

179
Angular Resistance & Breakout/Breakdown (Dynamic Trendlines)

This indicator provides a dynamic approach to identifying major support and resistance levels by fitting Linear Regression lines to recent pivot points (swing highs and swing lows). Unlike static horizontal lines, these "Angular" trendlines adapt to the market's slope, providing continuously adjusting targets for resistance and support, along with signals for confirmed breakouts and breakdowns.

💡 Key Features
Dynamic Trendlines: Utilizes Linear Regression to automatically draw sloped trendlines based on a configurable number of the most recent swing pivots.

Confirmed Signals: Generates clear Breakout (▲) and Breakdown (▼) signals with optional buffer and sensitivity filters to reduce noise.

Customizable Inputs: Fine-tune the pivot detection period, the number of points used for regression, line extension, and signal sensitivity.

On-Chart Info Panel: A table displays real-time data, including the number of detected pivot points and the current calculated price level of the dynamic lines.

⚙️ How It Works (The Logic)
Pivot Detection: The script uses the standard ta.pivothigh() and ta.pivotlow() functions to reliably identify swing points, based on the Pivot Left and Pivot Right settings. These points are stored in dynamic arrays (highs for resistance, lows for support).

Angular Line Generation: A custom function, f_regression_from_array, performs a Linear Regression analysis using the bar index (X-axis) and the pivot price (Y-axis) for the Points to use. This calculation determines the optimal slope and intercept to draw a best-fit dynamic line through the identified pivot points.

Breakout/Breakdown Confirmation:

Breakout: Triggered when the current close price crosses above the dynamic resistance line plus the user-defined Breakout buffer.

Breakdown: Triggered when the current close price crosses below the dynamic support line minus the user-defined Breakout buffer.

Sensitivity Filter: An optional filter requires the price movement on the signal bar to exceed a minimum percentage (Label sensitivity) away from the line to confirm the momentum of the move.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。