OPEN-SOURCE SCRIPT

Trend Breakout

518
Description:
This Pine Script indicator identifies pivot high and pivot low points based on user-defined left and right candle legs, detecting breakouts to signal potential trend changes. It plots horizontal lines at pivot highs (lime) and pivot lows (red), marking breakout signals with labels ("Br") when the price crosses above a pivot high or below a pivot low. The indicator also changes the background color to reflect the trend (green for uptrend, red for downtrend) with adjustable transparency. The indicator primarily focuses on recognizing specific pivot patterns to define trends and generate trading signals.

How It Works
• Pivot Detection: Identifies pivot highs and lows using configurable left (Left side Pivot Candle) and right (Right side Pivot Candle) periods.
• Pivot Highs (PH): A pivot high is identified when a candle's high is greater than a specified number of preceding candles (left leg) and succeeding candles (right leg).
• Pivot Lows (PL): Similarly, a pivot low is identified when a candle's low is less than a specified number of preceding and succeeding candles.
The script then tracks the last three pivot highs and pivot lows.
Trend Detection and Breakouts

1. High Line (Resistance): When a middle pivot high (out of the three tracked) is higher than both the previous and the next pivot high, a lime green line is drawn from that pivot high. This line acts as a dynamic resistance level.

2. Low Line (Support): Conversely, when a middle pivot low is lower than both the previous and the next pivot low, a red line is drawn from that pivot low. This line acts as a dynamic support level.
________________________________________
Trading Signals : The indicator generates signals based on price crossing these dynamically drawn lines .
• Long Signal (Uptrend):
o A "Long" signal is triggered when the close price crosses above the current high line (resistance), and the indicator is not already in an uptrend.
o When a long signal occurs, the background turns green, and the high line becomes dotted and thinner. A "Br" (Breakout) label appears below the candle.
• Short Signal (Downtrend):
o A "Short" signal is triggered when the close price crosses below the current low line (support), and the indicator is not already in a downtrend.
o When a short signal occurs, the background turns red, and the low line becomes dotted and thinner. A "Br" (Breakout) label appears above the candle.
________________________________________
Customizable Settings
The indicator provides three user-adjustable inputs:
• Right Side Pivot Candle (fpivotLeg): This setting (default 10) determines the number of candles to the right that must have lower highs/higher lows for a pivot to be confirmed.
• Left Side Pivot Candle (bpivotLeg): This setting (default 15) determines the number of candles to the left that must have lower highs/higher lows for a pivot to be confirmed.
• Adjust Color Visualization (Colortrnp): This setting (default 85) controls the transparency of the background color changes, allowing you to adjust how prominently the green (uptrend) and red (downtrend) backgrounds are displayed.
________________________________________
How to Use It
This indicator can be used by traders to:
• Identify potential reversals: The formation of new pivot highs and lows can signal shifts in market direction.
• Spot breakout opportunities: Crossing above the high line or below the low line can indicate the start of a new trend or the continuation of an existing one.
• Confirm trend strength: The presence and extension of the high and low lines can provide visual cues about the prevailing trend.
• Ideal for swing traders or trend-following strategies.
• Use the breakout labels ("Br") and background color to confirm trend direction.
• Adjust pivot leg inputs to fine-tune sensitivity for different timeframes or assets.
• Customize transparency to suit chart readability.

Example:
On a breakout above a pivot high, a green "Br" label appears, the background turns green, and the pivot line becomes dotted. This signals a potential uptrend, helping traders identify entry points or trend confirmations.

Disclaimer: No indicator guarantees profits. Always use this indicator in conjunction with other analysis methods and proper risk management.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.