You are on page 1of 1

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © vishaljindal09

//@version=4

study("RSI with Moving Average")

rsi_period = input(defval=14, title="RSI Period", type=input.integer)


sma_f_p = input(defval=13, title="RSI SMA Period", type=input.integer)
ema_s_p = input(defval=33, title="RSI EMA Period", type=input.integer)
bull_sup = input(defval=40, title="RSI Bull Trend Support", type=input.integer)
bear_res = input(defval=60, title="RSI Bear Trend Resistance", type=input.integer)

rsi = rsi(close, rsi_period)


sma_rsi = sma(rsi, sma_f_p)
ema_rsi = ema(rsi, ema_s_p)

prsi = plot(rsi, title='RSI', color=color.new(#FF00FF, 0), style=plot.style_line,


linewidth=2)
overbought = hline(70, title="Overbought", color=color.new(color.purple, 50),
linestyle=hline.style_dashed, linewidth=1)
oversold = hline(30, title="Oversold", color=color.new(color.purple, 50),
linestyle=hline.style_dashed, linewidth=1)
fill(overbought, oversold, color.new(color.purple, 90), title="RSI Fill")

psma = plot(sma_rsi, title='SMA', color=color.new(color.gray, 30),


style=plot.style_line, linewidth=2)
pema = plot(ema_rsi, title="EMA", color=color.new(color.gray, 30),
style=plot.style_line, linewidth=2)

fillColor = ema_rsi < sma_rsi ? color.green : color.red


fill(psma, pema, color=fillColor, transp=60)
fill(psma, prsi, color=color.gray, transp=80)

hline(bull_sup, title="Bull Market RSI Support", color=color.new(color.green, 50),


linestyle=plot.style_line, linewidth=3)
hline(bear_res, title="Bear Market RSI Resistance", color=color.new(color.red, 60),
linestyle=plot.style_line, linewidth=3)

You might also like