双轨突破策略

Author: ChaoZhang, Date: 2023-09-19 16:27:12
Tags:

概述

双轨突破策略基于开盘价及前一天波动幅度设置上下轨,以突破上轨做多和突破下轨做空。该策略捕捉突破形成的趋势交易机会。

策略原理

  1. 计算最近N根K线的最高价HH和最低价LL。

  2. 计算前一天的最高收盘价HC和最低收闭价LC。

  3. 前一天波动幅度Range为HH-LC和HC-LL中的较大值。

  4. 上轨BuyLine为开盘价加上k1*Range。

  5. 下轨SellLine为开盘价减去k2*Range。

  6. 当收盘价上穿上轨时做多。当收盘价下穿下轨时做空。

优势分析

该策略主要优点:

  1. 抓住开盘价附近的突破形成的趋势交易机会。

  2. 上下轨基于历史波动自动设置,避免主观。

  3. k值可自定义,适应涨跌幅不同的品种。

  4. 突破形态清晰,信号质量较高。

  5. 可灵活设置持仓周期,捕捉不同级别趋势。

风险分析

该策略主要风险:

  1. 无法确定上下轨合理范围,存在过优化风险。

  2. 突破可能为假突破,须设置止损。

  3. 固定持仓时间无法动态响应行情。

  4. 回测周期较短,可能存在曲拟合。

  5. 多空双边交易,实现难度较大。

对应解决方法:

  1. 优化k值参数,扩大数据回测范围。

  2. 设置合理止损位置,控制单笔损失。

  3. 增加趋势判断,避免逆势交易。

  4. 考虑缩短持仓周期至当日。

  5. 实盘验证,分阶段逐步扩大仓位。

优化方向

该策略可考虑以下几点优化:

  1. 动态调整上下轨参数k值。

  2. 结合交易量等指标确认突破信号。

  3. 增加移动止损保护利润。

  4. 评估突破强弱,调整开仓手数。

  5. 区分趋势和区间,进行策略分解。

总结

双轨突破策略可以捕捉开盘价附近的趋势交易机会。但其参数设定和持仓时间优化空间较大,需要充分考虑风险控制。实盘时建议从保守参数开始,分批逐步扩大仓位。


/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-18 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("Dual Thrust Strategy",overlay=true,initial_capital=1000)
k1=input(0.67,type=float,step=0.01)
k2=input(0.62,type=float,step=0.01)
TimeFrame=input('240')
len=input(20)
HH=security(syminfo.tickerid,TimeFrame,highest(high,len),barmerge.lookahead_off)
LC=security(syminfo.tickerid,TimeFrame,lowest(close,len),barmerge.lookahead_off)
HC=security(syminfo.tickerid,TimeFrame,highest(close,len),barmerge.lookahead_off)
LL=security(syminfo.tickerid,TimeFrame,lowest(low,len),barmerge.lookahead_off)
Range=max(HH-LC,HC-LL)
BuyLine=security(syminfo.tickerid,"D",open,barmerge.lookahead_off)+k1*Range
SellLine=security(syminfo.tickerid,"D",open,barmerge.lookahead_off)-k2*Range
plot(BuyLine,color=blue,linewidth=2,offset=1,transp=70)
plot(SellLine,color=red,linewidth=2,offset=1,transp=70)


LongCondition=crossover(close,BuyLine)
ShortCondition=crossunder(close,SellLine)
strategy.entry("enter long",true,1,when=LongCondition)
strategy.entry("enter short",false,1,when=ShortCondition)
plotshape(LongCondition and strategy.position_size<0?low:na,style=shape.labelup,location=location.absolute,color=blue,text="Long",textcolor=white,size=size.small)
plotshape(ShortCondition and strategy.position_size>0?high:na,style=shape.labeldown,location=location.absolute,color=red,text="Short",textcolor=white,size=size.small)
alertcondition(LongCondition and strategy.position_size<0,title='Long_DT')
alertcondition(ShortCondition and strategy.position_size>0,title='Short_DT')

更多内容