Auto Trendlines
May 5, 2026

The Auto Trendlines indicator automatically detects and plots diagonal trendlines based on pivot highs and lows to identify dynamic support and resistance levels. It provides a visual framework for understanding market structure by connecting significant price points and projecting potential future trend paths.
Usage
The Usage section describes how the script can be used to identify market trends and potential reversal points. The indicator classifies trendlines into two categories:
- Bullish (Support): Connects ascending pivot lows. Price bouncing off these lines indicates a higher probability of trend continuation, while a close below may signal a weakening uptrend.
- Bearish (Resistance): Connects descending pivot highs. Rejections at these lines suggest downward pressure, whereas a close above may indicate a potential breakout or trend shift.
The script uses a multi-length system (L1 and L2) to track short-term and long-term structures simultaneously. Confirmed segments are displayed as solid lines, while projected extensions appear as dotted lines, allowing traders to anticipate where price might interact with the trend in the future.
Details
The script utilizes a specific construction logic to ensure clean visual output and structural relevance:
- Anchor Replacement: This feature automatically refines the starting points of trendlines. If a raw pivot connection results in a line cutting through price action, the script searches for a more extreme anchor to ensure the trendline remains technically valid.
- Angle Filtering: To reduce market noise, the indicator calculates the geometric angle of each trendline. Lines that are too flat (sideways) or too steep (unsustainable) can be filtered out based on user-defined degree thresholds.
- Dynamic Glow: A multi-layered linefill system creates a visual "glow" around the trendlines, representing a zone of influence rather than a singular price point.
Settings
Trendlines
- Show Trendlines: Toggles the visibility of all trendline structures.
- Bullish Color: Sets the color for ascending support lines.
- Bearish Color: Sets the color for descending resistance lines.
Lengths
- Show L1 / Length 1: Enables and defines the pivot lookback period for short-term trend detection.
- Show L2 / Length 2: Enables and defines the pivot lookback period for long-term trend detection.
Detection
- Anchor Replacement: When enabled, automatically adjusts trendline origins to prevent them from intersecting candle bodies.
- Future Extension Bars: Determines the horizontal length of the dotted projected trendlines.
- Break Bars Limit: Sets the number of bars a trendline remains visible on the chart after it has been price-broken.
Angle Filter
- Use Angle Filter: Toggles the removal of trendlines based on their steepness.
- Min Angle / Max Angle: Defines the specific degree range for trendlines to be considered valid.
Debug
- Show Angle Label: Displays the numerical angle at the start of each line, assisting in the calibration of the Angle Filter.
FAQ
How do I adjust the sensitivity of the trendline detection? You can modify the "Length" settings in the Lengths group; smaller values detect more frequent, short-term trends, while larger values focus on major macro structures.
What causes a trendline to disappear or change? Trendlines are based on dynamic pivots; if the "Break Bars Limit" is reached after price crosses a line, or if a new, more relevant pivot is formed that replaces the current structure, the lines will update.
How can I access the Auto Trendlines 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.