本策略名称为“双指数移动平均线与三指数移动平均线交叉策略”(Dual Exponential Moving Average and Triple Exponential Moving Average Crossover Strategy)。该策略结合了双指数移动平均线(DEMA)和三指数移动平均线(TEMA)的交叉信号,通过DEMA和TEMA的金叉死叉来判断入场出场。
本策略主要基于双指数移动平均线(DEMA)和三指数移动平均线(TEMA)的交叉来产生交易信号。
双指数移动平均线(DEMA)的计算公式为:
DEMA = 2*EMA1 - EMA2
其中,EMA1和EMA2分别是长度周期为N的Exponential Moving Average。DEMA结合了EMA的平滑性和响应迅速性。
三指数移动平均线(TEMA)的计算公式为:
TEMA = 3*(EMA1 - EMA2) + EMA3
其中,EMA1、EMA2和EMA3分别是长度周期为N的Exponential Moving Average。TEMA通过三次指数平滑,能够过滤假突破。
当DEMA上穿TEMA时,产生买入信号;当DEMA下穿TEMA时,产生卖出信号。根据双曲线交叉的原理,可以抓住周期转换,进出场及时。
本策略通过双指数移动平均线和三指数移动平均线的交叉形成交易信号,结合DEMA的响应速度和TEMA的滤波作用,可以提高交易精确度。但单一指标组合易受错觉影响,仍需要多种验证工具的辅助,才能形成系统的交易体系,从而取得长期稳定收益。
/*backtest
start: 2023-12-03 00:00:00
end: 2024-01-02 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("DEMA-TEMA Cross Strategy", shorttitle="DEMA-TEMA Cross", overlay=true)
// Input options for Double EMA (DEMA)
dema_length = input.int(10, title="DEMA Length", minval=1)
dema_src = input(close, title="DEMA Source")
// Calculate Double EMA (DEMA)
dema_e1 = ta.ema(dema_src, dema_length)
dema_e2 = ta.ema(dema_e1, dema_length)
dema = 2 * dema_e1 - dema_e2
// Input options for Triple EMA (TEMA)
tema_length = input.int(8, title="TEMA Length", minval=1)
tema_src = input(close, title="TEMA Source")
// Calculate Triple EMA (TEMA)
tema_ema1 = ta.ema(tema_src, tema_length)
tema_ema2 = ta.ema(tema_ema1, tema_length)
tema_ema3 = ta.ema(tema_ema2, tema_length)
tema = 3 * (tema_ema1 - tema_ema2) + tema_ema3
// Crossover signals for long (small green arrow below candle)
crossover_long = ta.crossover(dema, tema)
// Crossunder signals for short (small red arrow above candle)
crossunder_short = ta.crossunder(dema, tema)
plotshape(crossunder_short ? 1 : na, title="Short Entry", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
plotshape(crossover_long ? -1 : na, title="Long Entry", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plot(dema, "DEMA", color=color.green)
plot(tema, "TEMA", color=color.blue)
if (crossover_long)
strategy.entry("Long", strategy.long)
if (crossunder_short)
strategy.entry("Short", strategy.short)