1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
190 lines of Pine Script v5 from pinescript/editors_picks/cup-handle.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Cup & Handle Final draws the cup fill, border, and retrace on the price chart. Settings limit how steep the top line may be, how tall the cup may be at the top and bottom, and how many bars may break those lines. Flatten options only change the drawn lines. Optional labels and test lines mark the latest cup and its top points. It does not place trades or manage exits.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
left
int
3
left
right
int
1
right
PP back
int
50
ZZback
% angle
float
22.
prcAngle
% cup Height Top
float
22.
prcOfCupT
max % breaks
float
20.
maxHighs
Flatten
bool
true
flatTop
show test-lines
bool
false
i_shTlin
show test-labels
bool
false
i_shTlab
% cup Height Bot
float
22.
prcOfCupB
max % breaks
float
20.
maxLows
Flatten
bool
true
flatBot
Show all 16 settings
Setting
Type
Default
Variable
show Cup labels
bool
false
i_CupLab
fill
color
color.new(color.yellow, 87)
c_cup
border
color
color.new(color.aqua , 75)
c_bord
retrace
color
color.new( #FF0000 , 80)
c_retr
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
Sideway Zones Live is an overlay indicator that estimates inner and outer sideways bands from recent highs and lows with a rational quadratic kernel. It tracks swing pivots over a loopback period and counts bars that remain between the outer high and low. Afte
This indicator identifies High Of Low Price (HOLP) and Low Of High Price (LOHP) candlestick setups based on price extremes over a specified lookback period. A HOLP signal triggers when the current bar closes above the high of a recent session low, whereas a LO
This indicator plots dynamic support and resistance levels on the price chart. It detects pivot highs and lows using the pivot length and tracks touches to build strength-based levels. Support and resistance zones appear as colored boxes while lines mark key l
This indicator calculates and plots Donchian Channels directly on the price chart. It determines the highest high and lowest low over a user-selected lookback period using an optimized monotonic deque algorithm, as well as a middle basis line computed as their
This indicator tracks bar lows during consecutive rising highs using Pine Script arrays. When at least four lows accumulate or the price breaches the minimum low in the stack, the script sorts the recorded lows in ascending order and flushes them. It plots up
This indicator tracks smart money market structure directly on the price chart. It calculates dual-period swing highs and swing lows to detect Changes of Character (CHoCH), Breaks of Structure (BOS), inducements, and liquidity sweeps. When structural levels ar