OPEN-SOURCE SCRIPT

Trend Line Methods (TLM)

166
Trend Line Methods (TLM)

Overview
Trend Line Methods (TLM) is a visual study designed to help traders explore trend structure using two complementary, auto-drawn trend channels. The script focuses on how price interacts with rising or falling boundaries over time. It does not generate trade signals or manage risk; its purpose is to support discretionary chart analysis.

Method 1 – Pivot Span Trendline
The Pivot Span Trendline method builds a dynamic channel from major swing points detected by pivot highs and pivot lows.
• The script tracks a configurable number of recent pivot highs and lows.
• From the oldest and most recent stored pivot highs, it draws an upper trend line.
• From the oldest and most recent stored pivot lows, it draws a lower trend line.
• An optional filled area can be drawn between the two lines to highlight the active trend span.
As new pivots form, the lines are recalculated so that the channel evolves with market structure. This method is useful for visualising how price respects a trend corridor defined directly by swing points.

Method 2 – 5-Point Straight Channel
The 5-Point Straight Channel method approximates a straight trend channel using five key points extracted from a fixed lookback window.
Within the selected window:
• The window is divided into five segments of similar length.
• In each segment, the highest high is used as a representative high point.
• In each segment, the lowest low is used as a representative low point.
• A straight regression-style line is fitted through the five high points to form the upper boundary.
• A second straight line is fitted through the five low points to form the lower boundary.
The result is a pair of straight lines that describe the overall directional channel of price over the chosen window. Compared to Method 1, this approach is less focused on the very latest swings and more on the broader slope of the market.

Inputs & Menus
Pivot Span Trendline group (Method 1)
• Enable Pivot Span Trendline – Turns Method 1 on or off.
• High trend line color / Low trend line color – Colors of the upper and lower trend lines.
• Fill color between trend lines – Base color used to shade the area between the two lines. Transparency is controlled internally.
• Trend line thickness – Line width for both high and low trend lines.
• Trend line style – Line style (solid, dashed, or dotted).
• Pivot Left / Pivot Right – Number of bars to the left and right used to confirm pivot highs and lows. Larger values produce fewer but more significant swing points.
• Pivot Count – How many historical pivot points are kept for constructing the trend lines.
• Lookback Length – Number of bars used to keep pivots in range and to extend the trend lines across the chart.
5-Point Straight Channel group (Method 2)
• Enable 5-Point Straight Channel – Turns Method 2 on or off.
• High channel line color / Low channel line color – Colors of the upper and lower channel lines.
• Channel line thickness – Line width for both channel lines.
• Channel line style – Line style (solid, dashed, or dotted).
• Channel Length (bars) – Lookback window used to divide price into five segments and build the straight high/low channel.

Using Both Methods Together
Both methods are designed to visualise the same underlying idea: price tends to move inside rising or falling channels. Method 1 emphasises the most recent swing structure via pivot points, while Method 2 summarises the broader channel over a fixed window.
When the Pivot Span Trendline corridor and the 5-Point Straight Channel boundaries align or intersect, they can highlight zones where multiple ways of drawing trend lines point to similar support or resistance areas. Traders can use these confluence zones as a visual reference when planning their own entries, exits, or risk levels, according to their personal trading plan.

Notes
• This script is meant as an educational and analytical tool for studying trend lines and channels.
• It does not generate trading signals and does not replace independent analysis or risk management.
• The behaviour of both methods is timeframe- and symbol-agnostic; they will adapt to whichever chart you apply them to.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.