
Esta estrategia es un sistema de negociación a corto plazo basado en una combinación de indicadores de doble línea de cruce y RSI. La estrategia utiliza una media móvil de índice de 9 períodos y 21 períodos (EMA) como base para determinar la tendencia, mientras que combina un indicador relativamente fuerte (RSI) como herramienta de confirmación de dinámica para lograr la gestión del riesgo mediante el establecimiento de paradas y paradas fijas.
La lógica central de la estrategia se basa en la interacción de dos indicadores técnicos. En primer lugar, se determina la dirección de la tendencia del mercado a través de la cruz de los EMA de 9 y 21 ciclos. Se considera una tendencia alcista cuando el EMA de corto plazo se eleva por encima del EMA de largo plazo; se considera una tendencia bajista cuando el EMA de corto plazo se eleva por encima del EMA de largo plazo.
La estrategia, mediante la combinación de cruces de línea media y indicadores RSI, construye un sistema de trading de línea corta relativamente completo. La estrategia tiene la ventaja de que la señal es clara y el riesgo es controlable, pero también hay espacio para la optimización. La estabilidad y la rentabilidad de la estrategia se pueden mejorar aún más mediante la adición de mecanismos como el stop loss dinámico y el filtro de tiempo.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-28 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("abo 3llash - EMA + RSI Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Parameters
emaShortLength = input.int(9, title="Short EMA Length")
emaLongLength = input.int(21, title="Long EMA Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
stopLossPercent = input.float(1, title="Stop Loss Percentage") / 100
takeProfitPercent = input.float(2, title="Take Profit Percentage") / 100
// Calculating EMAs and RSI
emaShort = ta.ema(close, emaShortLength)
emaLong = ta.ema(close, emaLongLength)
rsi = ta.rsi(close, rsiLength)
// Buy and Sell Conditions
buyCondition = ta.crossover(emaShort, emaLong) and rsi < rsiOverbought
sellCondition = ta.crossunder(emaShort, emaLong) and rsi > rsiOversold
// Plotting the EMAs
plot(emaShort, title="Short EMA", color=color.blue)
plot(emaLong, title="Long EMA", color=color.red)
// Generating buy and sell signals on the chart
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Strategy Execution
if (buyCondition)
strategy.entry("Buy", strategy.long)
// Set Stop Loss and Take Profit for Buy
stopLossLevel = close * (1 - stopLossPercent)
takeProfitLevel = close * (1 + takeProfitPercent)
strategy.exit("Take Profit/Stop Loss", from_entry="Buy", stop=stopLossLevel, limit=takeProfitLevel)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Set Stop Loss and Take Profit for Sell
stopLossLevel = close * (1 + stopLossPercent)
takeProfitLevel = close * (1 - takeProfitPercent)
strategy.exit("Take Profit/Stop Loss", from_entry="Sell", stop=stopLossLevel, limit=takeProfitLevel)