// ChartArt's RSI + Bollinger Bands, Double Strategy - Update // // Version 1.1 // Idea by ChartArt on January 18, 2015. // // This strategy uses the RSI indicator // together with the Bollinger Bands // to sell when the price is above the // upper Bollinger Band (and to buy when // this value is below the lower band). // // This simple strategy only triggers when // both the RSI and the Bollinger Bands // indicators are at the same time in // a overbought or oversold condition. // // In this version 1.1 the strategy was // both simplified for the user and // made more successful in backtesting. // // List of my work: // tradingview.com/u/ChartArt/ // // __ __ ___ __ ___ // / ` |__| /\ |__) | /\ |__) | // \__, | | /~~\ | \ | /~~\ | \ | // //
///////////// RSI RSIlength = input(6,title="RSI Period Length") RSIoverSold = 50 RSIoverBought = 50 price = close vrsi = rsi(price, RSIlength)
///////////// Colors switch1=input(true, title="Enable Bar Color?") switch2=input(true, title="Enable Background Color?") TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? green : na barcolor(switch1?TrendColor:na) bgcolor(switch2?TrendColor:na,transp=50)
///////////// RSI + Bollinger Bands Strategy if (not na(vrsi))
if (crossover(vrsi, RSIoverSold) and crossover(source, BBlower)) strategy.entry("RSI_BB_L", strategy.long, stop=BBlower, oca_type=strategy.oca.cancel, comment="RSI_BB_L") else strategy.cancel(id="RSI_BB_L")
if (crossunder(vrsi, RSIoverBought) and crossunder(source, BBupper)) strategy.entry("RSI_BB_S", strategy.short, stop=BBupper, oca_type=strategy.oca.cancel, comment="RSI_BB_S") else strategy.cancel(id="RSI_BB_S")