Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=2
- study("Cup and Handle",shorttitle="Cup & Handle Pattern",overlay=true)
- icon = input(false,title="Toggle Icon")
- x1 = close[5] >= close[65] * .95
- x2 = close[5] <= close[65] * 1.05
- x3 = close[5] > close[35] * 1.33
- x4 = close < close[3] * .97
- x0 = x1 and x2 and x3 and x4
- x = x0 and not x0[1]
- //bgcolor(x ? lime:na,transp=0)
- ma = sma(close,20)
- ma5 = sma(close,5)
- dif = sma(close,50) - sma(close,20)
- z1 = ma > ma[1] and ma[1] > ma[2] and ma[2] > ma[3] and ma[3] > ma[4] and ma[4] > ma[5] and ma[5] > ma[6] and ma[6] > ma[7] and ma[7] > ma[8] and ma[8] > ma[9] and ma[9] > ma[10]
- z2 = dif <= lowest(dif,10)
- z3 = sma(close,20) < sma(close,50)
- z4 = ma5 < ma5[1] and ma5[1] < ma5[2] and ma5[2] < ma5[3]
- z0 = z1 and z2 and z3 and z4
- z = z0 and not z0[1]
- //bgcolor(z ? green:na,transp=0)
- //'▲'
- plotshape(z, text='Cup & \n Handle', style=shape.labelup,title="Cup & Handle", location=location.belowbar, color=green, textcolor=white, offset=0)
- y = z or x
- plotchar(icon and y , char='☕ ',location=location.abovebar,title="Icon",color=black,transp=0,size=size.small)
- plotshape(x, text='Big Cup & \n Handle', style=shape.labelup,title="Big Cup & Handle", location=location.belowbar, color=blue, textcolor=white, offset=0)
- //plotchar(x and icon , char='☕ ',location=location.abovebar,color=black,transp=0,size=size.small)
- alertcondition(y, title='Cup & Handle Pattern Formed', message='Cup & Handle Pattern Formed!')
Advertisement
Add Comment
Please, Sign In to add comment