OPEN-SOURCE SCRIPT
Angular Resistance & Breakout/Breakdown

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.
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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.