本策略是一个结合简单移动平均线(SMA)与相对强弱指标(RSI)的趋势跟踪交易系统。它通过短期和长期移动平均线的交叉来识别趋势方向,并利用RSI进行动量确认,从而在市场中寻找高概率的交易机会。该策略还包含了完整的风险管理模块,可以有效控制每笔交易的风险。
策略的核心逻辑基于两个技术指标的配合使用: 1. 双均线系统: 采用8周期和21周期的简单移动平均线,通过均线交叉识别趋势变化。当短期均线向上穿越长期均线时产生做多信号,向下穿越时产生做空信号。 2. RSI过滤器: 使用14周期的RSI指标进行动量确认。只有当RSI低于70时才执行做多,高于30时才执行做空,以避免在过度买入或卖出的区域进行交易。 3. 风险控制: 每笔交易都设置了1%的止损和2%的止盈水平,以保护资金安全和锁定利润。
这是一个结构完整、逻辑清晰的趋势跟踪策略。通过结合SMA和RSI,既能捕捉趋势,又能避免在过度买卖区域交易。内置的风险管理机制确保了策略的稳定性。虽然存在一些固有的局限性,但通过建议的优化方向可以进一步提升策略的性能。该策略特别适合追求稳健收益的交易者使用。
/*backtest
start: 2025-02-16 00:00:00
end: 2025-02-23 00:00:00
period: 6m
basePeriod: 6m
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=6
strategy("WEN - SMA with RSI Strategy", overlay=true)
// Define input parameters
// SMA Inputs
shortLength = input(8, title="Short MA Length")
longLength = input(21, title="Long MA Length")
// RSI Inputs
rsiLength = input(14, title="RSI Length")
rsiOverbought = input(70, title="RSI Overbought")
rsiOversold = input(30, title="RSI Oversold")
// Calculate indicators
// Moving Averages
shortMA = ta.sma(close, shortLength)
longMA = ta.sma(close, longLength)
// RSI
rsi = ta.rsi(close, rsiLength)
// Plot indicators
plot(shortMA, title="Short MA", color=color.blue)
plot(longMA, title="Long MA", color=color.red)
// RSI is typically plotted in a separate panel in trading platforms
// Entry conditions with RSI confirmation
smaLongCondition = ta.crossover(shortMA, longMA)
smaShortCondition = ta.crossunder(shortMA, longMA)
rsiLongCondition = rsi < rsiOverbought // Not overbought for long entry
rsiShortCondition = rsi > rsiOversold // Not oversold for short entry
// Combined entry conditions
longCondition = smaLongCondition and rsiLongCondition
shortCondition = smaShortCondition and rsiShortCondition
// Execute trades
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.close("Long")
strategy.entry("Short", strategy.short)
// Set stop loss and take profit
stopLoss = input(1, title="Stop Loss (%)") / 100
takeProfit = input(2, title="Take Profit (%)") / 100
longStopLossPrice = strategy.position_avg_price * (1 - stopLoss)
longTakeProfitPrice = strategy.position_avg_price * (1 + takeProfit)
shortStopLossPrice = strategy.position_avg_price * (1 + stopLoss)
shortTakeProfitPrice = strategy.position_avg_price * (1 - takeProfit)
strategy.exit("Take Profit / Stop Loss", from_entry="Long", stop=longStopLossPrice, limit=longTakeProfitPrice)
strategy.exit("Take Profit / Stop Loss", from_entry="Short", stop=shortStopLossPrice, limit=shortTakeProfitPrice)