Trend Lines v2

Mar 18, 2020

Static chart image
Support and Resistance
Signals
Drawing Tool

The Trend Lines v2 indicator automatically identifies and draws significant support and resistance trend lines by connecting historical pivot points to highlight potential price reversals and breakouts.

Usage

The Usage section describes how the script can be used to identify market structure. The tool automatically scans for the most recent Pivot Highs and Pivot Lows to construct trend lines that have not yet been breached by price action.

  • Bullish Trend Lines: The indicator identifies a series of higher pivot lows and connects them to form an ascending support line. These are colored green by default and suggest areas where buying pressure may emerge.
  • Bearish Trend Lines: The indicator identifies lower pivot highs and connects them to form a descending resistance line. These are colored red by default and suggest areas where selling pressure may reside.
  • Breakout Detection: The script monitors real-time price action against these lines. If a candle closes across a line, it is considered "broken," and the script can trigger alerts to notify the user of a potential trend shift.

Details

The script operates by storing the last several Pivot Points (PP) in arrays. For every new bar, it executes a search algorithm that attempts to draw a line from the most recent pivot point back through previous pivots.

The calculation follows these steps:

  1. Pivot Identification: It finds the last 10 (or user-defined) Higher and Lower Pivot Points based on the "Pivot Period" setting.
  2. Validity Check: For each potential line, the script iterates through every bar between the pivot points to ensure no price data has "broken" the line. A line is only considered valid if the price has remained above (for support) or below (for resistance) the projected slope.
  3. Optimization: To maintain performance and stay within execution time limits, the script stops searching once a valid continuous trend line is found for a specific pivot.
  4. Slope Calculation: The slope is determined by the price difference between the two chosen pivot points divided by the time distance (bar index) between them.

Settings

  • Start Year/Month/Day: Defines the starting point on the historical chart where the indicator begins its calculations.
  • Pivot Period: Determines the lookback and lookforward period used to identify a pivot point. A higher value results in more significant, longer-term trend lines, while a lower value identifies shorter-term trends.
  • Number of Pivot Points to check: Sets how many historical pivot points the script evaluates to find a valid trend line connection.
  • Up Trend Color: Sets the color for ascending support trend lines.
  • Down Trend Color: Sets the color for descending resistance trend lines.

FAQ

How do I adjust the indicator if the chart looks too crowded? You can increase the "Pivot Period" setting to focus on more significant market turns or reduce the "Number of Pivot Points to check" to limit the quantity of lines being calculated.

Why are there no trend lines appearing on my current view? If no lines are visible, it likely means the current price action has broken all recently identified lines. Try adjusting the "Pivot Period" to a different value to capture different market cycles.

How can I get access to the Trend Lines v2 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
ninjatraderNinjaTrader
metatrader4MetaTrader 4/5
thinkorswimThinkorswim

Unlock Unlimited Access to the LuxAlgo Library

Upgrade your plan to get all indicators, strategies, charts, and full access to Quant, our AI agent.

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.