MACD_StopLoss Strategy Analysis
Strategy ID: #233 (Strategy #233 of 465)
Strategy Type: MACD Trend Following + Special Stoploss Mechanism
Timeframe: 15 Minutes (15m)
I. Strategy Overview
MACD_StopLoss is a MACD-based trend-following strategy whose standout feature is its meticulously designed stoploss mechanism. The "StopLoss" in the strategy name directly indicates that the stoploss system is the strategy's core highlight.
Unlike ordinary MACD strategies, MACD_StopLoss adopts a "stoploss-first" design philosophy. On top of standard MACD crossover signals, it adds stricter stoploss protection, trailing stop, and holding-time limits to control risk while letting profits run as much as possible.
Core Characteristics
| Characteristic | Description |
|---|---|
| Buy Conditions | 1–2 sets of MACD golden cross buy signals |
| Sell Conditions | 1 set of base sell signals + dynamic take-profit/stoploss + time stoploss |
| Protection | Multi-layer stoploss protection (fixed stoploss + trailing stop + time stoploss) |
| Timeframe | 15-minute primary timeframe |
| Dependencies | pandas, numpy, TA-Lib |
II. Strategy Configuration Analysis
2.1 Basic Risk Parameters
# ROI Exit Table
minimal_roi = {
"0": 0.06, # Immediate exit: 6% profit
"30": 0.04, # After 30 minutes: 4% profit
"60": 0.02, # After 60 minutes: 2% profit
"120": 0.01 # After 120 minutes: 1% profit
}
# Stoploss Settings (Core Feature)
stoploss = -0.05 # -5% hard stoploss (stricter than typical strategies)
# Trailing Stop (Key Feature)
trailing_stop = True
trailing_stop_positive = 0.02 # 2% trailing start
trailing_stop_positive_offset = 0.025 # 2.5% offset trigger
Design Philosophy:
- Conservative Take-Profit: Lower profit targets compared to other strategies (6% vs 8–10%)
- Strict Stoploss: -5% stoploss, stricter than the common -8%~-10%
- Fast Trailing: Activates protection at 2.5% profit, earlier than most strategies
- Time Stoploss: Max holding 120 minutes, avoids prolonged captivity
2.2 Order Type Configuration
order_types = {
"entry": "limit", # Limit order entry
"exit": "limit", # Limit order exit
"stoploss": "market", # Market stoploss order
"stoploss_on_exchange": True, # Exchange stoploss order
}
III. Entry Conditions Details
3.1 Core Buy Signal: MACD Golden Cross
Standard MACD Golden Cross Entry Logic:
# MACD Parameter Settings
macd_fast = 12
macd_slow = 26
macd_signal = 9
# MACD Golden Cross
dataframe.loc[
qtpylib.crossed_above(dataframe['macd'], dataframe['macdsignal']),
'buy'
] = 1
Signal Confirmation Conditions:
| Condition | Description |
|---|---|
| MACD line crosses above signal line | Standard golden cross signal |
| MACD near zero line | Avoid golden crosses at extreme positions |
| Volume confirmation (optional) | Volume expansion confirms signal |
3.2 Auxiliary Buy Conditions (Optional)
Condition #2: MACD Golden Cross Above Zero Line
# MACD golden cross above zero (stronger signal)
macd_positive = dataframe['macd'] > 0
macd_cross = crossed_above(dataframe['macd'], dataframe['macdsignal'])
buy_signal_2 = macd_positive & macd_cross
Condition Description:
- MACD above zero indicates bullish trend
- Golden cross above zero is more reliable
- Suitable for adding positions after trend confirmation
3.3 Buy Condition Filters
Possible filter conditions:
- Trend Filter: Price above moving average (e.g., EMA200)
- Momentum Filter: MACD histogram growing
- Volume Filter: Volume expansion confirms
IV. Exit Conditions Details
4.1 Multi-Layer Stoploss System (Core Feature)
This is the strategy's core highlight, using three-layer stoploss protection:
| Stoploss Type | Parameter | Trigger Condition | Design Purpose |
|---|---|---|---|
| Fixed Stoploss | -5% | 5% loss reached | Control max loss per trade |
| Trailing Stop | +2.5% | Profit drawdown to 2% | Protect earned profits |
| Time Stoploss | 120 minutes | Holding timeout | Avoid prolonged captivity |
4.2 Take-Profit System
| Holding Time | Take-Profit Target | Design Intent |
|---|---|---|
| 0–30 minutes | 6% | Short-term quick profit |
| 30–60 minutes | 4% | Medium-term target |
| 60–120 minutes | 2% | Conservative target |
| 120 minutes+ | 1% | Avoid time cost |
4.3 Technical Sell Signals
Sell Signal #1: MACD Death Cross
# MACD death cross
macd_death_cross = crossed_below(dataframe['macd'], dataframe['macdsignal'])
Sell Signal #2: Price Breaks Below Key Moving Average
# Price breaks below EMA50 (optional)
price_below_ema = dataframe['close'] < dataframe['ema50']
Sell Signal #3: MACD Histogram Turns Negative
# MACD histogram turns from positive to negative
histogram_negative = dataframe['macd'] - dataframe['macdsignal'] < 0
V. Technical Indicator System
5.1 Core Indicator: MACD
| Indicator Parameter | Value | Description |
|---|---|---|
| Fast Line Period | 12 | Short-term EMA |
| Slow Line Period | 26 | Long-term EMA |
| Signal Line Period | 9 | EMA of DIF |
5.2 MACD Calculation Details
# DIF (Fast Line)
DIF = EMA(close, 12) - EMA(close, 26)
# DEA (Slow Line/Signal Line)
DEA = EMA(DIF, 9)
# MACD Histogram
MACD_hist = (DIF - DEA) * 2
5.3 MACD Signal Interpretation
| Signal | Condition | Meaning |
|---|---|---|
| Golden Cross | DIF crosses above DEA | Buy signal |
| Death Cross | DIF crosses below DEA | Sell signal |
| Above Zero | DIF > 0 | Bullish trend |
| Below Zero | DIF < 0 | Bearish trend |
| Histogram Growing | MACD_hist > Previous | Momentum strengthening |
| Histogram Contracting | MACD_hist < Previous | Momentum weakening |
5.4 Auxiliary Indicators (Optional)
| Indicator Category | Specific Indicator | Purpose |
|---|---|---|
| Trend Confirmation | EMA50, EMA200 | Judge major trend direction |
| Volatility | ATR | Dynamic stoploss distance calculation |
VI. Risk Management Highlights (Core Feature)
6.1 Three-Layer Stoploss Protection Details
Layer 1: Fixed Stoploss (-5%)
stoploss = -0.05 # Stricter than typical strategies
- Design Purpose: Control max loss per trade
- Characteristic: Stricter than typical -8%~-10%
- Applicable Scenario: All trades
Layer 2: Trailing Stop (+2.5%)
trailing_stop_positive = 0.02
trailing_stop_positive_offset = 0.025
- Design Purpose: Protect earned profits
- Characteristic: Activates protection at 2.5% profit, relatively early
- Applicable Scenario: Profitable trades
Layer 3: Time Stoploss (120 Minutes)
# Achieved via ROI table
minimal_roi = {
"120": 0.01 # After 120 minutes, only 1% profit needed to exit
}
- Design Purpose: Avoid prolonged captivity
- Characteristic: Max holding 2 hours
- Applicable Scenario: Trades going sideways
6.2 Stoploss Priority
When multiple stoploss conditions trigger simultaneously:
- Fixed Stoploss: Highest priority, protects principal
- Trailing Stop: Protects profits
- Time Stoploss: Avoids time cost
- Signal Stoploss: MACD death cross and other technical signals
6.3 Stoploss Parameter Comparison
| Strategy Type | Fixed Stoploss | Trailing Start Point |
|---|---|---|
| Aggressive | -10% | 5% |
| Standard | -8% | 3–4% |
| MACD_StopLoss | -5% | 2.5% |
| Conservative | -3% | 1–2% |
VII. Strategy Pros & Cons
Pros
- Strict Stoploss: -5% hard stoploss, stricter than typical strategies, better risk control
- Trailing Protection: Activates at 2.5%, protecting profits earlier
- Time Stoploss: Avoids prolonged captivity, high capital efficiency
- Simple and Clear: Single MACD indicator, logic simple and easy to understand
- Easy to Execute: Stoploss points clear, easy to follow strictly
Cons
- Conservative Take-Profit: 6% target relatively low, may miss big moves
- Trend-Dependent: More false MACD signals in ranging markets
- Fixed Parameters: MACD parameters 12/26/9 cannot adjust dynamically
- No Filter Mechanism: No extra trend filter, may buy against trend
- Frequent Stoploss Triggers: -5% stoploss relatively strict, easily shaken out in volatile markets
VIII. Applicable Scenarios
| Market Environment | Recommended Config | Description |
|---|---|---|
| Uptrend | Enable | MACD golden cross confirms trend |
| Downtrend | Enable | Usable for shorting (if supported) |
| Ranging Market | Reduce trades | More false MACD signals, easily shaken out |
| High Volatility | Tighten stoploss | Prevent getting shaken out then seeing a reversal |
| Low Volatility | Widen stoploss | Avoid frequent stoploss triggers |
IX. Applicable Market Environment Details
MACD_StopLoss is a "stoploss-first" trend-following strategy suitable for risk-averse traders.
9.1 Strategy Core Logic
- MACD Golden Cross Entry: Capture trend turning points
- -5% Fixed Stoploss: Strictly control max loss per trade
- Trailing Stop Protection: Don't let profits slip away
- Time Stoploss Mechanism: Avoid capital being tied up long-term
9.2 Performance Across Market Environments
| Market Type | Performance Rating | Analysis |
|---|---|---|
| Uptrend | ★★★★☆ | MACD golden cross signals effective, stoploss protects profits |
| Downtrend | ★★★★☆ | Usable for shorting, strict stoploss avoids deep losses |
| Wide Range | ★★☆☆☆ | More false MACD signals, -5% stoploss easily triggered |
| Extreme Consolidation | ★★☆☆☆ | Frequent stoploss triggers, high fee erosion |
9.3 Key Configuration Recommendations
| Config Item | Recommended Value | Description |
|---|---|---|
| Stoploss | -5% (default) | Adjustable based on volatility |
| Trailing Stoploss | Enable | Key protection mechanism |
| Max Holding Time | 120 minutes | Avoid captivity |
| Trading Pairs | High-trending tokens | Avoid choppy tokens |
X. Summary
MACD_StopLoss is a trend-following strategy with stoploss as its core feature. Its core value lies in:
- Strict Stoploss: -5% hard stoploss, stricter than typical strategies
- Three-Layer Protection: Fixed stoploss + trailing stop + time stoploss
- Fast Trailing: Activates protection at 2.5%, locking in profits earlier
- Simple and Reliable: Single MACD indicator, clear logic
For risk-averse traders, this is a strategy worth considering. Recommendations:
- Use in trending markets
- Follow stoploss discipline strictly
- Adjust stoploss parameters based on volatility
- Combine with trend filters to improve win rate