MACD_Recovery Strategy In-Depth Analysis
Strategy Number: #461 (461st of 465 strategies)
Strategy Type: Trend Following + Momentum Reversal Combination Strategy
Timeframe: 5 minutes (5m)
I. Strategy Overview
MACD_Recovery is a hybrid strategy combining trend following with momentum reversal. The strategy uses EMA200 to determine the long-term trend direction, captures short-term pullback opportunities through RSI oversold signals, and employs MACD golden cross as a precise entry trigger. The "Recovery" in the strategy name suggests its core logic—seeking recovery entry opportunities during pullbacks in an uptrend.
Core Features
| Feature | Description |
|---|---|
| Buy Conditions | 1 combined buy signal (three conditions triggered together) |
| Sell Conditions | 1 combined sell signal (three conditions triggered together) |
| Protection Mechanism | No independent protection parameter group; relies on indicator combination filtering |
| Timeframe | 5 minutes (5m) |
| Dependencies | talib, qtpylib |
II. Strategy Configuration Analysis
2.1 Basic Risk Parameters
# ROI Exit Table (11-level精细 take-profit)
minimal_roi = {
"0": 0.03024, # Immediate: 3.024%
"296": 0.02924, # ~5 hours later: 2.924%
"596": 0.02545, # ~10 hours later: 2.545%
"840": 0.02444, # ~14 hours later: 2.444%
"966": 0.02096, # ~16 hours later: 2.096%
"1258": 0.01709, # ~21 hours later: 1.709%
"1411": 0.01598, # ~23.5 hours later: 1.598%
"1702": 0.0122, # ~28 hours later: 1.22%
"1893": 0.00732, # ~31.5 hours later: 0.732%
"2053": 0.00493, # ~34 hours later: 0.493%
"2113": 0 # ~35 hours later: 0% (forced exit)
}
# Stop Loss Setting
stoploss = -0.04032 # -4.032%
Design Philosophy:
- Employs 11-level精细 take-profit, gradually decreasing from 3.024% to 0%
- Time span of approximately 35 hours (about 1.5 days), providing ample profit space
- Stop loss at -4.032%, forming a risk-reward ratio of approximately 1:0.75 with the initial take-profit target of 3.024%
- No trailing stop; relies on ROI table and sell signals for exit
2.2 Order Type Configuration
The strategy uses default order type configuration with no special settings.
III. Buy Conditions Detailed Analysis
3.1 Buy Signal Structure
The strategy employs a single combined buy signal that must satisfy three conditions simultaneously:
# Buy Conditions
(
(dataframe['rsi'].rolling(8).min() < 41) & # Condition 1: RSI Oversold
(dataframe['close'] > dataframe['ema200']) & # Condition 2: Trend Confirmation
(qtpylib.crossed_above(dataframe['macd'],
dataframe['macdsignal'])) # Condition 3: MACD Golden Cross
)
3.2 Buy Conditions Detailed Analysis
Condition #1: RSI Oversold Confirmation
# Logic
- RSI indicator 8-period rolling minimum value < 41
- Uses rolling window to capture recent oversold zones
- Threshold of 41 is more lenient than traditional 30, capturing more opportunities
Design Intent: Identify oversold conditions during price pullbacks to prepare for entry.
Condition #2: Trend Direction Confirmation
# Logic
- Close price > EMA200
- Ensures trading only in uptrends
- Avoids catching falling knives in downtrends
Design Intent: Filter false signals; enter only when the main trend is upward.
Condition #3: MACD Golden Cross Trigger
# Logic
- MACD line crosses above signal line
- Serves as precise entry timing confirmation
- Forms resonance with RSI oversold
Design Intent: Enter at the moment of momentum reversal after oversold conditions, improving win rate.
3.3 Buy Conditions Classification
| Condition Group | Condition Number | Core Logic |
|---|---|---|
| Trend Confirmation | Condition 2 | EMA200 bullish alignment |
| Momentum Reversal | Conditions 1+3 | RSI oversold + MACD golden cross |
IV. Sell Logic Detailed Analysis
4.1 ROI Take-Profit System
The strategy employs an 11-level progressive take-profit system with the following core logic:
Profit Margin Range Holding Time Target Return
──────────────────────────────────────
Immediate Exit 0 minutes 3.024%
Short-term Holding 5 hours 2.924%
Medium-term Holding 10 hours 2.545%
Medium-Long Holding 14 hours 2.444%
... ... ...
Forced Exit 35 hours 0%
Design Features:
- Shorter holding time requires higher take-profit target
- Encourages quick profit realization
- Forced exit after 35 hours to avoid long-term capital occupation
4.2 Sell Signal
# Sell Conditions
(
(dataframe['rsi'].rolling(8).max() > 93) & # Condition 1: RSI Overbought
(dataframe['macd'] > 0) & # Condition 2: MACD Bullish
(qtpylib.crossed_below(dataframe['macd'],
dataframe['macdsignal'])) # Condition 3: MACD Death Cross
)
4.3 Sell Signal Analysis
| Condition | Logic | Signal Name |
|---|---|---|
| RSI Overbought | 8-period maximum > 93 | Momentum Extreme |
| MACD Bullish | MACD > 0 | Trend Confirmation |
| MACD Death Cross | MACD crosses below signal line | Reversal Signal |
Design Intent: Exit when RSI is extremely overbought, MACD remains bullish but begins to reverse, locking in profits.
V. Technical Indicator System
5.1 Core Indicators
| Indicator Category | Specific Indicator | Usage |
|---|---|---|
| Trend Indicator | EMA200 | Long-term trend direction judgment |
| Momentum Indicator | RSI | Overbought/Oversold identification |
| Momentum Indicator | MACD | Entry timing confirmation |
5.2 Indicator Parameters
# EMA Parameters
ema200 = ta.EMA(dataframe, timeperiod=200)
# RSI Parameters (using default value 14)
rsi = ta.RSI(dataframe)
# MACD Parameters (using default values 12, 26, 9)
macd = ta.MACD(dataframe)
dataframe['macd'] = macd['macd']
dataframe['macdsignal'] = macd['macdsignal']
dataframe['macdhist'] = macd['macdhist']
VI. Risk Management Features
6.1 Tight Stop Loss
Stop loss is set at -4.032%, relatively tight:
| Parameter | Value | Description |
|---|---|---|
| Stop Loss Range | -4.032% | Relatively tight |
| Initial Take-Profit | 3.024% | Risk-reward ratio approximately 0.75:1 |
Risk Warning: Tight stop loss may increase probability of being shaken out, but effectively controls single-trade loss.
6.2 Time-Constrained Exit
35-hour forced exit mechanism:
- Avoids long-term capital occupation
- Forced stop-loss protection
- Prevents long-term floating losses
6.3 No Trailing Stop
The strategy does not use trailing stop, relying on:
- ROI table progressive take-profit
- Sell signal active exit
VII. Strategy Advantages and Limitations
✅ Advantages
- Simple Logic: Three-condition combined buy, clear and easy to understand
- Trend Filtering: EMA200 ensures trading only in uptrends
- Time Constraint: 35-hour forced exit controls position risk
⚠️ Limitations
- Few Conditions: Only 1 buy signal may miss other entry opportunities
- Tight Stop Loss: -4.032% may be triggered by market noise
- No Trailing Stop: Cannot follow trend to extend profits
VIII. Applicable Scenario Recommendations
| Market Environment | Recommended Configuration | Description |
|---|---|---|
| Moderate Uptrend | Default Configuration | Strategy's optimal scenario |
| Strong Uptrend | Can increase take-profit targets | Capture larger profits during trend continuation |
| Sideways Market | Use with caution | EMA200 filtering may reduce signals |
| Downtrend | Not recommended | Strategy designed for long positions only, no short mechanism |
IX. Applicable Market Environment Detailed Analysis
MACD_Recovery is a typical trend pullback trading strategy. Based on its code architecture, it is best suited for moderate uptrend markets and performs poorly in downtrend or highly volatile markets.
9.1 Strategy Core Logic
- Trend Confirmation Priority: Close price must be above EMA200, ensuring trading only in bull markets
- Pullback Entry: Uses RSI oversold to identify price pullback opportunities
- Momentum Confirmation: MACD golden cross serves as entry timing confirmation
9.2 Performance in Different Market Environments
| Market Type | Performance Rating | Reason Analysis |
|---|---|---|
| 📈 Moderate Uptrend | ⭐⭐⭐⭐⭐ | Clear trend, many pullback entry opportunities, ROI table works well |
| 🔄 Oscillating Uptrend | ⭐⭐⭐⭐☆ | Has trend filtering, can capture swing opportunities |
| 📉 Downtrend | ⭐☆☆☆☆ | EMA200 filtering results in no signals or being trapped |
| ⚡️ High Volatility | ⭐⭐☆☆☆ | Tight stop loss may be frequently triggered |
9.3 Key Configuration Recommendations
| Configuration Item | Recommended Value | Description |
|---|---|---|
| Trading Pairs | Major currency pairs | High liquidity currencies |
| Timeframe | 5m (default) | Can be adjusted based on market |
| Stop Loss | -4.032% | Can be appropriately relaxed to -5% |
X. Important Reminder: The Cost of Complexity
10.1 Learning Cost
The strategy logic is simple, suitable for beginners to understand and learn. Core concepts:
- EMA trend judgment
- RSI overbought/oversold
- MACD golden/death cross
10.2 Hardware Requirements
| Number of Trading Pairs | Minimum Memory | Recommended Memory |
|---|---|---|
| 1-10 pairs | 1GB | 2GB |
| 10-50 pairs | 2GB | 4GB |
Strategy has low computational requirements and modest hardware demands.
10.3 Differences Between Backtesting and Live Trading
Due to simple conditions, differences between backtesting and live trading are minimal. Main points to note:
- Slippage impact
- Exchange latency
- Price volatility within 5-minute periods
10.4 Manual Trader Recommendations
The core logic can be manually applied:
- Plot EMA200 on daily or 4-hour charts
- Use RSI 14 to identify oversold (< 41)
- Observe MACD golden cross signals
- Set 4% stop loss
XI. Summary
MACD_Recovery is a simple and effective trend pullback strategy. Its core value lies in:
- Trend Filtering: EMA200 ensures trading only in bull markets
- Pullback Entry: RSI oversold identifies price pullback opportunities
- Timing Confirmation: MACD golden cross provides precise entry signals
For quantitative traders, this is a strategy template suitable for introductory learning. Parameters can be adjusted or additional filtering conditions can be added based on actual needs.