MACD Trend Following Strategy
Build a trend-following strategy using MACD (Moving Average Convergence Divergence). This tutorial teaches you to ride strong market trends by identifying momentum shifts and staying in winning positions longer than mean reversion strategies.
What You'll Build
A trend-following strategy that enters when MACD crosses above signal line (bullish) and exits when it crosses below (bearish). Profits from sustained directional moves.
Time Required: 20-25 minutes
Strategy Overview
Strategy Type
Trend Following - captures sustained price movements by riding momentum.
Indicator
MACD - measures trend direction and momentum through moving average convergence/divergence.
Entry Logic
Buy when MACD line crosses above signal line, indicating bullish momentum shift.
Exit Logic
Sell when MACD line crosses below signal line, indicating momentum weakening.
Understanding MACD
MACD Components
Trading Signals: MACD > Signal = Bullish (buy), MACD < Signal = Bearish (sell). The crossovers indicate momentum shifts.
Step 1: Understand MACD Indicators
Great News! MACD indicators are already calculated and ready to use in MangoLabs. You'll find:
- •
MACD_12_26_9- The MACD line (standard 12/26/9 parameters) - •
MACD_Signal_9- The signal line (9-period EMA of MACD)
All features are shared across users - just select them when building your strategy!
Step 2: Build Strategy Logic
Design MACD Crossover Strategy
- Create new strategy: "MACD Trend Following"
- Build entry condition (bullish crossover):Buy Signal:• Add Feature Node:
MACD_12_26_9• Add Feature Node:MACD_Signal_9(signal line)• Add Crossover Node: Detects when MACD crosses above signal• Connect: MACD + Signal → Crossover Node• Add Entry Signal: Type "Buy"• Connect: Crossover result → Entry Signal - Build exit condition (bearish crossover):Sell Signal:• Add Feature Node:
MACD_12_26_9• Add Feature Node:MACD_Signal_9• Add Crossunder Node: Detects when MACD crosses below signal• Connect: MACD + Signal → Crossunder Node• Add Exit Signal: Type "Sell"• Connect: Crossunder result → Exit Signal - Validate and save strategy
Step 3: Backtest
Backtest Configuration
- Symbol: BTCUSDT, ETHUSDT (trending assets work best)
- Timeframe: 4h or 1d (MACD works better on higher timeframes)
- Period: 1 year for robust results
- Position Size: 100% (trend following benefits from full exposure)
Why higher timeframes? MACD is less noisy on 4h/daily candles. Trend following needs time to develop and capture large moves. Lower timeframes (1h, 15m) generate too many false signals.
Expected Results
Target Metrics for MACD Strategy
Total Return (1yr)
30-80%
Sharpe Ratio
0.8-1.5
Max Drawdown
20-35%
Win Rate
40-50%
Trades (1yr)
15-40
Avg Win/Loss Ratio
1.5-3.0
MACD strategies typically have lower win rates than mean reversion but larger winners (better risk/reward ratio). Drawdowns are higher due to riding trends through pullbacks.
Strategy Enhancements
Add Trend Filter
Only take MACD signals in direction of 200-day moving average. Reduces whipsaws in sideways markets.
Zero-Line Filter
Only buy when MACD crosses above signal AND MACD is above 0. Ensures trend is truly bullish.
Histogram Confirmation
Require MACD histogram to be increasing for 2-3 bars after crossover to confirm momentum.
Trailing Stop
Instead of exiting on crossunder, use a trailing stop (e.g., 10% from peak) to capture more of the trend.
MACD vs RSI: When to Use Each
Use MACD When:
- Markets are trending (clear uptrends or downtrends)
- You want to capture large, sustained moves
- Trading on higher timeframes (4h, daily)
- You can tolerate lower win rates for bigger winners
- Willing to hold positions for days/weeks
Use RSI When:
- Markets are range-bound (sideways movement)
- You want quicker entries and exits
- Trading on lower timeframes (1h, 15m)
- You prefer higher win rates with smaller gains
- Holding positions for hours/days
Completion Checklist
- ✓ Created MACD and Signal line features
- ✓ Built crossover/crossunder strategy logic
- ✓ Backtested on 4h/daily timeframe with 1+ year data
- ✓ Achieved acceptable metrics (Sharpe >0.8, reasonable drawdown)
- ✓ Deployed to paper trading
- ✓ Understand trend following requires patience - fewer trades, bigger wins