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/
- // © MINTYFRESH97
- //@version=5
- indicator("RSI MASTER")
- // Import Zen Library
- // Get user input
- lookback = input.int(title="Lookback", defval=10)
- rsiLen = input.int(title="RSI Length", defval=7)
- rsiOB = input.float(title="RSI Overbought", defval=70.0)
- rsiOS = input.float(title="RSI Oversold", defval=30.0)
- inp = input(close)
- // Get RSI value
- rsi = ta.rsi(inp, rsiLen)
- rsiSell = rsi > rsiOB
- rsiBuy = rsi < rsiOS
- //swing high/low filter
- swingHigh = high == ta.highest(high,20) or high[1] == ta.highest(high,20)
- swingLow = low == ta.lowest(low,20) or low[1] ==ta.lowest(low,20)
- //candle filter
- RallieCandle = (inp[3] > inp[4]) and (inp[2] > inp[3]) and
- (inp < inp[1])
- pullBack = (inp[3] < inp[4]) and (inp[2] < inp[3])
- and (inp[1] < inp[2]) and (inp > inp[1])
- // Detect buy and sell signals
- buySignal = rsiBuy[1] and pullBack and swingLow
- sellSignal = rsiSell[1] and RallieCandle and swingHigh
- risSupportband1 = hline(40, "RSI Support Band",linestyle=hline.style_solid, linewidth=3, color=color.green)
- rsiResistanceband = hline(60, "RSI Resistance Band",linestyle=hline.style_solid, linewidth=3, color=color.red)
- rsiResistanceband2 = hline(70, "RSI Resistance Band", linestyle=hline.style_solid, linewidth=3, color=color.red)
- risSupportband = hline(30,"RSI Support Band", linestyle=hline.style_solid, linewidth=3, color=color.green)
- h1=hline(30)
- h2=hline(40)
- h3=hline(70)
- h4=hline(60)
- fill(h1 , h2, color=color.new(color.green, 90))
- fill(h3 , h4, color=color.new(color.red, 90))
- // Draw data to chart
- plot(rsi, title="RSI", color=rsiBuy ? color.lime : rsiSell ? color.red : color.gray, linewidth=2)
- bgcolor(buySignal ? color.new(color.green, 85) : na)
- bgcolor(sellSignal ? color.new(color.red, 85) : na)
- // Trigger alerts
- alertcondition(buySignal or sellSignal, title="RSI Signal", message="RSI Exhaustion Setup for {{ticker}} - RSI value = {{plot_0}}")
Advertisement
Add Comment
Please, Sign In to add comment