该策略运用了RSI、StochRSI和布林带三种股价技术指标,并结合交易的时间和方向条件,实现判断买入和卖出信号的量化交易策略。
当RSI指标小于低位区域并且StochRSI指标K线上穿D线时,视为买入信号。同时股价较布林带下线廉价或穿过布林带下线也作为买入依据。
当RSI指标超过高位区域并且StochRSI指标K线下穿D线时,视为卖出信号。同时股价高于布林带上线或跌穿布林带上线也作为卖出依据。
通过 RSI 指标判断股价是否超买超卖,StochRSI 判断股价动能,布林带判断股价是否高位运行和廉价,多指标组合判断买卖。
这是一个多指标组合的策略,指标覆盖面广,判断依据全面。在判断信号前都需要当前股价或指标和其阈值发生交叉,对虚假信号有一定的过滤。
在下单前增加了时间条件限制,可以避免特定的时间段带来更大的风险。
通过多种指标的综合判断,能够匹配更多类型的走势,提高策略的有效率。
该策略主要依赖三种指标,如果指标发出错误信号,策略会造成损失。指标应该互相验证,不能完全依赖某个指标。比如某个时间段RSI震荡,会增加发出虚假信号的可能。
策略加入的时间判断条件可能也会错过有利行情。
如果选股不当,例如 exaggeration效应严重的股票,指标的有效性会大打折扣,应该研究股票对这些指标的适用性。
增加最大回撤等风控手段,可以对损失进行限制。
调整指标的参数,更好的与选定的股票匹配。比如加快RSI参数以检测更快的价格变动。
增加过滤机制,例如股价在布林带中部时暂缓交易,避免震荡行情。并且在开盘和收盘附近阻止下单,避开跳空的风险。
选股时可以参考公司基本面,避选财务造假严重的股票。也可以增加行业和市值的判断,选取大盘股。
这是一个典型的多变量技术指标策略,指标组合较为均衡,覆盖面广,同时下单条件严谨,可以有效选股实现盈利,回撤也会控制在一定范围内。通过指标和参数优化,可以更好的适配市场,同时增加风控机制最大限度规避风险,进一步提高策略的稳定可靠性。
/*backtest
start: 2023-12-24 00:00:00
end: 2024-01-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version= 2
strategy("RSI+STOCHRSI+BB Strategy", overlay=true)
lengthrsi = input(6)
overSold = input( 20 )
overBought = input( 70 )
price = close
vrsi = rsi(price, lengthrsi)
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
bblength = input(50)
bbupmult =input(1.5,title="Multiplier for BB Upper Band")
bblowmult = input(1.5,title="Multiplier for BB Lower Band")
basis = sma(close,bblength)
devup = bbupmult * stdev(close, bblength)
devlow = bblowmult * stdev(close, bblength)
upper = basis + devup
lower = basis - devlow
plot(basis, color=red)
p1 = plot(upper, color=blue)
p2 = plot(lower, color=blue)
fill(p1, p2)
yearfrom = input(2018)
yearuntil =input(2019)
monthfrom =input(6)
monthuntil =input(12)
dayfrom=input(1)
dayuntil=input(31)
if ( ( crossover(k,d)) and ( crossover(vrsi,overSold) or vrsi<overSold) and ( (price<lower) or crossover(price,lower) ) )
strategy.entry("BUY", strategy.long, stop=close, oca_name="TREND", comment="BUY")
else
strategy.cancel(id="BUY")
if ( ( crossunder(k,d) ) and ( (vrsi >overBought) or crossunder(vrsi,overBought) ) and ( (price>upper) or crossunder(price,upper) ))
strategy.entry("SELL", strategy.short,stop=close, oca_name="TREND", comment="SELL")
else
strategy.cancel(id="SELL")