This strategy combines the Relative Strength Index (RSI) and Bollinger Bands to construct a short-term trading strategy. It mainly utilizes the buy and sell signals when RSI breaks through the upper or lower Bollinger Bands. Meanwhile, a stop loss mechanism is included to effectively control risks.
This strategy combines the strengths of both RSI and Bollinger Bands for short-term trading. The main advantages are:
Potential risks of this strategy includes:
Solutions:
There is room for further optimization:
In summary, this is a relatively stable and reliable short-term trading strategy. By combining the strengths of overbought-oversold judgment of RSI and the adaptive range of Bollinger Bands, it forms an advantageous short-term system. With parameter tuning and logic refinement, this strategy can achieve consistent profits.
/*backtest start: 2022-12-12 00:00:00 end: 2023-10-13 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 strategy("rsi+bb st", shorttitle="rsibb st 0.3") len_rsi=input(14) len_bb = input(25) mul10 = input(20.0) mul=mul10/10 sl100 = input(94.0, title='stop loss rate') sl=sl100/100 lw = 3 vwma_e(src, len) => ema(src*volume, len)/ema(volume,len) rsi = rsi(close, len_rsi) plot(rsi, color=blue, title= 'rsi blue', linewidth=lw) plot(70, color=gray, title='line 70', linewidth=lw) plot(30, color=gray, title='line 30', linewidth=lw) bbg = stdev(rsi, len_bb)*mul bbc = vwma_e(rsi, len_bb) //bbc=ema(rsi,len_bb) ratio = 0.6 bbc := bbc*ratio + 50*(1-ratio) bbu = bbc+bbg bbl = bbc-bbg plot(bbu, color=green, title='bb_up green', linewidth=lw) plot(bbl, color=red, title='bb_low red', linewidth=lw) plot(bbc, color=#808000ff, title='bb center', linewidth=lw) plot(50, color=black) lc = crossover(rsi, bbl) //or crossover(rsi, bbc) sc = crossunder(rsi, bbu) last_pos = 0*close if lc last_pos := 1 else last_pos := last_pos[1] if sc last_pos := 2 last_price = 0*close if last_pos[1] !=1 and last_pos == 1 last_price := close else last_price := last_price[1] if last_pos==1 and close < last_price*sl lc:=false sc:=true last_pos:=2 if (lc) strategy.entry("long", strategy.long) if (sc) strategy.entry("short", strategy.short)