xmd79

RSI OB/OS on Chart

Jan 11th, 2022
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 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. // © lotekjunky
  3.  
  4. //@version=5
  5.  
  6. indicator( shorttitle = "RSI OB/OS on Chart", title = " LoTek - On Chart RSI OB/OS w Alerts ", overlay=true)
  7.  
  8. // Settings
  9. rsi_len = input.int ( 13, title = " RSI Length ", inline = "1", group = "RSI Settings" )
  10. rsi_src = input.source ( close, title = "", inline = "1", group = "RSI Settings" )
  11.  
  12. i_rsi_ob = input.int ( 75, title = "RSI Overbought", inline = "4", group = "Alert Settings" )
  13. i_rsi_os = input.int ( 25, title = "RSI Overbought", inline = "5", group = "Alert Settings" )
  14.  
  15. // Maybe I'll get this figured out some day
  16. //i_char_ob = input.string ( "OB", title = "Overbought Symbol", inline = "1", group = "On Chart" )
  17. //i_char_os = input.string ( "OS", title = "Oversold Symbol", inline = "2", group = "On Chart" )
  18. //i_col_ob = input.color ( color.new(color.lime,50), title = "OB Symbol Color", inline = "3", group = "On Chart" )
  19. //i_col_os = input.color ( color.new(color.red,50), title = "OS Symbol Color", inline = "4", group = "On Chart" )
  20.  
  21. // Do math and stuff
  22. rsi_val = ta.rsi(rsi_src, rsi_len)
  23. bl_rsi_ob = rsi_val >= i_rsi_ob
  24. bl_rsi_os = rsi_val <= i_rsi_os
  25.  
  26. // Draw on chart
  27. plotshape(bl_rsi_ob, title='Overbought', location=location.abovebar, color=color.new(color.red,50), style=shape.triangledown, text='OB')
  28. plotshape(bl_rsi_os, title='OverSold', location=location.belowbar, color=color.new(color.lime,50), style=shape.triangledown, text='OS')
  29.  
  30. // Alerts
  31. alertcondition( bl_rsi_ob, title='RSI Overbought', message='RSI OB')
  32. alertcondition( bl_rsi_os, title='RSI Oversold' , message='RSI OB')
Advertisement
Add Comment
Please, Sign In to add comment