This strategy combines dual moving average crossover, RSI, and stochastic indicators to seek high-probability trading opportunities in short-term trading through the joint confirmation of multiple technical indicators. The strategy uses the crossover of 20-day and 50-day moving averages as the main trading signal, and incorporates RSI and stochastic indicators as auxiliary judgments to double-check the trading signals. In addition, the strategy also employs ATR as the basis for stop-loss and take-profit, managing positions with a fixed risk-reward ratio, striving to obtain stable returns while controlling risks.
This strategy is a short-term trading strategy based on dual moving averages, RSI, and stochastic indicators. It controls trading risks while grasping trend opportunities through the joint confirmation of multiple technical indicators. The strategy logic is clear, parameters are easy to optimize, and it is suitable for investors engaged in short-term trading. However, the strategy also has some shortcomings, such as limited trend-grasping ability and lack of dynamic management of positions and capital. These problems can be improved by introducing more technical indicators, optimizing signals and position management, etc., in order to further enhance the strategy’s performance.
/*backtest start: 2024-05-17 00:00:00 end: 2024-06-16 00:00:00 period: 4h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Cruce de Medias con Filtros de RSI y Estocástico", overlay=true) // Definir parámetros de las medias móviles fast_length = input(20, title="Periodo de Media Rápida") slow_length = input(50, title="Periodo de Media Lenta") // Calcular medias móviles fast_ma = ta.sma(close, fast_length) slow_ma = ta.sma(close, slow_length) // Añadir filtro RSI rsi_length = input(7, title="Periodo del RSI") rsi = ta.rsi(close, rsi_length) rsi_overbought = input(70, title="RSI Sobrecomprado") rsi_oversold = input(30, title="RSI Sobrevendido") // Añadir filtro Estocástico k_period = input(7, title="K Periodo del Estocástico") d_period = input(3, title="D Periodo del Estocástico") smooth_k = input(3, title="Suavización del Estocástico") stoch_k = ta.sma(ta.stoch(close, high, low, k_period), smooth_k) stoch_d = ta.sma(stoch_k, d_period) stoch_overbought = input(80, title="Estocástico Sobrecomprado") stoch_oversold = input(20, title="Estocástico Sobrevendido") // Definir niveles de stop-loss y take-profit con ratio 2:1 risk = input(1, title="Riesgo en ATR") reward_ratio = input(2, title="Ratio Riesgo/Beneficio") atr_length = input(14, title="Periodo del ATR") atr = ta.atr(atr_length) stop_loss = risk * atr take_profit = reward_ratio * stop_loss // Señal de compra long_condition = ta.crossover(fast_ma, slow_ma) and rsi < rsi_overbought and stoch_k < stoch_overbought if (long_condition) strategy.entry("Compra", strategy.long) // Señal de venta short_condition = ta.crossunder(fast_ma, slow_ma) and rsi > rsi_oversold and stoch_k > stoch_oversold if (short_condition) strategy.entry("Venta", strategy.short) // Configurar Stop-Loss y Take-Profit para posiciones largas if (strategy.position_size > 0) strategy.exit("Take Profit/Stop Loss", from_entry="Compra", stop=low - stop_loss, limit=high + take_profit) // Configurar Stop-Loss y Take-Profit para posiciones cortas if (strategy.position_size < 0) strategy.exit("Take Profit/Stop Loss", from_entry="Venta", stop=high + stop_loss, limit=low - take_profit) // Plotear las medias móviles en el gráfico plot(fast_ma, title="Media Rápida (50)", color=color.blue) plot(slow_ma, title="Media Lenta (200)", color=color.red) // Plotear RSI y Estocástico en subgráficos hline(rsi_overbought, "RSI Sobrecomprado", color=color.red) hline(rsi_oversold, "RSI Sobrevendido", color=color.green) plot(rsi, title="RSI", color=color.orange, linewidth=2) hline(stoch_overbought, "Estocástico Sobrecomprado", color=color.red) hline(stoch_oversold, "Estocástico Sobrevendido", color=color.green) plot(stoch_k, title="Estocástico K", color=color.purple, linewidth=2) plot(stoch_d, title="Estocástico D", color=color.purple, linewidth=1, style=plot.style_stepline)