OPEN-SOURCE SCRIPT
Automated Trendline Breakout Engine

Overview
**Automated Trendline Breakout Engine ** automatically detects swing highs and swing lows to build dynamic support and resistance trendlines. The indicator continuously updates these trendlines as new pivots form and generates BUY and SELL signals whenever price breaks above resistance or below support.
The script is designed to provide traders with an objective method of identifying trendline breakouts without manually drawing trendlines.
Features
* Automatic swing high and swing low detection
* Dynamic resistance trendlines
* Dynamic support trendlines
* Real-time breakout detection
* BUY signals when price breaks above resistance
* SELL signals when price breaks below support
* Broken trendlines automatically change to dashed style
* Customizable swing length
* Customizable trendline colors
* Optional signal display
How It Works
1. Swing Detection
The indicator identifies pivot highs and pivot lows using the selected **Trendline Swing Length**.
Higher values:
* Detect stronger market swings
* Produce fewer but more reliable trendlines
Lower values:
* Detect more swings
* Generate more frequent signals
2. Trendline Construction
Resistance trendlines connect the two most recent pivot highs.
Support trendlines connect the two most recent pivot lows.
Only the latest valid trendline of each type is displayed.
3. Breakout Logic
A BUY signal is generated when:
* Price closes above the active resistance trendline
* Previous candle closed below or on the trendline
* The trendline has not already been broken
A SELL signal is generated when:
* Price closes below the active support trendline
* Previous candle closed above or on the trendline
* The trendline has not already been broken
Once broken, the trendline changes to a dashed line to indicate it has already produced its breakout signal.
Inputs
Trendline Swing Length
Controls pivot sensitivity.
Recommended values:
* 5–8 : Short-term trading
* 10–15 : Swing trading
* 20+ : Position trading
Show Trendline Breakout Signals
Enable or disable BUY/SELL labels.
Trendline Colors
Customize the appearance of:
* Resistance trendlines
* Support trendlines
Best Used On
Works well on:
* Stocks
* Forex
* Crypto
* Commodities
* Indices
Suitable for:
* 15 Minute
* 1 Hour
* 4 Hour
* Daily
Tips
For better accuracy, combine this indicator with:
* Volume confirmation
* Moving averages
* RSI
* MACD
* Higher timeframe trend analysis
* Support and resistance zones
Avoid trading every breakout without confirmation, especially during low-volatility or ranging markets.
Limitations
* Trendlines are based on confirmed pivot points, so they appear only after the required number of bars has completed.
* Breakout signals are generated after pivot confirmation, not before.
* False breakouts can occur in sideways markets.
* This indicator does not predict future price movement; it only reacts to confirmed price action.
Version Notes
Fixed version improvements:
* Accurate trendline price calculation using `line.get_price()`
* Reliable breakout detection
* Prevention of duplicate breakout signals
* Automatic dashed styling for broken trendlines
* Cleaner trendline management
Disclaimer
This indicator is provided for educational and informational purposes only. It should not be considered financial or investment advice. Always perform your own analysis and use proper risk management before making trading decisions.
**Automated Trendline Breakout Engine ** automatically detects swing highs and swing lows to build dynamic support and resistance trendlines. The indicator continuously updates these trendlines as new pivots form and generates BUY and SELL signals whenever price breaks above resistance or below support.
The script is designed to provide traders with an objective method of identifying trendline breakouts without manually drawing trendlines.
Features
* Automatic swing high and swing low detection
* Dynamic resistance trendlines
* Dynamic support trendlines
* Real-time breakout detection
* BUY signals when price breaks above resistance
* SELL signals when price breaks below support
* Broken trendlines automatically change to dashed style
* Customizable swing length
* Customizable trendline colors
* Optional signal display
How It Works
1. Swing Detection
The indicator identifies pivot highs and pivot lows using the selected **Trendline Swing Length**.
Higher values:
* Detect stronger market swings
* Produce fewer but more reliable trendlines
Lower values:
* Detect more swings
* Generate more frequent signals
2. Trendline Construction
Resistance trendlines connect the two most recent pivot highs.
Support trendlines connect the two most recent pivot lows.
Only the latest valid trendline of each type is displayed.
3. Breakout Logic
A BUY signal is generated when:
* Price closes above the active resistance trendline
* Previous candle closed below or on the trendline
* The trendline has not already been broken
A SELL signal is generated when:
* Price closes below the active support trendline
* Previous candle closed above or on the trendline
* The trendline has not already been broken
Once broken, the trendline changes to a dashed line to indicate it has already produced its breakout signal.
Inputs
Trendline Swing Length
Controls pivot sensitivity.
Recommended values:
* 5–8 : Short-term trading
* 10–15 : Swing trading
* 20+ : Position trading
Show Trendline Breakout Signals
Enable or disable BUY/SELL labels.
Trendline Colors
Customize the appearance of:
* Resistance trendlines
* Support trendlines
Best Used On
Works well on:
* Stocks
* Forex
* Crypto
* Commodities
* Indices
Suitable for:
* 15 Minute
* 1 Hour
* 4 Hour
* Daily
Tips
For better accuracy, combine this indicator with:
* Volume confirmation
* Moving averages
* RSI
* MACD
* Higher timeframe trend analysis
* Support and resistance zones
Avoid trading every breakout without confirmation, especially during low-volatility or ranging markets.
Limitations
* Trendlines are based on confirmed pivot points, so they appear only after the required number of bars has completed.
* Breakout signals are generated after pivot confirmation, not before.
* False breakouts can occur in sideways markets.
* This indicator does not predict future price movement; it only reacts to confirmed price action.
Version Notes
Fixed version improvements:
* Accurate trendline price calculation using `line.get_price()`
* Reliable breakout detection
* Prevention of duplicate breakout signals
* Automatic dashed styling for broken trendlines
* Cleaner trendline management
Disclaimer
This indicator is provided for educational and informational purposes only. It should not be considered financial or investment advice. Always perform your own analysis and use proper risk management before making trading decisions.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.