AnthonyAlexander

Cup & Handle Pattern Completed

Jan 1st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. //@version=2
  2. study("Cup and Handle",shorttitle="Cup & Handle Pattern",overlay=true)
  3. icon = input(false,title="Toggle Icon")
  4. x1 = close[5] >= close[65] * .95
  5. x2 = close[5] <= close[65] * 1.05
  6. x3 = close[5] > close[35] * 1.33
  7. x4 = close < close[3] * .97
  8.  
  9. x0 = x1 and x2 and x3 and x4
  10. x = x0 and not x0[1]
  11. //bgcolor(x ? lime:na,transp=0)
  12.  
  13. ma = sma(close,20)
  14. ma5 = sma(close,5)
  15. dif = sma(close,50) - sma(close,20)
  16.  
  17. 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]
  18. z2 = dif <= lowest(dif,10)
  19. z3 = sma(close,20) < sma(close,50)
  20. z4 = ma5 < ma5[1] and ma5[1] < ma5[2] and ma5[2] < ma5[3]
  21. z0 = z1 and z2 and z3 and z4
  22. z = z0 and not z0[1]
  23. //bgcolor(z ? green:na,transp=0)
  24. //'▲'
  25. plotshape(z, text='Cup & \n Handle', style=shape.labelup,title="Cup & Handle", location=location.belowbar, color=green, textcolor=white, offset=0)
  26. y = z or x
  27. plotchar(icon and y , char='☕ ',location=location.abovebar,title="Icon",color=black,transp=0,size=size.small)
  28.  
  29. plotshape(x, text='Big Cup & \n Handle', style=shape.labelup,title="Big Cup & Handle", location=location.belowbar, color=blue, textcolor=white, offset=0)
  30.  
  31. //plotchar(x and icon , char='☕ ',location=location.abovebar,color=black,transp=0,size=size.small)
  32.  
  33. alertcondition(y, title='Cup & Handle Pattern Formed', message='Cup & Handle Pattern Formed!')
Advertisement
Add Comment
Please, Sign In to add comment