xmd79

RSI+Indicato

Oct 15th, 2021
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 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. // © sonnyparlin
  3.  
  4. //@version=5
  5. indicator(shorttitle='RSI+Indicator', title='RSI Indicator', overlay=true)
  6.  
  7. // Inputs and variables
  8. rsiLow = input.int(26, minval=1, title="RSI Low Limit")
  9. rsiHigh = input.int(75, minval=50, title="RSI High Limit")
  10. enterLong = ta.crossover(ta.rsi(close,14),rsiLow)
  11.  
  12. // Enter long
  13. currentRSI = ta.rsi(close,14)
  14. var float entryPrice = na
  15. if enterLong
  16. entryPrice := close
  17. label.new(bar_index,
  18. low,
  19. "Go Long ▲ RSI: " + str.tostring(currentRSI, '#'),
  20. color=color.lime,
  21. size = size.normal,
  22. style=label.style_label_up)
  23.  
  24. exitWithProfit = input.int(2, title='Signal with at least (x%) profit')/100
  25. exitCond1 = ta.crossunder(ta.rsi(close,14),rsiHigh)
  26. exitCond2 = (close - entryPrice) / close > exitWithProfit
  27. exitLong = exitCond1 and exitCond2
  28.  
  29. if exitLong
  30. label.new(bar_index,
  31. high,
  32. "Exit Long ▼ RSI: " + str.tostring(currentRSI, '#'),
  33. color=color.red,
  34. size = size.normal,
  35. style=label.style_label_down)
Advertisement
Add Comment
Please, Sign In to add comment