xmd79

Basic RSI and Stoch

Oct 1st, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 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. // © Magic-Charts
  3.  
  4. //@version=4
  5. study("Basic RSI and Stoch")
  6.  
  7. rsiSource = input(title="Source", type=input.source, defval=close)
  8. rsiLength = input(title="RSI Length", type=input.integer, defval=14)
  9. smoothK = input(title="K", type=input.integer, defval=5)
  10. smoothD = input(title="D", type=input.integer, defval=3)
  11.  
  12. rsiValue = rsi(rsiSource, rsiLength)
  13. k = sma(stoch(rsiValue, rsiValue, rsiValue, rsiLength), smoothK)
  14. d = sma(k, smoothD)
  15.  
  16.  
  17. highLine = hline(70, title="RSI Overbought Line", color=color.gray, linestyle=hline.style_dashed)
  18. midLine = hline(50, title="RSI Mid Line", color=color.gray, linestyle=hline.style_dashed)
  19. lowLine = hline(30, title="RSI Oversold Line", color=color.gray, linestyle=hline.style_dashed)
  20. fill(highLine, lowLine, color=color.silver)
  21.  
  22. rsiPlot = plot(rsiValue, title="RSI", color=color.black)
  23.  
  24. kPlot = plot(k, title="K", color=#808080)
  25. dPlot = plot(d, title="D", color=#BEBEBE)
  26. fill(kPlot, dPlot, color=k >= d ? #FFFFFF : #696969)
Advertisement
Add Comment
Please, Sign In to add comment