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.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。