PROTECTED SOURCE SCRIPT
Atualizado

AstroTrading_SpecialLevels

68
Overview
This Pine Script™ (version 5) indicator is designed to detect and mark key price levels using pivot points and Fibonacci extensions. It looks back over a user-defined number of bars to identify significant pivot highs and lows, then searches for specific patterns—either a bullish “dip–peak–dip” or a bearish “peak–dip–peak” formation. Once such a pattern is found, the script calculates Fibonacci-based levels (including STOP, Entry, and multiple target levels) and displays them on the chart with horizontal lines and labels.

Key Components
Input Parameters and Setup:

Bars Settings:

left_bars and right_bars define the number of bars to look left and right when calculating pivots.
lookback determines how many bars back (from the current bar) to search for potential pattern points.
Arrays for Pivot Points:
Two sets of arrays are created to store pivot lows and pivot highs along with their corresponding bar indices.

Pivot Point Calculation:

The script calculates pivot lows using ta.pivotlow(left_bars, right_bars) and pivot highs using ta.pivothigh(left_bars, right_bars).
When a valid pivot is detected (i.e. not na), its bar index (adjusted by right_bars) and value are pushed into the respective arrays.
Filtering by Lookback Period:

The code defines a start (bar_index - lookback) and end bar (bar_index - 1) to limit the search for pattern points.
It filters both pivot low and high arrays so that only points within this historical range are considered.
Pattern Detection – Bullish Formation (Dip–Peak–Dip):

The script searches for a sequence where:
Dip1: A pivot low is found.
Peak: A subsequent pivot high occurs after Dip1.
Dip2: A later pivot low occurs after the Peak.
Once these points are identified, it calculates the difference between the peak and the first dip.
It then creates arrays of Fibonacci multipliers ([0.0, 0.382, 0.707, 0.786, 1.618]), corresponding level labels ("STOP", "Entry", "1. Target", "2. Target", "3. Target"), and associated colors.
For each multiplier, the price level is computed using the formula:
priceLevel = dip2 + (peak – dip1) × multiplier
Horizontal lines are drawn at these price levels (extending to the right), and labels are placed to show both the level name and its numeric value.
Pattern Detection – Bearish Formation (Peak–Dip–Peak):

If no bullish sequence is found, the script then looks for the opposite pattern:
Peak1: A pivot high.
Dip: A subsequent pivot low after Peak1.
Peak2: A later pivot high after the Dip.
The difference is computed as:
diff = peak1 – dip
Using the same Fibonacci multipliers and labels, the price level is now calculated as:
priceLevel = peak2 – diff × multiplier
Lines and labels are drawn similarly to indicate STOP, Entry, and multiple target levels.
Fallback:

If neither bullish nor bearish patterns are found within the lookback period, the script creates a label on the chart to inform the user that no valid sequence was detected.
Trading Implications
By identifying these patterns and plotting Fibonacci extension levels, the indicator provides traders with potential areas for:

Stops: Price levels where a reversal might occur.
Entry Points: Levels at which to consider initiating a trade.
Targets: One or more levels for taking profits.
Traders can use these levels in conjunction with other technical analysis tools to help time entries and exits more effectively.

This explanation is written to meet TradingView’s guidelines by clearly detailing each part of the script and its purpose without unnecessary commentary.
Notas de Lançamento
Overview
This Pine Script™ (version 5) indicator is designed to detect and mark key price levels using pivot points and Fibonacci extensions. It looks back over a user-defined number of bars to identify significant pivot highs and lows, then searches for specific patterns—either a bullish “dip–peak–dip” or a bearish “peak–dip–peak” formation. Once such a pattern is found, the script calculates Fibonacci-based levels (including STOP, Entry, and multiple target levels) and displays them on the chart with horizontal lines and labels.

Key Components
Input Parameters and Setup:

Bars Settings:

left_bars and right_bars define the number of bars to look left and right when calculating pivots.
lookback determines how many bars back (from the current bar) to search for potential pattern points.
Arrays for Pivot Points:
Two sets of arrays are created to store pivot lows and pivot highs along with their corresponding bar indices.

Pivot Point Calculation:

The script calculates pivot lows using ta.pivotlow(left_bars, right_bars) and pivot highs using ta.pivothigh(left_bars, right_bars).
When a valid pivot is detected (i.e. not na), its bar index (adjusted by right_bars) and value are pushed into the respective arrays.
Filtering by Lookback Period:

The code defines a start (bar_index - lookback) and end bar (bar_index - 1) to limit the search for pattern points.
It filters both pivot low and high arrays so that only points within this historical range are considered.
Pattern Detection – Bullish Formation (Dip–Peak–Dip):

The script searches for a sequence where:
Dip1: A pivot low is found.
Peak: A subsequent pivot high occurs after Dip1.
Dip2: A later pivot low occurs after the Peak.
Once these points are identified, it calculates the difference between the peak and the first dip.
It then creates arrays of Fibonacci multipliers ([0.0, 0.382, 0.707, 0.786, 1.618]), corresponding level labels ("STOP", "Entry", "1. Target", "2. Target", "3. Target"), and associated colors.
For each multiplier, the price level is computed using the formula:
priceLevel = dip2 + (peak – dip1) × multiplier
Horizontal lines are drawn at these price levels (extending to the right), and labels are placed to show both the level name and its numeric value.
Pattern Detection – Bearish Formation (Peak–Dip–Peak):

If no bullish sequence is found, the script then looks for the opposite pattern:
Peak1: A pivot high.
Dip: A subsequent pivot low after Peak1.
Peak2: A later pivot high after the Dip.
The difference is computed as:
diff = peak1 – dip
Using the same Fibonacci multipliers and labels, the price level is now calculated as:
priceLevel = peak2 – diff × multiplier
Lines and labels are drawn similarly to indicate STOP, Entry, and multiple target levels.
Fallback:

If neither bullish nor bearish patterns are found within the lookback period, the script creates a label on the chart to inform the user that no valid sequence was detected.
Trading Implications
By identifying these patterns and plotting Fibonacci extension levels, the indicator provides traders with potential areas for:

Stops: Price levels where a reversal might occur.
Entry Points: Levels at which to consider initiating a trade.
Targets: One or more levels for taking profits.
Traders can use these levels in conjunction with other technical analysis tools to help time entries and exits more effectively.

This explanation is written to meet TradingView’s guidelines by clearly detailing each part of the script and its purpose without unnecessary commentary.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.