该策略基于三个时间周期的平滑异同平均线指标,当不同周期指标同向看涨或看跌时,产生交易信号。目的是利用多时间框架确认趋势,降低假信号概率。
平滑异同平均线(Heiken Ashi)指标不同于普通K线,其计算方式可平滑价格曲线,识别趋势较为准确。
本策略采用日线、周线和月线三个时间周期的平滑异同平均线指标。当三者同向看涨,即出现所有时间周期的火烛线为绿色时,产生买入信号;当三者同看跌,即火烛线全部为红色时,产生卖出信号。
入场后,只要任一时间周期平滑异同平均线转向,即产生平仓信号。
多时间框架验证,可减少假信号,增强稳定性。
平滑异同平均线指标可识别趋势,减少噪音。
规则简单清晰,容易实施。
可灵活选择时间周期组合,适应不同品种。
无参数优化,极易操作。
多重条件限制,可能错过交易机会。可降低条件限制。
平滑异同平均线滞后问题仍存在,可能延迟信号。可结合其他指标进行优化。
未设止损,无法控制风险。可加入移动止损策略。
盈亏比例固定,缺乏灵活性。可设置动态止盈止损。
仅基于指标,容易产生假信号。可加入量价确认机制。
测试添加更多时间框架,如15分钟或60分钟。
优化平滑异同平均线参数,提高灵敏度。
加入移动止损策略,以控制风险。
研究加入市场结构指标,避开震荡范围。
新增再入场条件,延长持仓周期。
该策略利用多时间周期平滑异同平均线指标的优点实现趋势跟踪,但仅基于指标易产生假信号。可通过添加更多指标、止损策略、优化参数等方法进行改进,使策略更可靠。整体来说,多时间框架验证思路值得学习借鉴。
/*backtest
start: 2023-01-01 00:00:00
end: 2023-03-23 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
args: [["v_input_5",true]]
*/
//@version=4
strategy("Heiken Ashi MTF Strategy")
ha_t = heikinashi(syminfo.tickerid)
res = input('D', title="TM 1")
ha_open = security(ha_t, res, open)
ha_close = security(ha_t, res, close)
ha_dif = ha_open-ha_close
ha_diff=iff(ha_dif > 0, 1, iff(ha_dif<0, 2, 3))
res2 = input('W', title="TM 2")
ha_open2 = security(ha_t, res2, open)
ha_close2 = security(ha_t, res2, close)
ha_dif2 = ha_open2-ha_close2
ha_diff2=iff(ha_dif2 > 0, 1, iff(ha_dif2<0, 2, 3))
res3 = input('M', title="TM 3")
ha_open3 = security(ha_t, res3, open)
ha_close3 = security(ha_t, res3, close)
ha_dif3 = ha_open3-ha_close3
ha_diff3=iff(ha_dif3 > 0, 1, iff(ha_dif3<0, 2, 3))
plot(15, title="TF1", color=iff(ha_diff==1, color.red, iff(ha_diff==2, color.green, color.white)), style=plot.style_circles, linewidth=5, join=true)
plot(14, title="TF2", color=iff(ha_diff2==1, color.red, iff(ha_diff2==2, color.green, color.white)), style=plot.style_circles, linewidth=5, join=true)
plot(13, title="TF3", color=iff(ha_diff3==1, color.red, iff(ha_diff3==2, color.green, color.white)), style=plot.style_circles, linewidth=5, join=true)
short = ha_diff ==1 and ha_diff2==1 and ha_diff3 ==1
long = ha_diff ==2 and ha_diff2==2 and ha_diff3 ==2
exitlong = ha_diff ==1 or ha_diff2==1 or ha_diff3 ==1
exitshort = ha_diff ==2 or ha_diff2==2 or ha_diff3 ==2
longA = input(true)
shortA = input(false)
if(longA)
strategy.entry("long",1,when=long)
strategy.close("long",when=exitlong)
if(shortA)
strategy.entry("short",0,when=short)
strategy.close("short",when=exitshort)