xmd79

Leledc Exhaustion levels

Sep 23rd, 2021
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. //@version=4
  2. //©BigThinker
  3.  
  4. // Combination of two previous indicators:
  5. // https://www.tradingview.com/script/2rZDPyaC-Leledc-Exhaustion-Bar/
  6. // https://www.tradingview.com/script/jB2a9GAV-Leledc-levels-IS/
  7.  
  8. study(title='Leledc Exhaustion levels',shorttitle="Leledc Levels",overlay=true)
  9.  
  10. //Input
  11. maj_length= input(30,"Major Exhaustions swing length")
  12. maj_bars= input(6,"Major Exhaustion bar count")
  13. min_length= input(5,"Minor Exhaustions swing length")
  14. min_bars= input(5,"Minor Exhaustion bar count")
  15. maj=input(true,title="Show Major exhaustion Bar point (Arrows/Full circles)")
  16. min=input(true,title="Show Minor exhaustion Bar point (empty circles)")
  17.  
  18. thicknesSwitch = input(2, title="Line Thickness(Level thickness)")
  19.  
  20. //Fun Lele
  21. Lelec(bars, len) =>
  22. bindex = int(na)
  23. bindex := nz(bindex[1], 0)
  24. sindex = int(na)
  25. sindex := nz(sindex[1], 0)
  26. return = 0
  27. bindex := close > close[4] ? bindex + 1 : bindex
  28. sindex := close < close[4] ? sindex + 1 : sindex
  29. if bindex > bars and close < open and high >= highest(high, len)
  30. bindex := 0
  31. return := -1
  32. return
  33. else
  34. if sindex > bars and close > open and low <= lowest(low, len)
  35. sindex := 0
  36. return := 1
  37. return
  38.  
  39. //Out C
  40. major = Lelec(maj_bars, maj_length)
  41. minor = Lelec(min_bars, min_length)
  42.  
  43.  
  44. plotchar(maj ? (major==-1?high:na) : na, char='•',location=location.absolute,color=color.red,size=size.normal)
  45. plotchar(maj ? (major==1?low:na) : na , char='•',location=location.absolute,color=color.lime,size=size.normal)
  46.  
  47. plotchar(min ? (minor==-1?high:na) : na, char='○',location=location.absolute,color=color.red,size=size.normal)
  48. plotchar(min ? (minor==1?low:na) : na , char='○',location=location.absolute,color=color.lime,size=size.normal)
  49.  
  50. Lelex = Lelec(maj_bars, maj_length)
  51.  
  52. //Out Bar
  53. highlel = Lelex == -1 ? high : na
  54. lowlel = Lelex == 1 ? low : na
  55.  
  56. //Out level
  57. resistance = float(na)
  58. support = float(na)
  59. resistance := close < open and Lelex ? high : resistance[1]
  60. support := close > open and Lelex ? low : support[1]
  61.  
  62. //Color
  63. rescol=color.new(#ff0000, 1)
  64. highcol = change(resistance) == 0 ? rescol: na
  65. supcol=color.new(#138484, 1)
  66. lowcol = change(support) == 0 ? supcol : na
  67.  
  68. //Plot Bar
  69. plotshape(maj ? lowlel : na,title="Up", color=color.new(#00ff00,1), location=location.belowbar, style=shape.triangleup, size=size.normal)
  70. plotshape(maj ? highlel: na,title="Down", color=color.new(#ff0000, 1), location=location.abovebar, style=shape.triangledown, size=size.normal)
  71.  
  72. //Plot level
  73. plot(maj ? resistance :na, title="Reistance Level", style=plot.style_line, color=highcol, linewidth=thicknesSwitch)
  74. plot(maj ? support :na, title="Support Level", style=plot.style_line, color=lowcol, linewidth=thicknesSwitch)
  75.  
  76. alertcondition(lowlel, "Up")
  77. alertcondition(highlel, "Down")
Advertisement
Add Comment
Please, Sign In to add comment