xmd79

INVEST BTC RSI (from @tradinglord)

Feb 14th, 2022
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. //@version=5
  2. indicator(title="INVEST BTC RSI (from @tradinglord)", shorttitle="INVEST BTC RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
  3.  
  4. // worked out from "The rational monkey who outperforms most investors"
  5. // and "Sometimes it's better to be rational monkey than a greedy baboon" - Tradinglord 2022
  6.  
  7. rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
  8. rsiSourceInput = input.source(close, "Source", group="RSI Settings")
  9. rsi_high = input(80)
  10. rsi_low = input(35)
  11. rsi_middle = input(50)
  12.  
  13. up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
  14. down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
  15. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
  16.  
  17. c_white = color.new(color.white, 50)
  18. c_green = color.new(#32CD32, 0)
  19. c_red = color.new(#FF0000, 0)
  20.  
  21. rsi_color = rsi < rsi_low ? c_green : rsi > rsi_high ? c_red : ta.crossover(rsi, rsi_middle) or ta.crossunder(rsi, rsi_middle) ? color.orange : c_white
  22. plot(rsi, "RSI", color=rsi_color, linewidth=3)
  23. rsiUpperBand = hline(rsi_high, "RSI Upper Band", color=#787B86)
  24. hline(rsi_middle, "RSI Middle Band", color=color.new(#787B86, 50))
  25. rsiLowerBand = hline(rsi_low, "RSI Lower Band", color=#787B86)
Advertisement
Add Comment
Please, Sign In to add comment