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.
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
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.
/*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)