RSITrendStrategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © email_analysts
// This code gives indication on the chart to go long or short based on RSI crossover strategy. 
//Default value has been taken as 5 and 11, with 6 being used to identify highs & lows.
//@version=4
strategy("RSITrendStrategy", overlay=false)
len1 = input(title="MA 1", defval = 5)
len2 = input(title="MA 1", defval = 11)
len3 = input(title="MA 1", defval = 6)

h1 = hline(30.)
h2 = hline(70.)
///fill(h1, h2, color = color.new(color.blue, 80))
sh = rsi(close, len1)
ln = rsi(close, len2)
rs = rsi(close, len3)
p1 = plot(sh, color = color.red)
p2 = plot(ln, color = color.green)
p3 = plot(rs, color = color.white)

mycol = sh > ln ? color.lime : color.red
fill(p1, p2, color = mycol)

buy = (sh[1] < ln[1] and sh > ln and rs[1] < 30) 
if (buy)
    strategy.entry("long", strategy.long)

sell = (sh[1] > ln[1] and sh < ln and rs[1] > 70)
if (sell)
    strategy.entry("short", strategy.short)