Multi-Indicator Dynamic Trend Crossover Quantitative Trading Strategy

MACD EMA RSI TA
Created on: 2025-02-19 15:01:13 Modified on: 2025-02-19 15:01:13
Copy: 0 Number of hits: 637
avatar of ChaoZhang ChaoZhang
1
Follow
1617
Followers

 Multi-Indicator Dynamic Trend Crossover Quantitative Trading Strategy

Overview

This strategy is a trend-following trading system based on multiple technical indicators, combining three classic technical indicators: Exponential Moving Average (EMA), Moving Average Convergence Divergence (MACD), and Relative Strength Index (RSI). It captures market trend changes and momentum through parameter settings including fast EMA (9 periods) and slow EMA (21 periods), MACD (12,26,9), and RSI (14), generating trading signals at indicator crossovers and threshold breakthroughs.

Strategy Principle

The core logic of the strategy is to identify market trend turning points through the confirmation of multiple technical indicators. It includes three aspects of signal confirmation: 1. EMA Crossover Signal: A long signal is generated when the fast EMA crosses above the slow EMA, and a short signal when it crosses below. 2. MACD Crossover Signal: Long position confirmed when MACD line crosses above the signal line, short position when crossing below. 3. RSI Filter: Trades are allowed when RSI value is between 30-70, avoiding trades in excessive overbought/oversold areas. The strategy executes trades only when all three indicators show synchronized signals.

Strategy Advantages

  1. Multiple indicator cross-validation effectively reduces the impact of false signals.
  2. Combination of trend following and momentum indicators enables more accurate capture of market turning points.
  3. RSI filtering mechanism avoids trading in excessive overbought/oversold areas.
  4. Clear strategy logic facilitates parameter adjustment and optimization.
  5. Capable of both long and short trading, adapting to different market environments.

Strategy Risks

  1. Multiple indicator confirmation may lead to signal lag, missing optimal entry points.
  2. Frequent crossover signals may occur in range-bound markets, increasing trading costs.
  3. Fixed RSI thresholds may lack flexibility in different market environments.
  4. Absence of stop-loss and take-profit mechanisms may result in significant losses during high volatility.
  5. Technical indicator parameters require thorough historical data validation.

Strategy Optimization Directions

  1. Introduce adaptive indicator parameters that adjust dynamically based on market volatility.
  2. Add stop-loss and take-profit mechanisms to control single trade risk.
  3. Include volume indicator verification to improve signal reliability.
  4. Develop market environment recognition module to use different trading parameters in different market states.
  5. Introduce money management module to adjust position size dynamically based on account risk.
  6. Consider adding trend strength filtering to avoid trading in weak trends.

Summary

This strategy captures market trend changes through multiple technical indicator cross-validation, offering good reliability and adaptability. However, in practical application, attention should be paid to signal lag and over-trading issues. It is recommended to optimize through introducing adaptive parameters, stop-loss mechanisms, and market environment recognition to improve strategy stability and profitability. During implementation, it is advised to conduct thorough historical data backtesting and parameter optimization, continuously adjusting and improving based on actual trading results.

Strategy source code
/*backtest
start: 2024-02-20 00:00:00
end: 2025-02-17 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5  
strategy("EMA + MACD + RSI Strategy with Long and Short", overlay=true)
  
// Input parameters for MACD, EMA, and RSI
fast_ema_length = input.int(9, title="Fast EMA Length", minval=1)
slow_ema_length = input.int(21, title="Slow EMA Length", minval=1)

macd_short_length = input.int(12, title="MACD Short Length", minval=1)
macd_long_length = input.int(26, title="MACD Long Length", minval=1)
macd_signal_length = input.int(9, title="MACD Signal Length", minval=1)

rsi_length = input.int(14, title="RSI Length", minval=1)
rsi_oversold_level = input.int(30, title="RSI Oversold Level", minval=1)
rsi_overbought_level = input.int(70, title="RSI Overbought Level", minval=1)

// Calculate the MACD line and Signal line
[macdLine, signalLine, _] = ta.macd(close, macd_short_length, macd_long_length, macd_signal_length)

// Calculate the EMAs
fast_ema = ta.ema(close, fast_ema_length)
slow_ema = ta.ema(close, slow_ema_length)

// Calculate the RSI
rsi = ta.rsi(close, rsi_length)

// Conditions for long entry (bullish)
macd_bullish_crossover = ta.crossover(macdLine, signalLine)  // MACD line crosses above Signal line
ema_bullish_crossover = ta.crossover(fast_ema, slow_ema)    // Fast EMA crosses above Slow EMA
rsi_above_30 = rsi > rsi_oversold_level                      // RSI above 30 (not oversold)

long_condition = macd_bullish_crossover and ema_bullish_crossover and rsi_above_30

// Conditions for short entry (bearish)
macd_bearish_crossover = ta.crossunder(macdLine, signalLine)  // MACD line crosses below Signal line
ema_bearish_crossover = ta.crossunder(fast_ema, slow_ema)    // Fast EMA crosses below Slow EMA
rsi_below_70 = rsi < rsi_overbought_level                    // RSI below 70 (not overbought)

short_condition = macd_bearish_crossover and ema_bearish_crossover and rsi_below_70

// Execute long trade
if (long_condition)
    strategy.entry("Long", strategy.long)

// Execute short trade
if (short_condition)
    strategy.entry("Short", strategy.short)

// Plot the EMAs and MACD for visualization
plot(fast_ema, color=color.green, linewidth=2, title="Fast EMA")
plot(slow_ema, color=color.red, linewidth=2, title="Slow EMA")

plot(macdLine, color=color.blue, linewidth=2, title="MACD Line")
plot(signalLine, color=color.red, linewidth=2, title="Signal Line")

hline(30, "RSI 30", color=color.green)
hline(70, "RSI 70", color=color.red)
plot(rsi, color=color.purple, linewidth=2, title="RSI")