Trend Line
Sep 1, 2020

The Trend Line indicator automatically plots dynamic support and resistance levels based on fractal price points to help traders identify market structure and potential breakout zones.
Usage
The Usage section describes how the script can be used to identify key pivot points and trend trajectories. This tool is primarily used to visualize market defense lines where price action historically reacts.
- Trend Identification: By connecting fractal highs (top lines) and fractal lows (bottom lines), the script visualizes the slope of the current market direction.
- Support and Resistance: The generated lines act as dynamic levels. A price crossover or crossunder of these lines can signal a shift in momentum or a potential trend reversal.
- Visual Filtering: The indicator includes logic to manage line visibility. If the price deviates significantly from a line (determined by the price change ratio), the line may become dotted or be removed to maintain chart clarity and relevance.
Details
The script utilizes fractal geometry to determine pivot points. It identifies local maxima and minima within a user-defined period to establish the anchor points for the trend lines.
- Angle Calculation: The script calculates the mathematical angle between fractal points to determine the most significant trend trajectory.
- Line Management: To prevent chart clutter, the script includes an automated cleanup routine that deletes lines that are too short or have become too distant from the current price action.
- Dynamic Scaling: The tool adjusts its internal calculations based on the timeframe (seconds, minutes, days, etc.) to ensure consistent line placement across different chart resolutions.
Settings
The indicator includes several customizable parameters to tune the sensitivity and appearance of the trend lines:
- Bars Limit: Sets the historical lookback window (in bars) for the indicator's calculations.
- Segment Range: Determines the range used to look for connecting fractal points to form a line.
- Fractals Period: Defines the number of bars used to detect high and low fractal points.
- Ray Style: Controls the extension of the trend lines (None, Left, Right, or Both).
- Color Top Line: Sets the color for trend lines connecting fractal highs.
- Color Bottom Line: Sets the color for trend lines connecting fractal lows.
FAQ
How do I interpret dotted lines versus solid lines? Solid lines represent trend lines that are currently close to the price action. Lines become dotted when the price gap increases significantly, suggesting the level may be losing immediate relevance.
Can I use this for automated alerts? Yes, the script includes built-in alert conditions for price crossovers and crossunders of both top and bottom trend lines.
How can I access the Trend Line indicator? 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.