本策略基于拉里·康诺斯的经典策略思想,利用双均线系统捕捉市场的中短线震荡,在超买超卖区实现落袋为安的操作策略。
使用2周期RSI指标判断股价是否处于超卖区域。
使用长周期均线(200周期)判断大趋势方向。只有当价格高于长周期均线时才考虑建仓。
当价格高于长周期均线且RSI指标低于超卖线时,以市价单开仓做多。
当价格上涨突破短周期均线(5周期)时,以市价单全平多单止盈。
此外,策略还提供以下可配置选项:
RSI参数:周期长度、超买超卖线位置。
均线参数:长短均线周期。
RSI均线过滤:添加RSI均线判断,避免RSI指标震荡过激。
止损设置:可选择是否添加止损。
使用双均线系统,能够有效跟踪中长线趋势。
RSI指标避免在剧烈震荡中错失最佳入场时机。
可配置灵活,适合不同参数优化。
rundown突破策略,不容易漏单。
双均线策略对参数敏感,需要优化参数以达到最佳效果。
无止损设置存在亏损扩大的风险。需要谨慎资金管理,控制单笔仓位规模。
震荡行情中虚假突破可能存在亏损风险。可以考虑优化均线周期或添加其他条件作为过滤器。
回测数据拟合风险。需在多市场多时间段验证策略稳健性。
测试优化RSI和均线的参数组合,找到最佳参数。
测试不同的入场过滤条件,如交易量突增等,减少虚假信号。
加入跟踪止损来控制单笔亏损。需要评估止损设置对总体盈利的影响。
评估不同持仓时间对盈利的影响,寻找最佳持仓周期。
在更长的时间周期(如日线级别)测试策略稳健性。
本策略整合了双均线趋势跟踪和RSI指标的超买超卖特性,是一种典型的突破系统。通过参数优化、严格的资金管理和稳健性验证,该策略可以成为量化交易的有力工具。但是交易者需要警惕回测过拟合问题,在实盘中继续调整和完善策略,使之适应多变的市场环境。
/*backtest
start: 2023-09-26 00:00:00
end: 2023-10-26 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("RSI Strategy", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
//Starter Parameters
length = input(title="RSI Lenght", defval=2)
overBoughtRSI = input(title="OverBought Level for RSI", defval=10)
shortLength = input(title="Short MA Length", defval=5)
longLength = input(title="Long MA Length", defval=200)
RuleMRSI=input(title="RSI Moving Average Filter", defval= true)
lengthmrsi=input(title="RSI Moving Average Length", defval=4)
overBoughtMRSI=input(title="OverBought Level for the Moving Average of the RSI", defval=30)
Rulestop=input(title="Apply Stop Loss", defval=false)
stop_percentual=input(title="% Stop Loss", defval=10)
//RSI
vrsi = rsi(close, length)
//Moving Averages
longma = sma(close,longLength)
shortma = sma(close,shortLength)
mrsi=sma(vrsi,lengthmrsi)
//Stop Loss
stop_level = strategy.position_avg_price*((100-stop_percentual)/100)
//Backtest Period
testStartYear = input(2009, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(2, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
testPeriod() => true
//Strategy
if testPeriod() and (not na(vrsi))
if (RuleMRSI==false) and (Rulestop==false)
if (vrsi<overBoughtRSI) and (close>longma)
strategy.entry("RsiLE", strategy.long , comment="Open")
if (close>shortma)
strategy.close_all()
if (RuleMRSI==true) and (Rulestop==false)
if (vrsi<overBoughtRSI) and (close>longma) and (mrsi<overBoughtMRSI)
strategy.entry("RsiLE", strategy.long , comment="Open")
if (close>shortma)
strategy.close_all()
if (RuleMRSI==false) and (Rulestop==true)
if (vrsi<overBoughtRSI) and (close>longma)
strategy.entry("RsiLE", strategy.long , comment="Open")
strategy.exit("RsiLE", stop = stop_level)
if (close>shortma)
strategy.close_all()
if (RuleMRSI==true) and (Rulestop==true)
if (vrsi<overBoughtRSI) and (close>longma) and (mrsi<overBoughtMRSI)
strategy.entry("RsiLE", strategy.long , comment="Open")
strategy.exit("RsiLE", stop = stop_level)
if (close>shortma)
strategy.close_all()