OPEN-SOURCE SCRIPT

Price Trendlines + Break Signals

429
█ OVERVIEW
The "Price Trendlines + Break Signals" indicator is a technical analysis tool that automatically draws trendlines based on price pivot points and detects breakout signals. Designed for traders seeking precise market signals, the indicator identifies key pivot points, draws trendlines (resistance and support), and generates breakout signals with background highlighting. It offers flexible settings and alerts for breakout signals.

█ CONCEPTS
The indicator was created to provide traders with an alternative source of signals based on trendlines. Breakouts and bounces from trendlines can signal a trend change or the end of a correction. Combining these signals with other technical analysis tools can form the basis for building diverse trading strategies.

█ FEATURES
-Pivot Point Calculation: The indicator identifies pivot points (pivot high and pivot low) based on the closing price, with configurable left and right bars for pivot detection. Setting a higher number of bars results in fewer but more significant trendlines, with a delay corresponding to the specified length. Lower values generate more trendlines, but they are less significant. Crossovers are signaled only after the trendline is drawn, so sometimes no signals appear on crossed trendlines—this indicates the price passed through the line before it was detected.
- Trendlines: Draws trendlines connecting price pivot points—upper lines for downtrends (resistance) and lower lines for uptrends (support). Lines can be extended by a specified number of bars (default: 50).
- Tolerance Margin: Trendlines are widened by a tolerance margin, calculated using the average candle body size over a specified period and its multiplier. Reducing the multiplier to zero leaves only the trendline without a margin. Breaking this zone is a condition for generating signals.
- Breakout Signals: Generates signals when the price breaks through a trendline (bullish for upper lines, bearish for lower lines), with background highlighting for signal confirmation.

Alerts: Built-in alerts for:
- Upper trendline breakout (bullish signal).
- Lower trendline breakout (bearish signal).
Customization: Allows adjustment of pivot parameters, trendline extension length, tolerance margin, line colors, fills, and signal background transparency.


█ HOW TO USE
Adding the Indicator: Add the indicator to your TradingView chart via the Pine Editor or Indicators menu.

Configuring Settings:
- Left Bars for Pivot: Number of bars back for detecting pivots (default: 10).
- Right Bars for Pivot: Number of bars forward to confirm pivots (default: 10).
- Extend past 2nd pivot: Number of bars to extend the trendline after the second pivot (default: 50, 0 = no extension).
- Average Body Periods: Period for calculating the average candle body size used for the tolerance margin (default: 100).
- Tolerance Multiplier: Multiplier for the tolerance margin based on the average candle body size (default: 1.0).

Colors and Style:
- Upper trendline (resistance): default red.
- Lower trendline (support): default green.
- Line fills: colors with transparency (default 70).
- Signal background: green for bullish signals, red for bearish signals (default transparency 85).

Interpreting Signals:
- Trendlines: Upper lines (red) indicate a downtrend, lower lines (green) indicate an uptrend. Signals appear after a trendline breakout with the tolerance margin. Each trendline generates only one breakout signal, though it may still act as resistance or support for the price.
- Breakout Signals: Green background indicates an upper trendline breakout (bullish), red background indicates a lower trendline breakout (bearish).
- Alerts: Set up alerts in TradingView for trendline breakout signals.
Combining with Other Tools: Use with support/resistance levels, Fibonacci levels, RSI, pivot points, or FVG (Fair Value Gap) for signal confirmation.


█ APPLICATIONS
The "Price Trendlines + Break Signals" indicator is designed to identify trends and potential reversal points, supporting both trend-following and contrarian strategies:

- Trend Confirmation: Trendlines indicate the direction of the price trend, and bounces from them may signal the end of a correction.
- Reversal Strategies: Breakout signals can be used as cues to enter positions in anticipation of a trend change or correction.
- Noise Filtering: The tolerance margin reduces false signals, enhancing reliability.

█ NOTES
- Trendline crossovers are signaled only after the trendline is drawn, so sometimes no signals appear on crossed trendlines—this indicates the price passed through the line before it was detected.
- Each trendline generates only one breakout signal, though it may still act as a level of support or resistance for the price.
- Setting a higher number of bars for pivots results in fewer but more significant trendlines, with a delay corresponding to the specified length. Lower values generate more trendlines, but they are less significant.
- Adjust settings (e.g., number of bars for pivots, tolerance multiplier) to suit your trading style and timeframe.
- Combine with other technical analysis tools, such as RSI, pivot points, or FVG, to enhance signal accuracy.
- For high-volatility markets, consider increasing the tolerance margin to reduce false signals.

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.