OPEN-SOURCE SCRIPT
Cup with Handle Pattern

Cup with Handle Pattern Indicator – Description
This Cup with Handle Pattern Indicator is designed to visually identify one of the most powerful bullish continuation patterns in technical analysis — the Cup with Handle.
🔍 What It Detects
The indicator scans for the classic "U-shaped" cup formation followed by a slight downward drift (the handle), which often precedes a breakout.
Once a valid pattern is detected, it plots a green triangle below the price bar at the point of breakout — where the price crosses above recent highs after consolidation.
⚙️ Key Features
Customizable Duration: The cup length can be adjusted (default is 150 bars), allowing flexibility based on the timeframe and asset.
Automatic Breakout Detection: The indicator uses a combination of relative highs, lows, and ATR (Average True Range) to ensure valid setups.
No repainting: Signals are plotted only after confirmation, making this suitable for live trading or backtesting.
🛠️ How It Works
Left Cup High: Detected based on historical highs before the low.
Cup Low: The lowest point within the cup duration.
Right Cup High: A recent high before breakout.
Breakout Point: Triggered when price crosses above the 30-bar high after the handle formation.
Validity Checks: Ensures the structure has a proper depth, symmetry, and volatility conditions using ATR.
📊 Visual Elements
Green Triangle Up: Plotted below bar at the breakout.
Blue Line: Closing price.
✅ Ideal For:
Swing traders and position traders looking for high-probability breakout entries.
Chart analysts who want to automate the detection of classic base-building patterns.
Educational and training purposes for pattern recognition.
This Cup with Handle Pattern Indicator is designed to visually identify one of the most powerful bullish continuation patterns in technical analysis — the Cup with Handle.
🔍 What It Detects
The indicator scans for the classic "U-shaped" cup formation followed by a slight downward drift (the handle), which often precedes a breakout.
Once a valid pattern is detected, it plots a green triangle below the price bar at the point of breakout — where the price crosses above recent highs after consolidation.
⚙️ Key Features
Customizable Duration: The cup length can be adjusted (default is 150 bars), allowing flexibility based on the timeframe and asset.
Automatic Breakout Detection: The indicator uses a combination of relative highs, lows, and ATR (Average True Range) to ensure valid setups.
No repainting: Signals are plotted only after confirmation, making this suitable for live trading or backtesting.
🛠️ How It Works
Left Cup High: Detected based on historical highs before the low.
Cup Low: The lowest point within the cup duration.
Right Cup High: A recent high before breakout.
Breakout Point: Triggered when price crosses above the 30-bar high after the handle formation.
Validity Checks: Ensures the structure has a proper depth, symmetry, and volatility conditions using ATR.
📊 Visual Elements
Green Triangle Up: Plotted below bar at the breakout.
Blue Line: Closing price.
✅ Ideal For:
Swing traders and position traders looking for high-probability breakout entries.
Chart analysts who want to automate the detection of classic base-building patterns.
Educational and training purposes for pattern recognition.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.