Auto Trendline Indicator (based on fractals)

Jul 16, 2022

Static chart image
Support and Resistance
Channels
Pivot Based (Retrospective)

The Auto Trendline Indicator indicator automatically identifies and connects recent fractals to project systematic trend lines for price action analysis. This tool eliminates the subjectivity of manual drawing by using a fixed mathematical approach to link pivot highs and lows.

Usage

The Usage section focuses on how the script automates the identification of market structure. By connecting the most recent two fractals of the same type (e.g., two pivot highs), the script projects lines that act as dynamic levels of interest.

  • Market Structure Identification: The script labels High-Highs (HH), Lower-Highs (LH), Higher-Lows (HL), and Lower-Lows (LL). Users can use these labels to determine the current trend direction and potential reversals.
  • Trend Line Projection: Lines are automatically extended from the most recent fractals. These can be configured to extend only to the right or in both directions to see historical significance.
  • Crossing Detection: An optional feature allows the plotting of "X" symbols when the price closes across an active trend line. This is useful for traders looking for trend breakouts or breakdowns.

Details

The script is built upon the concept of Williams Fractals, which represent local price extremes. A fractal is confirmed when a high or low is surrounded by a specific number of lower highs or higher lows on both sides.

Unlike manual trend lines, which are often influenced by trader bias, this tool uses a systematic algorithm:

  1. It identifies the two most recent fractal points.
  2. It calculates the slope between these two points.
  3. It projects a line through these points across the chart.

The "Fractal Market Hypothesis" suggests that price movements exhibit self-similar patterns across different timeframes. While trend lines provide visual references for potential support or resistance, it is important to note that their slope does not inherently predict future price direction.

Settings

Fractals

  • Fractal Period: The number of bars required on either side of a high/low to confirm a fractal. Higher values reduce noise but increase the lag of the trend line formation.
  • Plot HL/LL/LH/HH: Toggles the visibility and colors of the fractal labels on the chart.

Auto trendlines

  • Recent Line: Sets the color and width for the most recently formed trend line.
  • Historical Line: Sets the color and width for previous trend lines.
  • Max pair of lines: Limits the number of historical lines kept on the chart to maintain performance and visual clarity.
  • Which way to extend lines: Determines if the trend line extends to the right or in both directions.
  • Show crosses: When enabled, plots a symbol when the closing price crosses an active trend line.

FAQ

How do I adjust the sensitivity of the trend lines? You can adjust the "Fractal Period" in the settings. A smaller period will detect more frequent, short-term trends, while a larger period will focus on major market swings.

Why does the trend line appear a few bars after the high or low? Fractals require a specific number of bars (defined by the period) to close after the pivot point to confirm it is a local extreme. This confirmation lag is necessary to ensure the point is a valid fractal.

How can I get access to the Auto Trendline Indicator? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free access on the following platforms
tradingviewSymbolTradingView
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

ninjatraderNinjaTrader
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

metatrader4MetaTrader 4/5
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

thinkorswimThinkorswim
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.