Strategy vault / Trend following
Dual Exponential Moving Average and Relative Strength Index Crossover Strategy
This strategy is a trend-following trading system that combines dual Exponential Moving Averages (EMA) with the Relative Strength Index (RSI). Operating on a 5-minute timeframe, it captures market trends through the…

Overview
This strategy is a trend-following trading system that combines dual Exponential Moving Averages (EMA) with the Relative Strength Index (RSI). Operating on a 5-minute timeframe, it captures market trends through the crossover of short-term and long-term EMAs along with RSI confirmation, while incorporating fixed percentage take-profit and stop-loss for risk management.
Strategy Principles
The strategy is based on the following core components:
- Uses a dual EMA system with 9-period and 21-period for trend direction identification
- Incorporates 14-period RSI for trend confirmation
- Generates long signals when short EMA crosses above long EMA with RSI above 50
- Generates short signals when short EMA crosses below long EMA with RSI below 50
- Implements 1.5% take-profit and 0.5% stop-loss for risk management
Strategy Advantages
- Robust Signal System: Combines trend (EMA) and momentum (RSI) indicators for dual confirmation, effectively reducing false signals
- Comprehensive Risk Management: Uses fixed-ratio take-profit and stop-loss, ensuring controllable risk for each trade
- Clear Trading Logic: Entry and exit conditions are well-defined, easy to understand and execute
- High Adaptability: Can be optimized through parameter adjustment to suit different market conditions
Strategy Risks
- Choppy Market Risk: May generate frequent false breakout signals in ranging markets
- Slippage Risk: High-frequency trading on 5-minute timeframe may face significant slippage
- Fixed Stop-Loss Risk: Percentage-based fixed stops may be easily triggered in high volatility
- Trend Reversal Risk: May experience larger drawdowns during sudden trend reversals
Strategy Optimization Directions
- Dynamic Stop-Loss: Consider incorporating ATR indicator for dynamic stop-loss adjustment
- Market Environment Filter: Add volatility indicators to screen suitable trading conditions
- Position Sizing Optimization: Implement dynamic position sizing based on volatility and risk metrics
- Trading Time Optimization: Analyze performance across different time windows to optimize trading hours
Summary
This is a complete trading system combining technical indicators and risk management. The strategy effectively identifies trends through EMA and RSI collaboration while controlling risk using fixed take-profit and stop-loss levels. Although it has certain limitations, the suggested optimization directions can further enhance the strategy's stability and profitability. The strategy is suitable for traders seeking steady returns, particularly in markets with clear trends.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("5-Minute EMA + RSI Strategy", overlay=true, shorttitle="EMA RSI")
// Inputs
ema_short_length = input.int(9, title="Short EMA Length", minval=1)
ema_long_length = input.int(21, title="Long EMA Length", minval=1)
rsi_length = input.int(14, title="RSI Length")
rsi_overbought = input.int(70, title="RSI Overbought Level")
rsi_oversold = input.int(30, title="RSI Oversold Level")
// Calculate EMAs
ema_short = ta.ema(close, ema_short_length)
ema_long = ta.ema(close, ema_long_length)
// Calculate RSI
rsi = ta.rsi(close, rsi_length)
// Plot EMAs
plot(ema_short, title="Short EMA", color=color.blue, linewidth=2)
plot(ema_long, title="Long EMA", color=color.red, linewidth=2)
// Conditions for Entries
long_condition = ta.crossover(ema_short, ema_long) and rsi > 50
short_condition = ta.crossunder(ema_short, ema_long) and rsi < 50
// Execute Trades
if (long_condition)
strategy.entry("Buy", strategy.long)
if (short_condition)
strategy.entry("Sell", strategy.short)
// Risk Management: Take Profit & Stop Loss
take_profit_perc = input.float(1.5, title="Take Profit %", step=0.1) // 1.5% target
stop_loss_perc = input.float(0.5, title="Stop Loss %", step=0.1) // 0.5% stop
strategy.exit("Take Profit/Stop Loss", "Buy",
profit=take_profit_perc, loss=stop_loss_perc)
strategy.exit("Take Profit/Stop Loss", "Sell",
profit=take_profit_perc, loss=stop_loss_perc)
// Add Visual Alerts
plotshape(long_condition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(short_condition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-20. 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/Dual-Exponential-Moving-Average-and-Relative-Strength-Index-Crossover-Strategy.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
- Adaptive ATR and RSI Trend Following Strategy with Trailing Stop LossPine Script · Trend following · 1h
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dual Mode Adaptive Trend Trading Strategy EMA Crossover with ATR Volatility Based Risk Management SystemPine Script · Trend following · 1d
- Dynamic Dual EMA Crossover Strategy with Adaptive Profit Loss ControlPine Script · Trend following · 1d
- Dynamic Multi Timeframe ATR Crossover Strategy Optimizing Trend Following and Risk Management with Flexible ParametersPine Script · Trend following · 1h