本策略是一个基于双均线系统和RSI指标的趋势跟踪交易系统。该策略结合了均线交叉信号、RSI超买超卖判断以及价格突破确认,构建了一个多重过滤的交易决策框架。策略通过6周期和82周期的指数移动平均线(EMA)来捕捉中短期趋势,同时利用相对强弱指数(RSI)来过滤市场过热和过冷的情况,最后通过价格突破来确认交易信号。
策略的核心逻辑包含三个维度的信号过滤: 1. 趋势判断:使用快速EMA(6周期)和慢速EMA(82周期)的交叉来判断趋势方向。当快线上穿慢线时产生做多信号,当快线下穿慢线时产生做空信号。 2. 动量过滤:使用14周期的RSI指标来过滤过度追涨杀跌的情况。当RSI大于70时认为市场过热,抑制做多;当RSI小于22时认为市场过冷,抑制做空。 3. 价格确认:要求在入场时必须有价格突破确认。做多要求收盘价创新高,做空要求收盘价创新低。
该策略通过均线系统和RSI指标的巧妙结合,构建了一个逻辑严密的趋势跟踪系统。策略的多重过滤机制有效控制了风险,但也可能错过部分交易机会。通过持续优化和完善,策略有望在不同市场环境下都能保持稳定表现。
/*backtest
start: 2024-02-17 00:00:00
end: 2025-02-15 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA RSI Strategy", overlay=true)
// Input Parameters
emaShortLength = input.int(6, title="EMA Short Length")
emaLongLength = input.int(82, title="EMA Long Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.float(70, title="RSI Overbought Level")
rsiOversold = input.float(22, title="RSI Oversold Level")
// Calculations
emaShort = ta.ema(close, emaShortLength)
emaLong = ta.ema(close, emaLongLength)
rsi = ta.rsi(close, rsiLength)
// Conditions
emaBuyCondition = ta.crossover(emaShort, emaLong)
emaSellCondition = ta.crossunder(emaShort, emaLong)
higherHighCondition = close > ta.highest(close[1], 1)
lowerLowCondition = close < ta.lowest(close[1], 1)
rsiNotOverbought = rsi < rsiOverbought
rsiNotOversold = rsi > rsiOversold
// Entry Signals
buySignal = emaBuyCondition and rsiNotOverbought and higherHighCondition
sellSignal = emaSellCondition and rsiNotOversold and lowerLowCondition
// Execute Trades
if (buySignal)
strategy.entry("Buy", strategy.long)
if (sellSignal)
strategy.entry("Sell", strategy.short)
// Plotting
plot(emaShort, color=color.green, title="EMA Short")
plot(emaLong, color=color.red, title="EMA Long")
plot(rsi, title="RSI", color=color.blue, linewidth=1)
hline(rsiOverbought, title="RSI Overbought", color=color.red, linestyle=hline.style_dotted)
hline(rsiOversold, title="RSI Oversold", color=color.green, linestyle=hline.style_dotted)