Trend Lines, Supports and Resistances
May 15, 2024

The Trend Lines, Supports and Resistances indicator provides a comprehensive visual framework for identifying technical market structures, including automated trend line detection and pivot-based support/resistance zones. This tool aims to streamline technical analysis by dynamically mapping key price barriers and trend trajectories directly onto the chart.
Usage
The script automatically detects significant market structures based on pivot points and projects them to assist in trend and breakout analysis.
- Trend Lines: Automatically draws lines connecting pivot highs or lows. These are used to determine market direction and potential reversal zones.
- Support & Resistance: Identifies horizontal zones where price has historically found a floor or ceiling. These zones are visualized as boxes to represent the area between the candle bodies and the wicks.
- Pivot Points: Marks significant high and low points which serve as the foundation for all structural calculations.
- Structure Violations: When a trend line is breached, the indicator can visually update its style (e.g., changing to a dotted line) to signal that the previous trend may be weakening or broken.
Details
The indicator processes historical price action using pivot algorithms to find structural "anchor points." Trend lines are validated based on user-defined parameters for "maximum violations," allowing for a degree of price noise while maintaining the integrity of the line. Support and resistance levels are calculated by examining recent pivot points and drawing rectangular zones that encapsulate the price action at those levels.
The script is built on Pine Script v5/v6, offering optimized performance and visual clarity. It includes logic to filter out insignificant price fluctuations, ensuring that only the most relevant market structures are displayed.
Settings
Pivot Points
- Pivot Length: Sets the number of bars required to confirm a pivot high or low.
- Mark Pivots: Toggles the visual markers for individual pivot points.
- Alerts Enabled: Enables or disables notifications for pivot formations.
Trend Lines
- Points to Check: The number of recent pivot points to evaluate when attempting to form a trend line.
- Maximum Violation: The number of times price is allowed to breach the line before it is considered invalid.
- Excepted Last Bars: Ignores the most recent bars from violation checks to prevent premature invalidation.
- Show Violated Trend Lines: Displays trend lines even after they have been broken, using a distinct style.
- Line Extension: Controls how the lines extend across the chart (None, Left, Right, Both).
Supports & Resistances
- Enabled: Toggles the visibility of S/R zones.
- Points to Check: Determines the lookback period for identifying support and resistance levels.
- Maximum Violation Allowed: Sets the tolerance for price breaching a support or resistance zone.
FAQ
How do I use the trend line alerts?
You can enable alerts within the script settings. Once enabled, use the TradingView Alert dialog to create a new alert for this indicator to get notified when a trend line is breached or a new pivot forms.
Can I customize the colors of the zones?
Yes, the "Style" section of the settings allows you to customize the High Color (Resistance) and Low Color (Support) to match your chart theme.
How do I get access to this tool?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.