xmd79

Relative Strength Index

Oct 7th, 2021
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 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. //@version=4
  3. study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")
  4. len = input(14, minval=1, title="Length")
  5. src = input(close, "Source", type = input.source)
  6. up = rma(max(change(src), 0), len)
  7. down = rma(-min(change(src), 0), len)
  8. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
  9. plot(rsi, "RSI", color=#ffffff)
  10.  
  11. band1 = hline(70, "Upper Band", color=#ffffff)
  12. bandm = hline(50, "Middle Band", color=color.new(#ffffff, 60))
  13. band0 = hline(30, "Lower Band", color=#ffffff)
  14. band4 = hline(80, "Upper Band", color=#ffffff)
  15. band3 = hline(60, "Middle Band", color=color.new(#ffffff, 60))
  16. band2 = hline(20, "Lower Band", color=#ffffff)
  17. fill(band1, band0, color=color.rgb(126, 87, 194, 90), title="Background")
Advertisement
Add Comment
Please, Sign In to add comment