OPEN-SOURCE SCRIPT

Auto TrendLines [TradingFinder] Support Resistance Signal Alerts

12 610
🔵Introduction

The trendline is one of the most essential tools in technical analysis, widely used in financial markets such as Forex, cryptocurrency, and stocks. A trendline is a straight line that connects swing highs or swing lows and visually indicates the market’s trend direction.

Traders use trendlines to identify price structure, the strength of buyers and sellers, dynamic support and resistance zones, and optimal entry and exit points.

In technical analysis, trendlines are typically classified into three categories: uptrend lines (drawn by connecting higher lows), downtrend lines (formed by connecting lower highs), and sideways trends (moving horizontally). A valid trendline usually requires at least three confirmed touchpoints to be considered reliable for trading decisions.

Trendlines can serve as the foundation for a variety of trading strategies, such as the trendline bounce strategy, valid breakout setups, and confluence-based analysis with other tools like candlestick patterns, divergences, moving averages, and Fibonacci levels.

Additionally, trendlines are categorized into internal and external, and further into major and minor levels, each serving unique roles in market structure analysis.

snapshot


🔵How to Use

Trendlines are a key component in technical analysis, used to identify market direction, define dynamic support and resistance zones, highlight strategic entry and exit points, and manage risk. For a trendline to be reliable, it must be drawn based on structural principles—not by simply connecting two arbitrary points.

snapshot


🟣Selecting Pivot Types Based on Trend Direction

The first step is to determine the market trend: uptrend, downtrend, or sideways.

Then, choose pivot points that match the trend type:

  • In an uptrend, trendlines are drawn by connecting low pivots, especially higher lows.
  • In a downtrend, trendlines are formed by connecting high pivots, specifically lower highs.


It is crucial to connect pivots of the same type and structure to ensure the trendline is valid and analytically sound.

snapshot


🟣Pivot Classification

This indicator automatically classifies pivot points into two categories:

Major Pivots:

  • MLL: Major Lower Low
  • MHL: Major Higher Low
  • MHH: Major Higher High
  • MLH: Major Lower High


These define the primary structure of the market and are typically used in broader structural analysis.

Minor Pivots:

  • mLL: minor Lower Low
  • mHL: minor Higher Low
  • mHH: minor Higher High
  • mLH: minor Lower High


These are used for drawing more precise trendlines within corrective waves or internal price movements.

Example: In a downtrend, drawing a trendline from an MHH to an mHH creates structural inconsistency and introduces noise. Instead, connect points like MHL to MHL or mLH to mLH for a valid trendline.

snapshot

🟣Drawing High-Precision Trendlines

To ensure a reliable trendline:

  • Use pivots of the same classification (Major with Major or Minor with Minor).
  • Ensure at least three valid contact points (three touches = structural confirmation).
  • Draw through candles with the least deviation (choose wicks or bodies based on confluence).
  • Preferably draw from right to left for better alignment with current market behavior.
  • Use parallel lines to turn a single trendline into a trendline zone, if needed.


snapshot

🟣Using Trendlines for Trade Entries

  • Bounce Entry: When price approaches the trendline and shows signs of reversal (e.g., a reversal candle, divergence, or support/resistance), enter in the direction of the trend with a logical stop-loss.
  • Breakout Entry: When price breaks through the trendline with strong momentum and a confirmation (such as a retest or break of structure), consider trading in the direction of the breakout.


snapshot

🟣Trendline-Based Risk Management

  • For bounce entries, the stop-loss is placed below the trendline or the last pivot low (in an uptrend).
  • For breakout entries, the stop-loss is set behind the breakout candle or the last structural level.


A broken trendline can also act as an exit signal from a trade.

🟣Combining Trendlines with Other Tools (Confluence)

Trendlines gain much more strength when used alongside other analytical tools:

  • Horizontal support and resistance levels
  • Moving averages (such as EMA 50 or EMA 200)
  • Fibonacci retracement zones
  • Candlestick patterns (e.g., Engulfing, Pin Bar)
  • RSI or MACD divergences
  • Market structure breaks (BoS / ChoCH)


snapshot

🔵Settings

Pivot Period: This defines how sensitive the pivot detection is. A higher number means the algorithm will identify more significant pivot points, resulting in longer-term trendlines.
Alerts

Alert:

  • Enable or disable the entire alert system
  • Set a custom alert name
  • Choose how often alerts trigger (every time, once per bar, or on bar close)
  • Select the time zone for alert timestamps (e.g., UTC)


Each trendline type supports two alert types:

  • Break Alert: Triggered when price breaks the trendline
  • React Alert: Triggered when price reacts or bounces off the trendline


These alerts can be independently enabled or disabled for all trendline categories (Major/Minor, Internal/External, Up/Down).

Display:

For each of the eight trendline types, you can control:

  • Whether to show or hide the line
  • Whether to delete the previous line when a new one is drawn
  • Color, line style (solid, dashed, dotted), extension direction (e.g., right only), and width


Major lines are typically thicker and more opaque, while minor lines appear thinner and more transparent.

All settings are designed to give the user full control over the appearance, behavior, and alert system of the indicator, without requiring manual drawing or adjustments.

🔵Conclusion

A trendline is more than just a line on the chart—it is a structural, strategic, and flexible tool in technical analysis that can serve as the foundation for understanding price behavior and making trading decisions. Whether in trending markets or during corrections, trendlines help traders identify market direction, key zones, and high-potential entry and exit points with precision.

The accuracy and effectiveness of a trendline depend on using structurally valid pivot points and adhering to proper market logic, rather than relying on guesswork or personal bias.

This indicator is built to solve that exact problem. It automatically detects and draws multiple types of trendlines based on actual price structure, separating them into Major/Minor and Internal/External categories, and respecting professional analytical principles such as pivot type, trend direction, and structural location.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.