OPEN-SOURCE SCRIPT

Trendline Breakout Indicator [Dots3Red]

8 385
Trendline Breakout Indicator is an upgraded version of the existing "Trendline Breakout with Volume Confirmation [Dots3Red]".

What is this indicator for?
The indicator is built to automatically detect and visualize trending price channels, both bullish and bearish. It draws channels (or polygons, optionally) across pivot-based trendlines, tracks them in real time, and signals when price breaks out of them with a certain N% (can be confirmed by volume activity too).

How does it work?
The indicator identifies pivot highs and lows of a configurable length. Consecutive pivots of the same type (lows for bullish, highs for bearish) form a trendline. Each trendline is then extended bar by bar until the price breaks it.
Channel mode draws a parallel channel around the trendline, where the channel width is determined by the maximum price deviation from the trendline within the channel's range - not a fixed offset. This means every channel is fitted to actual price behavior.
Polygon mode instead fills the area between the trendline and the extreme price reached within it, giving a triangular wedge shape that highlights price compression.
Channels are color-coded: cyan/teal for bullish, red/pink for bearish.

Breakout Detection
A breakout is confirmed when:
  • For bullish channels: price closes below the lower trendline by more than the configured Breakout %
  • For bearish channels: price closes above the upper trendline by more than the configured Breakout %

When a breakout occurs, the channel is frozen and drawn at its final shape. A BO▲ / BO▼ label marks the breakout bar.
Only channels that have persisted for at least the configured minimum length (in bars) are drawn - this filters out insignificant short-lived moves

Volume Confirmation
Volume is measured relative to its 20-bar moving average. When volume at the breakout bar exceeds the Volume % Breakout threshold, a bar visualization is drawn at the breakout point.

Key Inputs
  • Channel / Polygon - Switch between channel and polygon visualization mode
  • Breakout % - How far price must close beyond the trendline to confirm a breakout
  • Slope Factor - Minimum slope required for a trendline to be considered a valid trend
  • Pivot Length - Lookback length for pivot high/low detection
  • Channel Min Length - Minimum bar length a channel must reach before being drawn
  • Volume % Breakout - Volume spike threshold relative to the 20-bar average (can be toggle on/off)

The code has been cleaned so as not to contain duplicate execution functions.

Example
สแนปชอต
Above is the Trendline analysis of the Nvidia stock behaviour.
The following configurable parameters have been chosen:
  • 2.5% for price break out
  • 1.02 for slope factor
  • 3 for Pivot length
  • 20 for min channel's length
  • 30% for min volume % breakout indicaton

It is interesting to observe what happens when two opposite channels overlap. From Jan 2025 to mid May 2025, the stock was in a clear bearish channel, yet a bullish channel started to develop since April 2025. The bearish channel got broken on May 13, 2025, at the time when the bullish channel had already been established - a more powerful signal to enter long.

Changing indicator settings might give different visual interpretations, especially the slope factor and the minimum pivot length.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน