Advertisement
xmd79

Double RSI + Bollinger Bands

Jan 3rd, 2023
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. //@version=5
  2. //Double RSI by Braconnot P.
  3. indicator(title="Double RSI + Bollinger Bands", shorttitle="Double RSIBB")
  4. src = input(close, title="Source")
  5.  
  6. string TT1 = 'Oversold, overbought lines from center (50). For 70/30 set it to 20'
  7. string TT2 = 'Creates a linear center space between bands'
  8.  
  9. lenRSIF = input.int(25, minval=1,title="Fast RSI")
  10. lenRSIS = input.int(100, minval=1,title="Slow RSI")
  11. rsiSmooth = input.int(4, minval=1, title="RSI Smoothing")
  12. tH = input.float(15, 'RSI OS OB', step=1,tooltip=TT1)
  13. rsiT = input.float(7, 'Bollinger spacer', step=1,tooltip=TT2)
  14. bLen = input.int(15, title="Bollinger Lenght")
  15. bMult = input.float(3, title="Bollinger Multiplier")
  16. rsiF = ta.sma(ta.rsi(src, lenRSIF), rsiSmooth)
  17. rsiS = ta.sma(ta.rsi(src, lenRSIS), rsiSmooth)
  18.  
  19. [middle, upper, lower] = ta.bb(rsiS, bLen, bMult)
  20. uB=plot(upper + rsiT, color=color.new(#ffffff, 60))
  21. lB=plot(lower - rsiT, color=color.new(#ffffff, 60))
  22.  
  23. fastRsiColor = rsiF > upper + rsiT and rsiF < 50 + tH ? color.rgb(228, 63, 51, 20) : rsiF <= lower - rsiT and rsiF > 50 - tH ? color.rgb(8, 170, 8, 20) : rsiF > tH + 50 ? color.rgb(255, 0, 0, 20) : rsiF < 50 - tH ? color.rgb(119, 255, 77, 20) : color.rgb(255, 243, 19, 20)
  24. fillRsiColorU= rsiF > upper + rsiT and rsiF < 50 + tH ? color.rgb(233, 85, 74, 40) : rsiF <= lower - rsiT and rsiF > 50 - tH ? color.rgb(8, 170, 8, 90) : rsiF > tH + 50 and rsiF > upper ? color.rgb(255, 0, 0,50) : rsiF < 50 - tH ? color.rgb(39, 206, 48,90) : color.rgb(190,190,190,100)
  25. fillRsiColorL = rsiF > upper + rsiT and rsiF < 50 + tH ? color.rgb(233, 84, 74, 90) : rsiF <= lower - rsiT and rsiF > 50 - tH ? color.rgb(8, 170, 8, 40) : rsiF > tH + 50 ? color.rgb(160, 17, 53,90) : rsiF < 50 - tH ? color.rgb(9, 255, 0, 42) : color.rgb(190,190,190,100)
  26. rsiFF=plot(rsiF, title='Fast RSI plot', color=fastRsiColor, linewidth=2)
  27. rsiSF=plot(rsiS, title= 'Slow RSI plot', color=color.rgb(248, 150, 65, 10), linewidth=3)
  28. midL=hline(50, title='Middle Line', color=color.rgb(255, 255, 255, 60), linestyle=hline.style_dashed, linewidth=1)
  29. oB=hline(50 +tH, title='OB Line', color=color.rgb(140, 45, 230, 40), linestyle=hline.style_solid, linewidth=1)
  30. oS=hline(50 -tH, title='OS Line', color=color.rgb(140, 45, 230, 40), linestyle=hline.style_solid, linewidth=1)
  31. fill(uB,lB, title='BG Fill', color=color.new(color.blue, 90))
  32. fill(rsiFF, uB, title='RSI Fill', color=fillRsiColorU)
  33. fill(lB,rsiFF, title='RSI Fill', color=fillRsiColorL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement