Skip to main content

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

FeatureDescription
Buy Conditions1 combined buy signal (three conditions triggered together)
Sell Conditions1 combined sell signal (three conditions triggered together)
Protection MechanismNo independent protection parameter group; relies on indicator combination filtering
Timeframe5 minutes (5m)
Dependenciestalib, 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 GroupCondition NumberCore Logic
Trend ConfirmationCondition 2EMA200 bullish alignment
Momentum ReversalConditions 1+3RSI 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

ConditionLogicSignal Name
RSI Overbought8-period maximum > 93Momentum Extreme
MACD BullishMACD > 0Trend Confirmation
MACD Death CrossMACD crosses below signal lineReversal 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 CategorySpecific IndicatorUsage
Trend IndicatorEMA200Long-term trend direction judgment
Momentum IndicatorRSIOverbought/Oversold identification
Momentum IndicatorMACDEntry 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:

ParameterValueDescription
Stop Loss Range-4.032%Relatively tight
Initial Take-Profit3.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

  1. Simple Logic: Three-condition combined buy, clear and easy to understand
  2. Trend Filtering: EMA200 ensures trading only in uptrends
  3. Time Constraint: 35-hour forced exit controls position risk

⚠️ Limitations

  1. Few Conditions: Only 1 buy signal may miss other entry opportunities
  2. Tight Stop Loss: -4.032% may be triggered by market noise
  3. No Trailing Stop: Cannot follow trend to extend profits

VIII. Applicable Scenario Recommendations

Market EnvironmentRecommended ConfigurationDescription
Moderate UptrendDefault ConfigurationStrategy's optimal scenario
Strong UptrendCan increase take-profit targetsCapture larger profits during trend continuation
Sideways MarketUse with cautionEMA200 filtering may reduce signals
DowntrendNot recommendedStrategy 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 TypePerformance RatingReason 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 ItemRecommended ValueDescription
Trading PairsMajor currency pairsHigh liquidity currencies
Timeframe5m (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 PairsMinimum MemoryRecommended Memory
1-10 pairs1GB2GB
10-50 pairs2GB4GB

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:

  1. Plot EMA200 on daily or 4-hour charts
  2. Use RSI 14 to identify oversold (< 41)
  3. Observe MACD golden cross signals
  4. Set 4% stop loss

XI. Summary

MACD_Recovery is a simple and effective trend pullback strategy. Its core value lies in:

  1. Trend Filtering: EMA200 ensures trading only in bull markets
  2. Pullback Entry: RSI oversold identifies price pullback opportunities
  3. 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.