Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © LENDL_GLOBAL
- // HOW IT WORKS:
- // Signals are based on RSI and the 200 period exponential moving average.
- // "Support" is shown when price is above EMA 200 and falls below the RSI midpoint (blue dots).
- // "Resistance" is shown when price is below EMA 200 and moves above the RSI midpoint (orange dots).
- // In a bull trend, RSI tends to return to the midpoint before continuation upward.
- // In a bear trend, RSI tends to return to the midpoint before continuation downward.
- // 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.
- // However, none of these tendencies are guaranteed and should always be evaluated probabilistically.
- // This context is useful for visualizing price action and RSI behavior for any asset or timeframe.
- //@version=4
- study("RSI Support & Resistance (EMA 200)", overlay=true)
- s200ema = ema(close, 200)
- s100ema = ema(close, 100)
- s50ema = ema(close, 50)
- // MA Inputs
- show200EMA = input(title="EMA 200", type=input.bool, defval=true, group="Moving Averages")
- show100EMA = input(title="EMA 100", type=input.bool, defval=false, group="Moving Averages")
- show50EMA = input(title="EMA 50", type=input.bool, defval=false, group="Moving Averages")
- // RSI Signals
- showRSISignals = input(title="Show RSI Signals (EMA 200)", type=input.bool, defval=true, group="RSI Signals")
- rsiLength = input(title="RSI Length", type=input.integer, defval=14, group="RSI Signals")
- rsiSource = input(title="RSI Source", type=input.source, defval=close, group="RSI Signals")
- rsiOverbought = input(title="RSI Overbought Level", type=input.integer, defval=70, group="RSI Signals")
- rsiMid = input(title="RSI Midpoint Level", type=input.integer, defval=50, group="RSI Signals")
- rsiOversold = input(title="RSI Oversold Level", type=input.integer, defval=30, group="RSI Signals")
- // Booleans
- rsiValue = rsi(rsiSource, rsiLength)
- isRsiOB = rsiValue >= rsiOverbought
- isRsiOS = rsiValue <= rsiOversold
- // Plot MAs
- plot(show200EMA ? s200ema : na, title="EMA 200", linewidth = 1, color = color.blue)
- plot(show100EMA ? s100ema : na, title="EMA 100", linewidth = 1, color = color.black)
- plot(show50EMA ? s50ema : na, title="EMA 50", linewidth = 1, color = color.gray)
- // Plot signals to chart
- plotshape(showRSISignals and isRsiOB, title="Overbought", location=location.abovebar, color=color.red, style=shape.triangledown)
- plotshape(showRSISignals and isRsiOS, title="Oversold", location=location.belowbar, color=color.green, style=shape.triangleup)
- plotshape(showRSISignals and isRsiOS == false and close >= s200ema and rsiValue <= rsiMid, title="Support", location=location.belowbar, color=color.aqua, style=shape.circle)
- plotshape(showRSISignals and isRsiOB == false and close <= s200ema and rsiValue >= rsiMid, title="Resistance", location=location.abovebar, color=color.orange, style=shape.circle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement