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