
This strategy is a trend-following trading system that combines Simple Moving Averages (SMA) with the Relative Strength Index (RSI). It identifies trend directions through crossovers of short-term and long-term moving averages, uses RSI for momentum confirmation, and seeks high-probability trading opportunities in the market. The strategy includes a comprehensive risk management module for effective control of trading risks.
The core logic is based on the combination of two technical indicators: 1. Dual MA System: Uses 8-period and 21-period simple moving averages to identify trend changes. Buy signals are generated when the short-term MA crosses above the long-term MA, and sell signals when it crosses below. 2. RSI Filter: Employs a 14-period RSI for momentum confirmation. Long positions are only executed when RSI is below 70, and short positions when RSI is above 30, avoiding trades in overextended areas. 3. Risk Control: Each trade includes a 1% stop loss and 2% take profit level to protect capital and secure profits.
This is a comprehensively structured trend-following strategy with clear logic. By combining SMA and RSI, it captures trends while avoiding trades in overextended areas. The built-in risk management ensures strategy stability. While there are some inherent limitations, the suggested optimization directions can further enhance strategy performance. This strategy is particularly suitable for traders seeking stable returns.
/*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)