RSI Cross [xaurr]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © xaurr

//@version=4
strategy("RSI Cross [xaurr]", shorttitle="RSIC",overlay=false)

src  = input(title="Source", type=input.source, defval=close)

//RSI Strategy
period = input(5,"RSI Period", minval=1)
overSold = input(30,"RSI Oversold", minval=1)
overBought = input(70, "RSI Overbought", minval=1)
fastPeriod = input(20,"Smooth Fast Period")
slowPeriod = input(50,"Smooth Slow Period")


rsi = rsi(src, period)
fast = ema(rsi,fastPeriod)
slow = ema(rsi,slowPeriod)


long = crossover(fast,slow)
short = crossunder(fast,slow)


pos = 0
pos:= long ?1:short ?-1 : nz(pos[1])


plot(overSold,"RSI Oversold",color=color.green)
plot(overBought, "RSI Overbought",color=color.red)
plot(rsi, linewidth = 1, color = color.blue, title="RSI Line")

plot(fast, linewidth = 2, color = color.green, title="RSI Fast Line")
plot(slow, linewidth = 2, color = color.red, title="RSI Slow Line")

bgcolor(pos == 1 ? color.green : pos == -1 ? color.red : na)

if pos == 1
    strategy.entry("long",strategy.long)

if pos == -1
    strategy.entry("short",strategy.short)