OPEN-SOURCE SCRIPT

Advanced Pattern Detector

**Script Overview**

**Indicator Name:** Advanced Pattern Detector

**Pine Script Version:** v5

**Indicator Type:** Overlaid on the chart (overlay=true)

**Main Features:**

- Detection and visualization of various technical patterns.
- Generation of BUY and SELL signals based on detected patterns.
- Display of Fibonacci levels to identify potential support and resistance levels.
- Ability to enable or disable each pattern through the indicator settings.

---

**Indicator Settings**

**Switches to Enable/Disable Patterns**

At the top of the indicator, there are parameters that allow the user to select which patterns will be displayed on the chart:

- Three Drives
- Rounding Top
- Rounding Bottom
- ZigZag Pattern
- Inverse Head and Shoulders
- Fibonacci Retracement

**Parameters for ZigZag**

Settings are also available for the ZigZag pattern, such as the depth of peak and trough detection, allowing the user to adjust the indicator's sensitivity to price changes.

---

**Pattern Detection**

Each pattern is implemented with its own logic, which checks specific conditions on the current bar (candle). Below are the main patterns:

1. **Three Drives**
- **Description:** This pattern consists of three consecutive price movements in one direction (up or down). It can signal the continuation of the current trend or its reversal.
- **How It Works:**
- **Upward Drive:** The indicator checks that the closing price of each subsequent candle is higher than the previous one for three bars.
- **Downward Drive:** The indicator checks that the closing price of each subsequent candle is lower than the previous one for three bars.

2. **Rounding Top**
- **Description:** A pattern representing a smooth decrease in maximum prices over several bars, which may indicate a potential downward trend reversal.
- **How It Works:**
- The indicator checks that the maximum prices of the last five bars are gradually decreasing, and the current bar shows a decrease in the maximum price.

3. **Rounding Bottom**
- **Description:** A pattern characterized by a smooth increase in minimum prices over several bars, signaling a possible upward trend reversal.
- **How It Works:**
- The indicator checks that the minimum prices of the last five bars are gradually increasing, and the current bar shows an increase in the minimum price.

4. **ZigZag Pattern**
- **Description:** Used to identify corrective movements on the chart. The pattern shows peak and trough points connected by lines, helping to visualize the main price movement.
- **How It Works:**
- The indicator uses a function to determine local maxima and minima based on the specified depth.
- Detected peaks and troughs are connected by lines to create a visual zigzag structure.

5. **Inverse Head and Shoulders**
- **Description:** An inverted head and shoulders formation signals a possible reversal of a downward trend to an upward one.
- **How It Works:**
- The indicator looks for three local minima: the left shoulder, the head (the lowest minimum), and the right shoulder.
- It checks that the left and right shoulders are approximately at the same level and below the head.

6. **Fibonacci Retracement Levels**
- **Description:** Automatically builds key Fibonacci levels based on the maximum and minimum prices over the last 50 bars. These levels are often used as potential support and resistance levels.
- **How It Works:**
- Daily, the minimum and maximum prices over the last 50 bars are calculated.
- Based on these values, Fibonacci levels are drawn: 100%, 23.6%, 38.2%, 50%, 61.8%, and 0%.
- Old levels are removed when a new day begins to keep the chart clean and up-to-date.

---

**Generation of Buy and Sell Signals**

The indicator combines the results of detected patterns to generate trading signals:

- **Buy Signals (BUY):**
- Rounding Bottom
- Three Drives Up
- Inverse Head and Shoulders
- ZigZag Low

- **Sell Signals (SELL):**
- Rounding Top
- Three Drives Down
- Inverse Head and Shoulders
- ZigZag High

**How It Works:**

- If one or more buy conditions are met, a "BUY" label is displayed below the corresponding bar on the chart.
- If one or more sell conditions are met, a "SELL" label is displayed above the corresponding bar on the chart.

---

**Visualization of Patterns on the Chart**

Each detected pattern is visualized using various graphical elements, allowing traders to easily identify them on the chart:

- **Three Drives Up:** Green upward triangle below the bar.
- **Three Drives Down:** Red downward triangle above the bar.
- **Rounding Top:** Orange "RT" label above the bar.
- **Rounding Bottom:** Blue "RB" label below the bar.
- **Inverse Head and Shoulders:** Turquoise "iH&S" label below the bar.
- **ZigZag High/Low:** Purple circles at the peaks and troughs of the zigzag.

---

**Displaying Fibonacci Levels**

Fibonacci levels are displayed as horizontal lines on the chart with corresponding labels. These levels help traders determine potential entry and exit points, as well as support and resistance levels.

---

**Drawing ZigZag Lines**

ZigZag lines connect the detected peaks and troughs, visualizing corrective movements. To avoid cluttering the chart, the number of lines is limited, and old lines are automatically removed as new ones are added.
Candlestick analysisChart patternsforecastingpatternssignals

Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının yazarı komut dosyasını açık kaynak olarak yayınlamıştır, böylece yatırımcılar betiği anlayabilir ve doğrulayabilir. Yazar çok yaşa! Ücretsiz olarak kullanabilirsiniz, ancak bu kodun yayında yeniden kullanımı Ev kurallarına tabidir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?

Feragatname