Advertisement
xmd79

Reversal picker

Jan 10th, 2023
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © Gudanin
  3.  
  4. //@version=5
  5. indicator("Reversal picker", overlay = true)
  6.  
  7.  
  8. //line variables
  9.  
  10. line1 = ta.sma(close, 14)
  11. line2 = ta.sma(close, 200)
  12. highrsi = ta.rsi(close,14) > 50
  13. lowrsi = ta.rsi(close,14) < 50
  14.  
  15.  
  16. line11 = ta.sma(close, 19)
  17. line22 = ta.sma(close, 21)
  18.  
  19. highrsi1 = ta.rsi(close,14) >= 65
  20. lowrsi1 = ta.rsi(close,14) <= 35
  21.  
  22.  
  23. //Reversal logic
  24.  
  25. BuyP= line11 > line22 and highrsi1 and line1 > line2 and highrsi
  26.  
  27. var label up = na
  28. var label down = na
  29. var line l = na
  30. var float first_close = na
  31. var bool can_draw = false
  32.  
  33. var line l1 = na
  34. var float first_close1 = na
  35. var bool can_draw1 = false
  36.  
  37. //support and resistance line colors
  38. color supportlinecolor = input.color(color.green, "Support line color")
  39. color resistancelinecolor = input.color(color.red, "Resistance line color")
  40.  
  41. //label colors
  42. color buylabelcolor = input.color(color.green, "Buy label color")
  43. color selllabelcolor = input.color(color.red, "Sell label color")
  44.  
  45. //text colors
  46. color buylabeltextcolor = input.color(color.white, "Buy label text color")
  47. color selllabeltextcolor = input.color(color.white, "Sell label text color")
  48.  
  49.  
  50.  
  51. if(line11 > line22 and highrsi1 and line1 > line2 and highrsi)
  52. first_close := close // Reset session high
  53. can_draw := true // We are allowed to draw a line
  54. l := line.new(bar_index-1, first_close, bar_index, first_close, color=resistancelinecolor, xloc = xloc.bar_index, extend = extend.both,width=2)
  55. line.delete(l[1])
  56.  
  57. if(na(up)) //Does not exist, create one
  58. up := label.new(bar_index, close, "Price reversing \n Sell below resistance line", color=selllabelcolor, yloc=yloc.abovebar, textcolor = selllabeltextcolor)
  59.  
  60.  
  61.  
  62.  
  63.  
  64. else
  65. label.set_x(up, bar_index)
  66.  
  67.  
  68. if(line11 < line22 and lowrsi and line1 < line2 and lowrsi )
  69. first_close1 := open // Reset session high
  70. can_draw1 := true // We are allowed to draw a line
  71. l1 := line.new(bar_index-1, first_close1, bar_index, first_close1, color=supportlinecolor, xloc = xloc.bar_index, extend = extend.both,width=2)
  72. line.delete(l1[1])
  73. if(na(down)) //Does not exist, create one
  74. down := label.new(bar_index, close, "Price reversing \n Buy above support line", color=buylabelcolor, yloc=yloc.belowbar, style = label.style_label_up, textcolor = buylabeltextcolor)
  75. else
  76. label.set_x(down, bar_index)
  77.  
  78.  
  79.  
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement