Skip to main content

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

CharacteristicDescription
Buy Conditions1–2 sets of MACD golden cross buy signals
Sell Conditions1 set of base sell signals + dynamic take-profit/stoploss + time stoploss
ProtectionMulti-layer stoploss protection (fixed stoploss + trailing stop + time stoploss)
Timeframe15-minute primary timeframe
Dependenciespandas, 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:

ConditionDescription
MACD line crosses above signal lineStandard golden cross signal
MACD near zero lineAvoid 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 TypeParameterTrigger ConditionDesign Purpose
Fixed Stoploss-5%5% loss reachedControl max loss per trade
Trailing Stop+2.5%Profit drawdown to 2%Protect earned profits
Time Stoploss120 minutesHolding timeoutAvoid prolonged captivity

4.2 Take-Profit System

Holding TimeTake-Profit TargetDesign Intent
0–30 minutes6%Short-term quick profit
30–60 minutes4%Medium-term target
60–120 minutes2%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 ParameterValueDescription
Fast Line Period12Short-term EMA
Slow Line Period26Long-term EMA
Signal Line Period9EMA 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

SignalConditionMeaning
Golden CrossDIF crosses above DEABuy signal
Death CrossDIF crosses below DEASell signal
Above ZeroDIF > 0Bullish trend
Below ZeroDIF < 0Bearish trend
Histogram GrowingMACD_hist > PreviousMomentum strengthening
Histogram ContractingMACD_hist < PreviousMomentum weakening

5.4 Auxiliary Indicators (Optional)

Indicator CategorySpecific IndicatorPurpose
Trend ConfirmationEMA50, EMA200Judge major trend direction
VolatilityATRDynamic 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:

  1. Fixed Stoploss: Highest priority, protects principal
  2. Trailing Stop: Protects profits
  3. Time Stoploss: Avoids time cost
  4. Signal Stoploss: MACD death cross and other technical signals

6.3 Stoploss Parameter Comparison

Strategy TypeFixed StoplossTrailing Start Point
Aggressive-10%5%
Standard-8%3–4%
MACD_StopLoss-5%2.5%
Conservative-3%1–2%

VII. Strategy Pros & Cons

Pros

  1. Strict Stoploss: -5% hard stoploss, stricter than typical strategies, better risk control
  2. Trailing Protection: Activates at 2.5%, protecting profits earlier
  3. Time Stoploss: Avoids prolonged captivity, high capital efficiency
  4. Simple and Clear: Single MACD indicator, logic simple and easy to understand
  5. Easy to Execute: Stoploss points clear, easy to follow strictly

Cons

  1. Conservative Take-Profit: 6% target relatively low, may miss big moves
  2. Trend-Dependent: More false MACD signals in ranging markets
  3. Fixed Parameters: MACD parameters 12/26/9 cannot adjust dynamically
  4. No Filter Mechanism: No extra trend filter, may buy against trend
  5. Frequent Stoploss Triggers: -5% stoploss relatively strict, easily shaken out in volatile markets

VIII. Applicable Scenarios

Market EnvironmentRecommended ConfigDescription
UptrendEnableMACD golden cross confirms trend
DowntrendEnableUsable for shorting (if supported)
Ranging MarketReduce tradesMore false MACD signals, easily shaken out
High VolatilityTighten stoplossPrevent getting shaken out then seeing a reversal
Low VolatilityWiden stoplossAvoid 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 TypePerformance RatingAnalysis
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 ItemRecommended ValueDescription
Stoploss-5% (default)Adjustable based on volatility
Trailing StoplossEnableKey protection mechanism
Max Holding Time120 minutesAvoid captivity
Trading PairsHigh-trending tokensAvoid choppy tokens

X. Summary

MACD_StopLoss is a trend-following strategy with stoploss as its core feature. Its core value lies in:

  1. Strict Stoploss: -5% hard stoploss, stricter than typical strategies
  2. Three-Layer Protection: Fixed stoploss + trailing stop + time stoploss
  3. Fast Trailing: Activates protection at 2.5%, locking in profits earlier
  4. 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