0bps

Strategy vault / Momentum

Dynamic EMA System Combined with RSI Momentum Indicator for Optimized Intraday Trading Strategy

This is an intraday trading strategy based on a dual Exponential Moving Average (EMA) system combined with the Relative Strength Index (RSI). The strategy identifies market trends and trading opportunities through…

Author
ChaoZhang
Complexity
Starter · 58 lines
Parameters
0
Backtest bar
1h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

This is an intraday trading strategy based on a dual Exponential Moving Average (EMA) system combined with the Relative Strength Index (RSI). The strategy identifies market trends and trading opportunities through crossover signals of fast and slow EMAs, confirmed by RSI momentum indicator, while incorporating stop-loss and take-profit mechanisms for risk management. The strategy employs a money management approach, using a fixed percentage of account equity for trading.

Strategy Principles

The core logic includes several key elements:

  1. Uses two EMAs with different periods (default 12 and 26) as trend indicators
  2. Incorporates RSI (default 14 periods) as momentum confirmation
  3. Long entry condition: fast EMA crosses above slow EMA with RSI above 50
  4. Short entry condition: fast EMA crosses below slow EMA with RSI below 50
  5. Uses fixed 20% of account equity for position sizing
  6. Integrates adjustable stop-loss (default 1%) and take-profit (default 2%)
  7. Implements position closure on reverse crossover signals

Strategy Advantages

  1. Systematic trading logic reducing emotional interference
  2. Combines trend and momentum confirmation for reliable signals
  3. Comprehensive risk management with fixed proportion position sizing and stop parameters
  4. Optimizable parameters for different market conditions
  5. Applicable across multiple timeframes with good adaptability
  6. Clear entry and exit mechanisms for easy execution and backtesting

Strategy Risks

  1. Potential false breakout signals in ranging markets
  2. Lag inherent in EMA indicators may miss crucial turning points
  3. Fixed stop-loss and take-profit levels may not suit all market conditions
  4. RSI might generate premature reversal signals in strong trends
  5. Requires ongoing monitoring and parameter adjustment

Strategy Optimization Directions

  1. Introduce volatility indicators (like ATR) for dynamic stop adjustments
  2. Add volume indicators for additional signal confirmation
  3. Develop adaptive parameter adjustment mechanisms
  4. Implement time filters to avoid unfavorable trading periods
  5. Consider adding trend strength filters to improve trade quality
  6. Optimize money management algorithm for more flexible position sizing

Summary

This strategy builds a complete trading system by combining EMA trend system with RSI momentum indicator. Its strengths lie in systematic trading logic and comprehensive risk management, though market condition impacts must be considered. Through continuous optimization and adjustment, the strategy can better adapt to different market conditions and improve trading results.

Source Pine Script

/*backtest
start: 2024-12-17 00:00:00
end: 2025-01-16 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/

//@version=5
strategy("Estrategia Intradía - Cruce EMA + RSI - Optimizado", overlay=true, pyramiding=0, default_qty_type=strategy.percent_of_equity, default_qty_value=20)

// Parámetros CON rangos de optimización
ema_fast_length = input.int(title="Período EMA Rápida", defval=12, minval=5, maxval=30, step=1)
ema_slow_length = input.int(title="Período EMA Lenta", defval=26, minval=15, maxval=50, step=1)
rsi_length = input.int(title="Período RSI", defval=14, minval=7, maxval=21, step=1)
rsi_overbought = input.int(title="Nivel de Sobrecompra RSI", defval=70, minval=60, maxval=80, step=1)
rsi_oversold = input.int(title="Nivel de Sobreventa RSI", defval=30, minval=20, maxval=40, step=1)
stop_loss_percent = input.float(title="Stop Loss (%)", defval=1.0, minval=0.1, maxval=3.0, step=0.1)
take_profit_percent = input.float(title="Take Profit (%)", defval=2.0, minval=0.5, maxval=5.0, step=0.1)

// Cálculos
ema_fast = ta.ema(close, ema_fast_length)
ema_slow = ta.ema(close, ema_slow_length)
rsi = ta.rsi(close, rsi_length)

// Condiciones de entrada
longCondition = ta.crossover(ema_fast, ema_slow) and rsi > 50
shortCondition = ta.crossunder(ema_fast, ema_slow) and rsi < 50

// Gestión de entradas y salidas
var float longQty = na
var float shortQty = na

if longCondition
    longQty := 20 / close
    strategy.entry("Long", strategy.long, qty=longQty)
    if stop_loss_percent > 0 and take_profit_percent > 0
        strategy.exit("Exit Long", "Long", stop=close * (1 - stop_loss_percent / 100), limit=close * (1 + take_profit_percent / 100))

if strategy.position_size > 0 and ta.crossunder(ema_fast, ema_slow)
    strategy.close("Long")
    longQty := na

if shortCondition
    shortQty := 20 / close
    strategy.entry("Short", strategy.short, qty=shortQty)
    if stop_loss_percent > 0 and take_profit_percent > 0
        strategy.exit("Exit Short", "Short", stop=close * (1 + stop_loss_percent / 100), limit=close * (1 - take_profit_percent / 100))

if strategy.position_size < 0 and ta.crossover(ema_fast, ema_slow)
    strategy.close("Short")
    shortQty := na

// Visualizaciones
plot(ema_fast, color=color.blue, title="EMA Rápida")
plot(ema_slow, color=color.orange, title="EMA Lenta")
plot(rsi, color=color.purple, title="RSI")
hline(50, color=color.gray)

Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-17. 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.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Dynamic-EMA-System-Combined-with-RSI-Momentum-Indicator-for-Optimized-Intraday-Trading-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. 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

esc

Try , , or .

↑↓ move↵ open