xmd79

RSI Objective Lines

Jan 12th, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 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. // © Sofien-Kaabar
  3.  
  4. //@version=5
  5. indicator("RSI Objective Lines")
  6.  
  7. lookback = input(defval = 200, title = 'Lookback')
  8. threshold = input(defval = 0.05, title = 'Threshold')
  9.  
  10. rsi_high = ta.rsi(high, 14)
  11. rsi_low = ta.rsi(low, 14)
  12.  
  13. // calculating the maximum range
  14. max_range = ta.highest(rsi_high, lookback) - ta.lowest(rsi_low, lookback)
  15.  
  16. // support
  17. support = ta.lowest(rsi_low, lookback) + (max_range * threshold)
  18.  
  19. // resistance
  20. resistance = ta.highest(rsi_high, lookback) - (max_range * threshold)
  21.  
  22.  
  23. inp = input(close)
  24.  
  25. plot(ta.rsi(inp, 14))
  26. plot(support, color = ta.rsi(inp, 14) > support? color.green : na)
  27. plot(resistance, color = ta.rsi(inp, 14) < resistance? color.red : na)
  28.  
Add Comment
Please, Sign In to add comment