Momentum Enhanced Simple Moving Average and RSI Strategy for Trend Following
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…

Overview
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.
Strategy Principles
The core logic is based on the combination of two technical indicators:
- 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.
- 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.
- Risk Control: Each trade includes a 1% stop loss and 2% take profit level to protect capital and secure profits.
Strategy Advantages
- Indicator Synergy: Combines trend-following and momentum indicators for more accurate identification of market turning points.
- Robust Risk Management: Built-in stop loss and take profit mechanisms effectively control risk.
- Flexible Parameters: All key parameters can be optimized for different market conditions.
- Wide Applicability: Can be applied across multiple markets and timeframes.
- Clear Logic: Strategy rules are explicit, easy to understand and execute.
Strategy Risks
- Choppy Market Risk: May generate frequent false signals in sideways markets.
- Lag Risk: Moving averages have inherent lag, potentially missing some profit opportunities.
- Parameter Sensitivity: May require parameter adjustments in different market environments.
- Trend Dependency: Strategy performs best in strong trending markets but may underperform in other conditions.
Optimization Directions
- Introduce market environment recognition mechanism for different parameter combinations.
- Add volume indicators as confirmatory signals.
- Optimize stop loss and take profit mechanisms, consider implementing dynamic stop loss.
- Add trend strength filters to trade only in strong trending markets.
- Develop adaptive parameter adjustment mechanisms to improve strategy adaptability.
Summary
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.
Source Pine Script
/*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)Published by ianzeng123 on the FMZ strategy square · last modified 2025-02-24. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Momentum-Enhanced-Simple-Moving-Average-and-RSI-Strategy-for-Trend-Following.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- ADX Momentum Trend StrategyPine Script · Momentum · 10m
- Bollinger Bands Momentum Trend Following Quantitative StrategyPine Script · Momentum · 1d
- Cross Momentum Trend Following Strategy SMA RSI Cross Momentum SystemPine Script · Momentum · 1h
- KST EMA Momentum Trend Following StrategyPine Script · Momentum · 1d
- MACD Momentum Indicator Backtest StrategyPine Script · Momentum · 1h
- Momentum Oscillator Bollinger Band RSI Trading StrategyPine Script · Momentum · 1m