该策略是一个基于均线交叉信号和趋势过滤的交易系统。它结合了短期SMA(9周期和15周期)的交叉信号以及长期EMA(200周期)作为趋势过滤器,通过在不同时间周期上的均线交叉来捕捉市场趋势。系统还包含了再入场机制,可以在趋势延续时重新建仓。
策略采用三重均线系统进行交易决策: 1. 使用9周期和15周期的简单移动平均线(SMA)产生交易信号 2. 使用200周期指数移动平均线(EMA)作为趋势过滤器 3. 当短期SMA(9周期)向上穿越15周期SMA且价格在200周期EMA之上时,产生做多信号 4. 当短期SMA(9周期)向下穿越15周期SMA且价格在200周期EMA之下时,产生做空信号 5. 系统还包含再入场逻辑,允许在初始交叉信号后,只要价格维持在200EMA的正确一侧,就可以重新建仓
该策略通过结合多重均线系统和趋势过滤器,构建了一个完整的趋势跟踪交易系统。它的主要优势在于能够在强趋势市场中获得可观收益,同时通过均线过滤和再入场机制提高了系统的稳定性。虽然存在一些固有风险,但通过优化方向的实施可以进一步提升策略的性能。该策略适合追踪中长期市场趋势,对于有耐心的交易者来说是一个可靠的交易工具。
/*backtest
start: 2024-02-19 00:00:00
end: 2025-02-17 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("SMA Crossover with EMA Filter", overlay=true)
// Define indicators
sma9 = ta.sma(close, 9)
sma15 = ta.sma(close, 15)
ema200 = ta.ema(close, 200)
// Crossover conditions
bullish_crossover = ta.crossover(sma9, sma15) // Buy signal
bearish_crossover = ta.crossunder(sma9, sma15) // Sell signal
// Filters
above_ema200 = close > ema200
below_ema200 = close < ema200
// Buy condition (only above 200 EMA)
buy_signal = bullish_crossover and above_ema200
if buy_signal
strategy.entry("Buy", strategy.long)
// Sell condition (only below 200 EMA)
sell_signal = bearish_crossover and below_ema200
if sell_signal
strategy.entry("Sell", strategy.short)
// Exit condition if the signal reverses
exit_long = bearish_crossover
exit_short = bullish_crossover
if exit_long
strategy.close("Buy")
if exit_short
strategy.close("Sell")
// Re-entry condition when price crosses EMA 200 after a prior crossover
buy_reentry = ta.barssince(bullish_crossover) > 0 and above_ema200
sell_reentry = ta.barssince(bearish_crossover) > 0 and below_ema200
if buy_reentry
strategy.entry("Buy", strategy.long)
if sell_reentry
strategy.entry("Sell", strategy.short)
// Plot indicators
plot(sma9, color=color.blue, title="SMA 9")
plot(sma15, color=color.red, title="SMA 15")
plot(ema200, color=color.orange, title="EMA 200")