Suchit RSI CCI
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SuchitRaju

//@version=4
strategy("MA RSI CCI")

price_up = if(close > open and close > sma(hl2,14))
    1
else
    0

price_down = if(open > close and close < sma(hl2,14))
    1
else
    0
// 

cci_indicator = cci(hl2, 14)
// plot(cci_indicator, color=color.blue)

rsi_slow = sma(rsi(close, 14), 50)
// plot(rsi_slow, color=color.red)

rsi_fast = rsi(close, 14)
// plot(rsi_fast, color=color.green)

isCrossover = if(rsi_fast > rsi_slow and cci_indicator > 0)
    1
else
    0
// plotshape(isCrossover, style = shape.arrowup, color = color.green, size = size.huge)

isCrossunder = if(rsi_fast < rsi_slow and cci_indicator < 0)
    1
else
    0
// plotshape(isCrossunder, style = shape.arrowup, color = color.red, size = size.huge)

// start = timestamp("GMT-5", 2016,9,1,0,0)
// end = timestamp("GMT-5", 2017,9,1,0,0)

// strategy.entry("Long", strategy.long, 1, when = isCrossover and price_up)
// strategy.entry("Short", strategy.short, 1, when = isCrossunder and price_down)
// strategy.close("Long", when = isCrossunder and price_down)
// strategy.close("Short", when = isCrossover and price_up)

strategy.entry("Long", strategy.long, 1, when = isCrossover)
strategy.entry("Short", strategy.short, 1, when = isCrossunder)
strategy.close("Long", when = isCrossunder)
strategy.close("Short", when = isCrossover)