Advertisement
xmd79

RSI Support & Resistance (EMA 200)

Sep 2nd, 2023
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 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. // © LENDL_GLOBAL
  3.  
  4. // HOW IT WORKS:
  5. // Signals are based on RSI and the 200 period exponential moving average.
  6. // "Support" is shown when price is above EMA 200 and falls below the RSI midpoint (blue dots).
  7. // "Resistance" is shown when price is below EMA 200 and moves above the RSI midpoint (orange dots).
  8. // In a bull trend, RSI tends to return to the midpoint before continuation upward.
  9. // In a bear trend, RSI tends to return to the midpoint before continuation downward.
  10. // If RSI spends a significant amount of time above or below the midpoint (visualized by many consecutive orange or blue dots), probability that price will touch or cross the EMA 200 increases.
  11. // However, none of these tendencies are guaranteed and should always be evaluated probabilistically.
  12. // This context is useful for visualizing price action and RSI behavior for any asset or timeframe.
  13.  
  14. //@version=4
  15. study("RSI Support & Resistance (EMA 200)", overlay=true)
  16.  
  17. s200ema = ema(close, 200)
  18. s100ema = ema(close, 100)
  19. s50ema = ema(close, 50)
  20.  
  21. // MA Inputs
  22. show200EMA = input(title="EMA 200", type=input.bool, defval=true, group="Moving Averages")
  23. show100EMA = input(title="EMA 100", type=input.bool, defval=false, group="Moving Averages")
  24. show50EMA = input(title="EMA 50", type=input.bool, defval=false, group="Moving Averages")
  25.  
  26. // RSI Signals
  27. showRSISignals = input(title="Show RSI Signals (EMA 200)", type=input.bool, defval=true, group="RSI Signals")
  28. rsiLength = input(title="RSI Length", type=input.integer, defval=14, group="RSI Signals")
  29. rsiSource = input(title="RSI Source", type=input.source, defval=close, group="RSI Signals")
  30. rsiOverbought = input(title="RSI Overbought Level", type=input.integer, defval=70, group="RSI Signals")
  31. rsiMid = input(title="RSI Midpoint Level", type=input.integer, defval=50, group="RSI Signals")
  32. rsiOversold = input(title="RSI Oversold Level", type=input.integer, defval=30, group="RSI Signals")
  33.  
  34. // Booleans
  35. rsiValue = rsi(rsiSource, rsiLength)
  36. isRsiOB = rsiValue >= rsiOverbought
  37. isRsiOS = rsiValue <= rsiOversold
  38.  
  39. // Plot MAs
  40. plot(show200EMA ? s200ema : na, title="EMA 200", linewidth = 1, color = color.blue)
  41. plot(show100EMA ? s100ema : na, title="EMA 100", linewidth = 1, color = color.black)
  42. plot(show50EMA ? s50ema : na, title="EMA 50", linewidth = 1, color = color.gray)
  43.  
  44. // Plot signals to chart
  45. plotshape(showRSISignals and isRsiOB, title="Overbought", location=location.abovebar, color=color.red, style=shape.triangledown)
  46. plotshape(showRSISignals and isRsiOS, title="Oversold", location=location.belowbar, color=color.green, style=shape.triangleup)
  47. plotshape(showRSISignals and isRsiOS == false and close >= s200ema and rsiValue <= rsiMid, title="Support", location=location.belowbar, color=color.aqua, style=shape.circle)
  48. plotshape(showRSISignals and isRsiOB == false and close <= s200ema and rsiValue >= rsiMid, title="Resistance", location=location.abovebar, color=color.orange, style=shape.circle)
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement