本策略是一个基于三重指数移动平均线(TEMA)的趋势跟踪交易系统。策略通过对比短期和长期TEMA的交叉信号来捕捉市场趋势,结合波动止损来管理风险。策略在5分钟时间周期上运行,采用300和500周期的TEMA指标作为信号生成的基础。
策略的核心逻辑基于以下几个关键要素: 1. 使用两个不同周期(300和500)的TEMA指标来识别趋势方向 2. 当短期TEMA向上穿越长期TEMA时,系统产生做多信号 3. 当短期TEMA向下穿越长期TEMA时,系统产生做空信号 4. 使用10个周期的最高价和最低价来设置止损位置 5. 入场后持有位置直到出现反向信号才平仓
该策略是一个完整的趋势跟踪系统,通过TEMA指标的交叉捕捉趋势,配合动态止损管理风险。策略逻辑清晰,实现简单,具有较好的实用性。但在实盘交易中需要注意市场环境的识别和风险控制,建议在回测验证的基础上,根据实际市场情况对参数进行优化。
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("TEMA Strategy for Gold", overlay=true)
// Inputs
tema_short_length = input.int(300, title="Short TEMA Length")
tema_long_length = input.int(500, title="Long TEMA Length")
pip_value = input.float(0.10, title="Pip Value (10 pips = 1 point for Gold)")
// Calculate TEMA
tema_short = ta.ema(2 * ta.ema(close, tema_short_length) - ta.ema(ta.ema(close, tema_short_length), tema_short_length), tema_short_length)
tema_long = ta.ema(2 * ta.ema(close, tema_long_length) - ta.ema(ta.ema(close, tema_long_length), tema_long_length), tema_long_length)
// Plot TEMA
plot(tema_short, color=color.blue, title="300 TEMA")
plot(tema_long, color=color.red, title="500 TEMA")
// Crossover conditions
long_condition = ta.crossover(tema_short, tema_long)
short_condition = ta.crossunder(tema_short, tema_long)
// Calculate recent swing high/low
swing_low = ta.lowest(low, 10)
swing_high = ta.highest(high, 10)
// Convert pips to price
pip_adjustment = pip_value * syminfo.mintick
// Long entry logic
if (long_condition and strategy.position_size == 0)
stop_loss_long = swing_low - pip_adjustment
strategy.entry("Long", strategy.long)
label.new(bar_index, swing_low, style=label.style_label_down, text="Buy", color=color.green)
// Short entry logic
if (short_condition and strategy.position_size == 0)
stop_loss_short = swing_high + pip_adjustment
strategy.entry("Short", strategy.short)
label.new(bar_index, swing_high, style=label.style_label_up, text="Sell", color=color.red)
// Exit logic
if (strategy.position_size > 0 and short_condition)
strategy.close("Long")
label.new(bar_index, high, style=label.style_label_up, text="Exit Long", color=color.red)
if (strategy.position_size < 0 and long_condition)
strategy.close("Short")
label.new(bar_index, low, style=label.style_label_down, text="Exit Short", color=color.green)