-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Indicator Name
Linear Regression Intensity
Category
Volatility
Description
Introducing the Linear Regression Intensity indicator by AlgoAlpha, a sophisticated tool designed to measure and visualize the strength of market trends using linear regression analysis. This indicator not only identifies bullish and bearish trends with precision but also quantifies their intensity, providing traders with deeper insights into market dynamics. Whether you’re a novice trader seeking clearer trend signals or an experienced analyst looking for nuanced trend strength indicators, Linear Regression Intensity offers the clarity and detail you need to make informed trading decisions.
Key Features:
📊 Comprehensive Trend Analysis: Utilizes linear regression over customizable periods to assess and quantify trend strength.
🎨 Customizable Appearance: Choose your preferred colors for bullish and bearish trends to align with your trading style.
🔧 Flexible Parameters: Adjust the lookback period, range tolerance, and regression length to tailor the indicator to your specific strategy.
📉 Dynamic Bar Coloring: Instantly visualize trend states with color-coded bars—green for bullish, red for bearish, and gray for neutral.
🏷️ Intensity Labels: Displays dynamic labels that represent the intensity of the current trend, helping you gauge market momentum at a glance.
🔔 Alert Conditions: Set up alerts for strong bullish or bearish trends and trend neutrality to stay ahead of market movements without constant monitoring.
Quick Guide to Using Linear Regression Intensity:
🛠 Add the Indicator: Simply add Linear Regression Intensity to your TradingView chart from your favorites. Customize the settings such as lookback period, range tolerance, and regression length to fit your trading approach.
snapshot
📈 Market Analysis: Observe the color-coded bars to quickly identify the current trend state. Use the intensity labels to understand the strength behind each trend, allowing for more strategic entry and exit points.
snapshot
🔔 Set Up Alerts: Enable alerts for when strong bullish or bearish trends are detected or when the trend reaches a neutral zone. This ensures you never miss critical market movements, even when you’re away from the chart.
snapshot
How It Works:
The Linear Regression Intensity indicator leverages linear regression to calculate the underlying trend of a selected price source over a specified length. By analyzing the consistency of the regression values within a defined lookback period, it determines the trend’s intensity based on a percentage tolerance. The indicator aggregates pairwise comparisons of regression values to assess whether the trend is predominantly upward or downward, assigning a state of bullish, bearish, or neutral accordingly. This state is then visually represented through dynamic bar colors and intensity labels, offering a clear and immediate understanding of market conditions. Additionally, the inclusion of Average True Range (ATR) ensures that the intensity visualization accounts for market volatility, providing a more robust and reliable trend assessment. With customizable settings and alert conditions, Linear Regression Intensity empowers traders to fine-tune their strategies and respond swiftly to evolving market trends.
Elevate your trading strategy with Linear Regression Intensity [AlgoAlpha] and gain unparalleled insights into market trends! 🌟📊
Reference Chart(s)
Chart Description
See image
Parameters
period(int, default=14):source_column(str, default='Close'):
Source / Reference
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlgoAlpha
//@Version=6
indicator("Linear Regression Intensity [AlgoAlpha]", shorttitle="AlgoAlpha - Regression Intensity", overlay=true, max_labels_count = 500)
// Input Groups
group_calc = "Calculation Parameters"
group_appearance = "Appearance Settings"
group_alerts = "Alert Conditions"
// Inputs with Tooltips
n = input.int(12, title="Lookback Period", minval=1, group=group_calc,
tooltip="Number of historical price points to analyze for trend intensity. Higher values provide more comprehensive trend analysis.")
p = input.int(90, title="Range Tolerance", minval=0, maxval=100, group=group_calc,
tooltip="Percentage threshold for determining trend strength. Higher values require more consistent trend alignment.")
linreg_source = input.source(close, title="Linear Regression Source", group=group_calc,
tooltip="Price source used for calculating the linear regression trend.")
linreg_length = input.int(90, title="Linear Regression Length", minval=1, group=group_calc,
tooltip="Number of bars used to calculate the linear regression line. Longer lengths provide a more comprehensive trend view.")
green = input.color(#00ffbb, title="Bullish Color", group=group_appearance,
tooltip="Color representing a strong bullish trend")
red = input.color(#ff1100, title="Bearish Color", group=group_appearance,
tooltip="Color representing a strong bearish trend")
// Linear Regression Calculation
v = ta.linreg(linreg_source, linreg_length, 0)
// Trend Calculation
trend = 0
for i = 0 to n - 2
for j = i + 1 to n - 1
if v[i] != v[j]
trend := trend + (v[i] > v[j] ? 1 : -1)
totalcombos = (n*(n-1))/2
thresh = totalcombos*(p/100)
state = trend > thresh ? 1 : trend < -thresh ? -1 : 0
volatility = ta.atr(14)
// Dynamic Label with Intensity Visualization
label.new(bar_index, close > v ? v - volatility : v + volatility, style = label.style_none, textcolor = color.from_gradient(math.abs(trend)/totalcombos, 0, 1, color.new(trend > 0 ? green : red, 90), color.new(trend > 0 ? green : red, 30)), text = math.abs(trend) == totalcombos ? str.tostring(math.abs(trend)/totalcombos, "#.000000") : str.tostring(math.abs(trend)/totalcombos, "#.######"), force_overlay = true)
// Bar Coloring
barcolor(state == 0 ? color.gray : state == 1 ? green : red, title="Trend State Bar Color")
// Alert Conditions
alertcondition(state == 1, title="Bullish Trend Confirmed", message="Strong Bullish Trend Detected")
alertcondition(state == -1, title="Bearish Trend Confirmed", message="Strong Bearish Trend Detected")
alertcondition(state == 0, title="Trend Neutrality", message="Trend Intensity Reached Neutral Zone")
Expected Output Columns
No response
Deliverables Checklist
- Implementation in
pyindicators/indicators/(pandas + polars support) - Exports in
__init__.pyand__all__ - Unit tests in
tests/indicators/(pandas, polars, edge cases) - Documentation page in
docs/content/indicators/with chart image - Sidebar registration in
docs/sidebars.js - Entry in README.md features list
- Analysis notebook in
analysis/indicators/with plotly chart
Additional Context
No response