
これは、二重移動平均システム (EMA) と相対力指数 (RSI) に基づいたデイトレード戦略です。この戦略では、高速および低速の指数移動平均のクロスオーバー信号と RSI モメンタム インジケーターを組み合わせて、市場のトレンドと取引機会を特定し、ストップロスとテイクプロフィットのメカニズムを統合してリスク管理を実現します。この戦略では、資金管理モデルを使用し、口座の資産の一定の割合を使用して取引を行います。
戦略の中核となるロジックには、次の重要な要素が含まれます。
この戦略は、EMA トレンド システムと RSI モメンタム インジケーターを組み合わせて、完全な取引システムを構築します。その利点は体系的な取引ロジックと完璧なリスク管理メカニズムにありますが、市場環境が戦略のパフォーマンスに与える影響には依然として注意を払う必要があります。継続的な最適化と調整を通じて、戦略はさまざまな市場状況に適応し、取引結果を向上させることができます。
/*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)