Strategy vault / Trend following
Dual EMA RSI Crossover Strategy with Dynamic Take Profit Stop Loss
This is a quantitative trading strategy based on dual EMA crossover combined with RSI indicator, integrated with dynamic take-profit and stop-loss mechanisms. The strategy utilizes 9-period and 21-period Exponential…

Overview
This is a quantitative trading strategy based on dual EMA crossover combined with RSI indicator, integrated with dynamic take-profit and stop-loss mechanisms. The strategy utilizes 9-period and 21-period Exponential Moving Averages (EMA) as primary trend indicators, coupled with the Relative Strength Index (RSI) as a filter condition, managing risk and profit through dynamic take-profit and stop-loss levels.
Strategy Principles
The strategy uses the crossover of fast EMA (9-period) and slow EMA (21-period) to capture trend changes. Long positions are opened when the fast line crosses above the slow line and RSI is below 70; short positions are opened when the fast line crosses below the slow line and RSI is above 30. Each trade is set with a 1.5% take-profit and 1% stop-loss, with this dynamic mechanism automatically adjusting based on entry prices.
Strategy Advantages
- Combination of trend following and oscillator indicators improves signal quality
- Dynamic take-profit/stop-loss mechanism effectively controls risk per trade
- Avoids entering in extreme overbought/oversold areas
- Simple and maintainable strategy logic
- Flexible parameter configuration for different market conditions
Strategy Risks
- False breakout signals may occur frequently in ranging markets
- Fixed percentage take-profit/stop-loss may not suit all market conditions
- Dual EMA system may be slow to react at trend reversal points
- RSI filter might miss important trend beginnings
- Lack of consideration for volume and other important market information
Optimization Directions
- Incorporate volume indicators to validate trend validity
- Dynamically adjust take-profit/stop-loss ratios based on volatility
- Add trend strength filters
- Optimize EMA periods, consider adaptive periods
- Include market environment assessment module for parameter adaptation
- Consider implementing periodic take-profit/stop-loss position adjustment mechanism
Summary
This is a well-structured and logically rigorous quantitative trading strategy. It captures trends through EMA crossovers, filters entry timing with RSI, and manages risk with dynamic take-profit/stop-loss levels. While it has certain limitations, the suggested optimization directions can further enhance strategy stability and profitability. The strategy serves as a solid foundation framework that can be optimized based on specific trading instruments and market conditions.
Source Pine Script
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Estrategia BTC/USDT - Ajustada", overlay=true)
// Definición de las EMAs
emaRapida = ta.ema(close, 9)
emaLenta = ta.ema(close, 21)
// Cálculo del RSI
rsi = ta.rsi(close, 14)
// Condiciones de compra y venta
longCondition = ta.crossover(emaRapida, emaLenta) and rsi < 70
shortCondition = ta.crossunder(emaRapida, emaLenta) and rsi > 30
// Ajustes de Take Profit y Stop Loss
takeProfitLong = close * 1.015 // Take Profit del 1.5% para Long
stopLossLong = close * 0.99 // Stop Loss del 1% para Long
takeProfitShort = close * 0.985 // Take Profit del 1.5% para Short
stopLossShort = close * 1.01 // Stop Loss del 1% para Short
// Ejecución de la estrategia
if (longCondition)
strategy.entry("Compra", strategy.long)
strategy.exit("Take Profit Long", "Compra", limit=takeProfitLong, stop=stopLossLong)
if (shortCondition)
strategy.entry("Venta", strategy.short)
strategy.exit("Take Profit Short", "Venta", limit=takeProfitShort, stop=stopLossShort)
// Visualización de las EMAs
plot(emaRapida, color=color.green, linewidth=2, title="EMA Rápida")
plot(emaLenta, color=color.red, linewidth=2, title="EMA Lenta")
Published by ChaoZhang on the FMZ strategy square · last modified 2024-11-25. 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-EMA-RSI-Crossover-Strategy-with-Dynamic-Take-Profit-Stop-Loss.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
- Advanced Multi Indicator Multi Dimensional Trend Cross Quantitative StrategyPine Script · Trend following · 3h
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dual EMA Crossover with RSI Trend Confirmation StrategyPine Script · Trend following · 3h
- Dual Mode Adaptive Trend Trading Strategy EMA Crossover with ATR Volatility Based Risk Management SystemPine Script · Trend following · 1d