Trend Lines

Feb 4, 2020

Static chart image
Support and Resistance
Drawing Tool
Pivot Based (Retrospective)

The Trend Lines indicator automatically identifies and plots dynamic support and resistance levels by connecting consecutive pivot points to highlight market structure shifts.

Usage

The Usage section describes how the script can be used to identify market trends and potential reversal points.

  • Uptrend Identification: When the script detects a Pivot Low (PL) that is higher than the previous Pivot Low, it draws a bullish trend line. This signifies a potential uptrend or a period of ascending support.
  • Downtrend Identification: When the script detects a Pivot High (PH) that is lower than the previous Pivot High, it draws a bearish trend line. This signifies a potential downtrend or a period of descending resistance.
  • Trend Line Management: The script automatically manages active lines based on the angle of the price action. If a new trend line is formed with a steeper angle (indicating a shift in momentum), the script can stop extending the previous line to keep the chart focused on current market conditions.
  • Visualizing History: Users can choose to display historical trend lines as dashed lines, providing a visual record of broken or old market structures while emphasizing the currently active levels.

Details

The script functions by first identifying Pivot Highs and Pivot Lows based on user-defined lookback (Left Bars) and lookforward (Right Bars) periods.

For bearish trend lines, the algorithm checks if the current PH is lower than the previous PH. If this condition is met, a line is drawn connecting them. To maintain clarity, the script compares the angle of the current line with the previous one; if the new angle indicates a stronger trend, the extension of the previous line is terminated.

For bullish trend lines, the algorithm checks if the current PL is higher than the previous PL. If a sequence of higher lows is detected, an uptrend line is generated. Similar to the bearish logic, the script evaluates the slope to determine whether to continue extending old lines or prioritize the most recent structure.

Settings

  • Left Bars: Sets the number of bars required to the left of a high or low to confirm a pivot point.
  • Right Bars: Sets the number of bars required to the right of a high or low to confirm a pivot point.
  • Show Pivot Points: Toggles the visibility of "H" (High) and "L" (Low) labels on the chart.
  • Show Old Line as Dashed: When enabled, previously active trend lines are converted to a dashed style once a new line is formed.
  • Uptrend line color: Defines the color for bullish trend lines connecting higher lows.
  • Downtrend line color: Defines the color for bearish trend lines connecting lower highs.

FAQ

How do I adjust the sensitivity of the trend lines? You can adjust the "Left Bars" and "Right Bars" settings. Lower values will result in more frequent, shorter-term trend lines, while higher values will identify more significant, long-term structural levels.

Why do some trend lines stop extending? The indicator automatically stops extending a line if a new trend line with a more relevant angle is formed, or if the price action dictates that the previous slope is no longer the primary trend.

How can I access this 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.