趋势追踪反转与埃勒斯先导指标联合策略


创建日期: 2023-11-07 16:10:26 最后修改: 2023-11-07 16:10:26
复制: 0 点击次数: 558
avatar of ChaoZhang ChaoZhang
1
关注
1259
关注者

趋势追踪反转与埃勒斯先导指标联合策略

概述

该策略为趋势追踪反转策略与埃勒斯先导指标策略的组合,目的是获得更可靠的交易信号。趋势追踪反转策略判断趋势反转点,埃勒斯先导指标策略判断周期性转折点。组合信号更准确判定入市时机。

策略原理

趋势追踪反转策略

该策略源自Ulf Jensen的《我如何在期货市场上将资金翻三番》一书第183页。它属于反转类型策略。当收盘价连续2日高于前一日收盘价,且9日Stochastic慢速线低于50时,做多;当收盘价连续2日低于前一日收盘价,且9日Stochastic快速线高于50时,做空。

埃勒斯先导指标策略

该策略使用日内数据,绘制单日去趋势化合成价格(Detrended Synthetic Price, DSP)和日内埃勒斯先导指标(Ehlers Leading Indicator, ELI)。DSP能捕捉价格主导周期,计算方法是2阶巴特沃斯滤波减去3阶滤波。ELI可提前指示周期转折点,计算方法是去趋势化合成价格减去其简单移动平均。当ELI穿过去趋势化合成价格时产生买卖信号。

优势分析

该组合策略最大优势是结合趋势反转判断和周期性转折判断,交易信号更可靠。趋势反转策略能判断突破上下轨的趋势反转点。埃勒斯先导指标又能提前指示周期性低谷和高点。两者结合能更准确抓住入市时机。

另一个优势是参数调整灵活。趋势反转策略中的股票指标参数可按市场调整;埃勒斯先导指标中的周期长度也可调整适应不同周期。

风险分析

该策略最大风险是错过趋势 persisting。因为策略等待反转信号出现才入场,可能错过早期强劲趋势阶段。此外,反转信号可能是假突破,被套也是可能。

解决方法是调整参数,缩短反转判断周期,及时捕捉趋势反转。另外可以引入止损来控制亏损。

优化方向

该策略可以从以下几个方面进行优化:

  1. 引入止损策略,以控制单笔亏损。

  2. 优化参数,调整反转信号周期,适应不同市场环境。

  3. 增加其他指标过滤,提高信号质量,减少假信号。

  4. 增加资金管理模块,控制整体仓位和风险。

  5. 测试不同品种参数效果,优化适合哪些品种。

  6. 增加机器学习模块,使参数可自适应调整。

总结

该策略结合趋势反转判断和周期性转折判断,能更可靠抓住入市时机。最大优势是信号质量好,可调整性强。最大风险是错过早期趋势,可通过调整参数、止损来控制。未来可从止损、参数优化、信号过滤等方面进行改进,使策略更适应不同市场环境。

策略源码
/*backtest
start: 2023-10-07 00:00:00
end: 2023-11-06 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 26/11/2019
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// This Indicator plots a single
// Daily DSP (Detrended Synthetic Price) and a Daily ELI (Ehlers Leading
// Indicator) using intraday data.
// Detrended Synthetic Price is a function that is in phase with the dominant
// cycle of real price data. This one is computed by subtracting a 3 pole Butterworth
// filter from a 2 Pole Butterworth filter. Ehlers Leading Indicator gives an advanced
// indication of a cyclic turning point. It is computed by subtracting the simple
// moving average of the detrended synthetic price from the detrended synthetic price.
// Buy and Sell signals arise when the ELI indicator crosses over or under the detrended
// synthetic price.
// See "MESA and Trading Market Cycles" by John Ehlers pages 64 - 70. 
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos

D_ELI(Length) =>
    pos = 0.0
    xHL2 = security(syminfo.tickerid, 'D', hl2)
    xEMA1 = ema(xHL2, Length)
    xEMA2 = ema(xHL2, 2 * Length)
    xEMA1_EMA2 = xEMA1 - xEMA2
    xResultEMA = ema(xEMA1_EMA2, Length)
    nRes = xEMA1_EMA2 - xResultEMA
    pos:= iff(nRes > 0, 1,
	       iff(nRes < 0, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & D_ELI (Ehlers Leading Indicator)", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthELI = input(7, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posD_ELI = D_ELI(LengthELI)
pos = iff(posReversal123 == 1 and posD_ELI == 1 , 1,
	   iff(posReversal123 == -1 and posD_ELI == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )