xmd79

RSI MASTER

Sep 3rd, 2022
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 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. // © MINTYFRESH97
  3.  
  4. //@version=5
  5. indicator("RSI MASTER")
  6.  
  7. // Import Zen Library
  8.  
  9. // Get user input
  10. lookback = input.int(title="Lookback", defval=10)
  11. rsiLen = input.int(title="RSI Length", defval=7)
  12. rsiOB = input.float(title="RSI Overbought", defval=70.0)
  13. rsiOS = input.float(title="RSI Oversold", defval=30.0)
  14.  
  15.  
  16. inp = input(close)
  17.  
  18. // Get RSI value
  19. rsi = ta.rsi(inp, rsiLen)
  20. rsiSell = rsi > rsiOB
  21. rsiBuy = rsi < rsiOS
  22.  
  23. //swing high/low filter
  24. swingHigh = high == ta.highest(high,20) or high[1] == ta.highest(high,20)
  25. swingLow = low == ta.lowest(low,20) or low[1] ==ta.lowest(low,20)
  26.  
  27. //candle filter
  28. RallieCandle = (inp[3] > inp[4]) and (inp[2] > inp[3]) and
  29. (inp < inp[1])
  30. pullBack = (inp[3] < inp[4]) and (inp[2] < inp[3])
  31. and (inp[1] < inp[2]) and (inp > inp[1])
  32.  
  33.  
  34. // Detect buy and sell signals
  35. buySignal = rsiBuy[1] and pullBack and swingLow
  36. sellSignal = rsiSell[1] and RallieCandle and swingHigh
  37.  
  38. risSupportband1 = hline(40, "RSI Support Band",linestyle=hline.style_solid, linewidth=3, color=color.green)
  39. rsiResistanceband = hline(60, "RSI Resistance Band",linestyle=hline.style_solid, linewidth=3, color=color.red)
  40. rsiResistanceband2 = hline(70, "RSI Resistance Band", linestyle=hline.style_solid, linewidth=3, color=color.red)
  41. risSupportband = hline(30,"RSI Support Band", linestyle=hline.style_solid, linewidth=3, color=color.green)
  42.  
  43. h1=hline(30)
  44. h2=hline(40)
  45.  
  46. h3=hline(70)
  47. h4=hline(60)
  48.  
  49. fill(h1 , h2, color=color.new(color.green, 90))
  50. fill(h3 , h4, color=color.new(color.red, 90))
  51.  
  52.  
  53.  
  54.  
  55.  
  56. // Draw data to chart
  57. plot(rsi, title="RSI", color=rsiBuy ? color.lime : rsiSell ? color.red : color.gray, linewidth=2)
  58. bgcolor(buySignal ? color.new(color.green, 85) : na)
  59. bgcolor(sellSignal ? color.new(color.red, 85) : na)
  60.  
  61.  
  62. // Trigger alerts
  63. alertcondition(buySignal or sellSignal, title="RSI Signal", message="RSI Exhaustion Setup for {{ticker}} - RSI value = {{plot_0}}")
  64.  
Advertisement
Add Comment
Please, Sign In to add comment