该策略使用布林带和随机RSI指标来生成可能表明价格反转的信号。默认情况下,看跌信号显示为红色箭头,看涨信号显示为绿色箭头。在发出信号之前,该策略会寻找以下情况:(看涨)蜡烛线在布林带上轨之上收盘,随后的蜡烛线在上轨内收盘,随机RSI低于预设阈值(默认为10);(看跌)蜡烛线在布林带下轨之下收盘,随后的蜡烛线在下轨内收盘,随机RSI高于预设阈值(默认为90)。
该策略的核心原理是利用布林带和随机RSI这两个技术指标来捕捉潜在的价格反转信号。布林带由一条中轨(通常是移动平均线)和两条上下轨道(中轨加减标准差)组成,可以反映价格的波动情况。当价格突破上轨或下轨时,通常意味着市场情绪过于乐观或悲观,价格可能会出现反转。随机RSI是在RSI指标的基础上再次应用随机指标,更加灵敏地反映了市场的超买超卖状态。当随机RSI达到极值区域(如超过90或低于10)时,也预示着潜在的反转。该策略结合布林带突破和随机RSI极值这两个条件,可以比较可靠地捕捉到价格反转的时机。
布林带随机RSI极值信号策略通过结合布林带和随机RSI两个技术指标,以价格突破布林带上下轨和随机RSI达到超买超卖极值区域作为潜在的反转信号,形成了一套简单易用的交易策略。该策略具有信号可靠,适用范围广等优势,但在震荡市中表现欠佳,趋势市中可能滞后,对参数设置也比较敏感。因此在实际应用中,可以考虑从趋势确认,动态参数,止损止盈,结合其他指标等方面对策略进行优化和改进,以提高其适应性和盈利能力,更好地服务于量化交易实践。
/*backtest
start: 2023-04-06 00:00:00
end: 2024-04-11 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(shorttitle='BBSR Extreme', title='Bollinger Bands Stochastic RSI Extreme Signal', overlay=true)
//General Inputs
src = input(close, title='Source')
offset = input.int(0, 'Offset', minval=-500, maxval=500)
//Bollinger Inputs
length = input.int(20, title='Bollinger Band Length', minval=1)
mult = input.float(2.0, minval=0.001, maxval=50, title='StdDev')
//Bollinger Code
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
plot(basis, 'BB Basis', color=color.new(#872323, 0), offset=offset)
p1 = plot(upper, 'BB Upper', color=color.new(color.teal, 0), offset=offset)
p2 = plot(lower, 'BB Lower', color=color.new(color.teal, 0), offset=offset)
fill(p1, p2, title='BB Background', color=color.new(#198787, 95))
//Stoch Inputs
smoothK = input.int(3, 'K', minval=1)
smoothD = input.int(3, 'D', minval=1)
lengthRSI = input.int(14, 'RSI Length', minval=1)
lengthStoch = input.int(14, 'Stochastic Length', minval=1)
upperlimit = input.float(90, 'Upper Limit', minval=0.01)
lowerlimit = input.float(10, 'Upper Limit', minval=0.01)
//Stochastic Code
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
//Evaluation
Bear = close[1] > upper[1] and close < upper and k[1] > upperlimit and d[1] > upperlimit
Bull = close[1] < lower[1] and close > lower and k[1] < lowerlimit and d[1] < lowerlimit
//Plots
plotshape(Bear, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny)
plotshape(Bull, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny)
// Alert Functionality
alertcondition(Bear or Bull, title='Any Signal', message='{{exchange}}:{{ticker}}' + ' {{interval}}' + ' BB Stochastic Extreme!')
alertcondition(Bear, title='Bearish Signal', message='{{exchange}}:{{ticker}}' + ' {{interval}}' + ' Bearish BB Stochastic Extreme!')
alertcondition(Bull, title='Bullish Signal', message='{{exchange}}:{{ticker}}' + ' {{interval}}' + ' Bullish BB Stochastic Extreme!')
if Bear
strategy.entry('Enter Long', strategy.long)
else if Bull
strategy.entry('Enter Short', strategy.short)