Advertisement
PineCoders

RSXRSI2

Nov 21st, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. //@version=4
  2.  
  3. study(title="RSXRSIv2", shorttitle="RSXRSI2", precision=0)
  4. src = close
  5. upLine = input(70, minval=50, maxval=90, title="RSI Upper Line Value")
  6. lowLine = input(30, minval=10, maxval=50, title="RSI Lower Line Value")
  7. len = input(14, minval=1, title="1st RSI Length")
  8. lenema1 = input(12, minval=1, title="1st RSI EMA Length")
  9. len2 = input(14, minval=1, title="2nd RSI Length")
  10. //lenema2 = input(12, minval=1, title="2nd RSI EMA Length")
  11. sbh = input(true, title="Show Back Ground Highlights When RSI is Above/Below High/Low Lines")
  12. sch = input(true, title="Show Back Ground Highlights When RSI Cross")
  13. sl = input(true, title="Show 'B' and 'S' Letters When RSI Crosses High/Low Line")
  14. useCurrentRes = input(true, title="1st RSI Use Current Chart Timeframe")
  15. resCustom = input(title="1st RSI Use Custom Timeframe (Uncheck Box Above)", type=input.resolution, defval="60")
  16. ssRSI = input(false, title="Show 2nd RSI on Custom Timeframe")
  17. resCustom2 = input(title="2nd RSI Custom Timeframe", type=input.resolution, defval="D")
  18. useCurrentRes2 = input(false, title="2nd RSI Timeframe Overide")
  19.  
  20.  
  21.  
  22. res = useCurrentRes ? timeframe.period : resCustom
  23. res2 = useCurrentRes2 ? timeframe.period : resCustom2
  24.  
  25. up = rma(max(change(src), 0), len)
  26. down = rma(-min(change(src), 0), len)
  27. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
  28. outRSI = security(syminfo.tickerid, res, rsi)
  29.  
  30. up2 = rma(max(change(src), 0), len2)
  31. down2 = rma(-min(change(src), 0), len2)
  32. rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))
  33. outRSI2 = security(syminfo.tickerid, res2, rsi2)
  34.  
  35. aboveLine = outRSI > upLine ? 1 : 0
  36. belowLine = outRSI < lowLine ? 1 : 0
  37. crossUp = outRSI[1] < lowLine and outRSI > lowLine ? 1 : 0
  38. crossDn = outRSI[1] > upLine and outRSI < upLine ? 1 : 0
  39.  
  40. bgcolor(sbh and aboveLine ? color.red : na, transp=70)
  41. bgcolor(sbh and belowLine ? color.green : na, transp=70)
  42. bgcolor(sch and crossUp ? color.lime : na, transp=40)
  43. bgcolor(sch and crossDn ? color.red : na, transp=40)
  44.  
  45. plot(outRSI, title="RSI", linewidth=1, color=color.aqua)
  46. plot(ssRSI and outRSI2 ? outRSI2 : na, title="2nd RSI - Different Time Frame?", style=plot.style_linebr, linewidth=1, color=color.orange)
  47.  
  48. plotchar(sl and crossUp ? crossUp : na, title="Buy Signal", char='B', location=location.bottom, color=color.lime, transp=0, offset=0)
  49. plotchar(sl and crossDn ? crossDn : na, title="Sell Signal", char='S', location=location.top, color=color.red, transp=0, offset=0)
  50.  
  51.  
  52.  
  53. showHline = input(true, title='Control Zones', defval=true)
  54. showHline2 = input(true, title='Mid/OB/OS Levels', defval=true)
  55. hline(20, color = showHline2 ? #808080 : #00000000)
  56. hline(80, color = showHline2 ? #808080 : #00000000)
  57. hline(50, color = showHline2 ? #808080 : #00000000)
  58.  
  59. hline(65, color = showHline ? #228B22 : #00000000)
  60. hline(70, color = showHline ? #228B22 : #00000000)
  61. hline(30, color = showHline ? #800000 : #00000000)
  62. hline(45, color = showHline ? #800000 : #00000000)
  63.  
  64. //RSIEMA
  65. out = ema(rsi, lenema1)
  66. plot(out, title="RSI EMA", color=color.orange, linewidth=1, transp=0)
  67. //out2 = ema(rsi2, lenema2)
  68. //plot(outRSI2, title="RSI 2 EMA", color=orange, linewidth=1, transp=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement