Strategy vault / Trend following
MACD RSI Dynamic Crossover Quantitative Trading System
This strategy is a quantitative trading system that combines the Moving Average Convergence Divergence (MACD) and Relative Strength Index (RSI) indicators. The strategy identifies market trend reversal points by…

Overview
This strategy is a quantitative trading system that combines the Moving Average Convergence Divergence (MACD) and Relative Strength Index (RSI) indicators. The strategy identifies market trend reversal points by analyzing the crossover signals of these two technical indicators and overbought/oversold levels to make trading decisions. The system executes trades programmatically, automatically capturing market opportunities.
Strategy Principles
The core logic is based on two main technical indicators: MACD and RSI. The MACD indicator calculates the difference between fast (12-period) and slow (26-period) moving averages, comparing it with a signal line (9-period moving average) to determine trend direction. The RSI indicator calculates the relative strength over 14 periods to determine if the market is overbought or oversold.
Buy signals are generated when the MACD line crosses above the signal line and RSI is below 70 (overbought level). Sell signals are generated when the MACD line crosses below the signal line and RSI is above 30 (oversold level). This dual confirmation mechanism effectively filters out false signals.
Strategy Advantages
- High Signal Reliability: Combining MACD and RSI crossover confirmation significantly reduces the impact of false signals.
- Strong Parameter Adaptability: The strategy allows flexible adjustment of MACD and RSI parameters to adapt to different market conditions.
- High Automation Level: Fully programmatic strategy execution reduces emotional interference.
- Good Visualization: Clear buy/sell signals marked on charts facilitate analysis and backtesting.
- Comprehensive Risk Control: RSI overbought/oversold levels provide additional risk control measures.
Strategy Risks
- Choppy Market Risk: May generate frequent trading signals in sideways markets, increasing transaction costs.
- Lag Risk: Signal generation has inherent delay due to moving average calculations, potentially missing optimal entry points.
- Parameter Sensitivity: Optimal parameters may vary in different market environments, requiring periodic adjustment.
- False Breakout Risk: False breakthrough signals may occur during increased market volatility.
Optimization Directions
- Incorporate Volatility Indicators: Consider adding ATR or volatility indicators for dynamic parameter adjustment.
- Enhance Signal Confirmation: Add volume or other technical indicators as additional confirmation conditions.
- Add Trend Filters: Introduce longer-period moving averages as trend filters.
- Improve Stop Loss Mechanism: Design more flexible stop-loss strategies, such as trailing stops or time-based exits.
- Optimize Position Management: Dynamically adjust position sizes based on signal strength and market conditions.
Summary
The MACD-RSI Dynamic Crossover Quantitative Trading System is an automated trading strategy combining classic technical analysis indicators. Through the dual mechanism of MACD trend judgment and RSI overbought/oversold confirmation, it effectively captures market turning points. The strategy offers high reliability and strong adaptability, but traders must be mindful of choppy market and signal lag risks. There is significant room for improvement through the introduction of additional technical indicators and signal confirmation optimization. In practical application, investors should adjust parameters based on specific market conditions and combine with other analysis methods.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-03 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("MACD + RSI Strategy", overlay=true)
// MACD settings
fastLength = input.int(12, title="MACD Fast Length")
slowLength = input.int(26, title="MACD Slow Length")
signalSmoothing = input.int(9, title="MACD Signal Smoothing")
// RSI settings
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.float(70, title="RSI Overbought Level")
rsiOversold = input.float(30, title="RSI Oversold Level")
// Calculate MACD
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalSmoothing)
// Calculate RSI
rsi = ta.rsi(close, rsiLength)
// Generate buy and sell signals
buySignal = ta.crossover(macdLine, signalLine) and rsi < rsiOverbought
sellSignal = ta.crossunder(macdLine, signalLine) and rsi > rsiOversold
// Plot buy and sell signals on chart
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Strategy entry and exit
if buySignal
strategy.entry("Buy", strategy.long)
if sellSignal
strategy.close("Buy")
// Plot MACD and Signal Line
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.orange, title="Signal Line")
// Plot RSI
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
plot(rsi, color=color.purple, title="RSI")Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-04. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/MACD-RSI-Dynamic-Crossover-Quantitative-Trading-System.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Adaptive ATR and RSI Trend Following Strategy with Trailing Stop LossPine Script · Trend following · 1h
- Advanced Supertrend Indicator Trading Mechanism Optimization StrategyPine Script · Trend following · 1d
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dual Indicator Dynamic Trend Trading Strategy Multi dimensional Technical Analysis System Based on RSI and MACDPine Script · Trend following
- Dynamic Dual EMA Crossover Strategy with Adaptive Profit Loss ControlPine Script · Trend following · 1d