该策略将相对强弱指数(RSI)与随机指标组合使用,形成双重策略,以更准确地判断市场的超买超卖状态,从而获得更可靠的交易信号。
该策略中,RSI长度为14周期,过度买入阈值为70,过度卖出阈值为30。随机指标的K值采用3周期均线计算,D值为K值的3周期均线。当K线从下往上突破D线时判定为超买信号,反之则为超卖信号。
策略采用RSI指标与随机指标的组合判断来发出交易信号:
当随机指标出现上穿(K线从下方向上穿过D线),同时RSI指标高于70,判定为超买信号,做空。
当随机指标出现下穿(K线从上方向下穿过D线),同时RSI指标低于30,判定为超卖信号,做多。
该双重组合策略充分利用了RSI指标判断超买超卖的优点,同时结合随机指标的顺势性来过滤假信号,从而产生更可靠的交易信号。
这种双重策略最大的优势在于可以有效减少假信号,提高信号的可靠性。
RSI指标单独使用时,会产生较多假信号。这是因为RSI指标本身仅判断价格的超买超卖状态,不能反映趋势的方向。所以单独RSI信号较多是不可靠的。
而随机指标则可以判断价格趋势的方向。K线上穿D线表明价格的上升趋势可能持续,这时RSI超买信号可靠性较高,判断为真超买而非假超买。
相反,K线下穿D线则说明价格趋势可能反转,即使RSI显示超卖信号,也有可能是假超卖,不作交易。
因此,组合使用RSI和随机指标,可以较好地把握住价格的超买超卖状态以及趋势的方向性,过滤掉大量不可靠信号,从而获得更精确的交易时机。
该策略也存在一定的风险需要注意:
双重指标组合使用虽可过滤假信号,但也可能错过一部分真实信号,从而错失交易机会。
RSI和随机指标的参数设定需要拿捏好度的关系,例如RSI周期过短、随机指标K、D值平滑度不当,都会影响信号的准确性。
指标发出信号时,还需要结合价格动量、成交量等因素进行确认,避免进入假突破。
需要关注系统性风险,在市场剧烈波动时,避免盲目交易。
该策略还可以从以下几个方面进行优化:
优化RSI和随机指标的参数,找到最佳参数组合。可以通过回测数据进行参数调优,也可以采用机器学习方法动态优化参数。
增加成交量的确认指标,例如成交量突增来验证买卖信号。
结合移动均线等趋势确认指标,避免被震荡市拉扯。例如只在趋势向上时考虑买入信号。
采用机器学习方法识别更复杂的买卖规则,如结合布林带、价格形态等信号来提高策略稳定性。
利用深度学习等前沿技术开发更智能的多元化交易系统,在更大样本空间中优化策略规则。
该RSI与随机指标双重组合策略,通过指标集成的思想,合理利用了各指标的优势,形成互补效应。其较单一RSI指标有更高的信号过滤精确度,从而获得更准确可靠的交易信号。但仍需要注意参数优化、风险管理等问题。该策略思路可推广至其他指标的组合,以发掘更有效的量化交易策略。
/*backtest
start: 2022-09-30 00:00:00
end: 2023-10-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
//Based on Divergences and Hidden Divergences
//Locates bottom market and reversals
strategy("Vix FIX / StochRSI Strategy", pyramiding=9, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=3, overlay=false)
///////////// Stochastic Slow
Stochlength = input(14, minval=1, title="lookback length of Stochastic")
StochOverBought = input(80, title="Stochastic overbought condition")
StochOverSold = input(20, title="Stochastic oversold condition")
smoothK = input(3, title="smoothing of Stochastic %K ")
smoothD = input(3, title="moving average of Stochastic %K")
k = sma(stoch(close, high, low, Stochlength), smoothK)
d = sma(k, smoothD)
///////////// RSI
RSIlength = input( 14, minval=1 , title="lookback length of RSI")
RSIOverBought = input( 70 , title="RSI overbought condition")
RSIOverSold = input( 30 , title="RSI oversold condition")
RSIprice = close
vrsi = rsi(RSIprice, RSIlength)
///////////// Double strategy: RSI strategy + Stochastic strategy
pd = input(22, title="LookBack Period Standard Deviation High")
bbl = input(20, title="Bolinger Band Length")
mult = input(2.0 , minval=1, maxval=5, title="Bollinger Band Standard Devaition Up")
lb = input(50 , title="Look Back Period Percentile High")
ph = input(.85, title="Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%")
new = input(false, title="-------Text Plots Below Use Original Criteria-------" )
sbc = input(false, title="Show Text Plot if WVF WAS True and IS Now False")
sbcc = input(false, title="Show Text Plot if WVF IS True")
new2 = input(false, title="-------Text Plots Below Use FILTERED Criteria-------" )
sbcFilt = input(true, title="Show Text Plot For Filtered Entry")
sbcAggr = input(true, title="Show Text Plot For AGGRESSIVE Filtered Entry")
ltLB = input(40, minval=25, maxval=99, title="Long-Term Look Back Current Bar Has To Close Below This Value OR Medium Term--Default=40")
mtLB = input(14, minval=10, maxval=20, title="Medium-Term Look Back Current Bar Has To Close Below This Value OR Long Term--Default=14")
str = input(3, minval=1, maxval=9, title="Entry Price Action Strength--Close > X Bars Back---Default=3")
//Alerts Instructions and Options Below...Inputs Tab
new4 = input(false, title="-------------------------Turn On/Off ALERTS Below---------------------" )
new5 = input(false, title="----To Activate Alerts You HAVE To Check The Boxes Below For Any Alert Criteria You Want----")
sa1 = input(false, title="Show Alert WVF = True?")
sa2 = input(false, title="Show Alert WVF Was True Now False?")
sa3 = input(false, title="Show Alert WVF Filtered?")
sa4 = input(false, title="Show Alert WVF AGGRESSIVE Filter?")
//Williams Vix Fix Formula
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100
sDev = mult * stdev(wvf, bbl)
midLine = sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (highest(wvf, lb)) * ph
//Filtered Bar Criteria
upRange = low > low[1] and close > high[1]
upRange_Aggr = close > close[1] and close > open[1]
//Filtered Criteria
filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh))
filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and not (wvf < upperBand and wvf < rangeHigh)
//Alerts Criteria
alert1 = wvf >= upperBand or wvf >= rangeHigh ? 1 : 0
alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh) ? 1 : 0
alert3 = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered ? 1 : 0
alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr ? 1 : 0
//Coloring Criteria of Williams Vix Fix
col = wvf >= upperBand or wvf >= rangeHigh ? lime : gray
isOverBought = (crossover(k,d) and k > StochOverBought) ? 1 : 0
isOverBoughtv2 = k > StochOverBought ? 1 : 0
filteredAlert = alert3 ? 1 : 0
aggressiveAlert = alert4 ? 1 : 0
plot(isOverBought, "Overbought / Crossover", style=line, color=red)
plot(filteredAlert, "Filtered Alert", style=line, color=fuchsia)
plot(aggressiveAlert, "Aggressive Alert", style=line, color=orange)
if (filteredAlert or aggressiveAlert)
strategy.entry("Long", strategy.long)
if (isOverBought)
strategy.close("Long")