What problem this strategy targets
Raw MACD crosses fail often in downtrends. This WunderTrading MACD strategy only longs when MACD crosses above its signal while EMA > SMA (same length ribbon), then manages exits with an ATR trailing-style stop and two percent take-profit tranches.
Pine v5 strategy(). Author showcase: BINANCE:ETHUSDT, 30m. Source copyright line © Deobald; published under WunderTrading.

Logic overview
Period 34 builds EMA/SMA ribbon and MACD; Signal Smoothing default 2; ATR period 17; SL = entry − 2.2×ATR.
Entries
- Long on MACD cross over signal with leadLine2 < leadLine1.
- No short entry branch in the source.
Exits, stops, take-profit, sizing
- Close long if close < floating ATR stop.
- TP1 default +1% for 10% qty; TP2 default +5% for 50% qty.
- pyramiding=2 in strategy().
Parameters (source defaults)
| Input | Default | Role |
|---|---|---|
| Period | 34 | MACD + EMA/SMA length |
| Signal Smoothing | 2 | MACD signal |
| Long Take Profit 1 % / Qty | 1 / 10 | First TP tranche |
| Long Take Profit 2 % / Qty | 5 / 50 | Second TP tranche |
| SL Multiplier | 2.2 | ATR stop multiple |
| ATR period | 17 | ATR length |
Markets, timeframes, limits
- Author showcase: ETHUSDT 30m; BTC unchecked here.
- Long-only.
- Custom Atr() smoother ≠ ta.atr exactly.
- Repaint and partial TP fills not verified by Coinpred.
TradingView setup guide
- Download the .pine file from Coinpred (membership required; see below) or compare with the original publication page.
- Open TradingView → Pine Editor, create a blank script, paste the full source, then save.
- Click Add to chart. Confirm it is a strategy() script so the Strategy Tester is available.
- Review defaults in the Inputs panel using the parameter table below, then tune for your symbol and timeframe.
- Inspect signals in the Strategy Tester before wiring alerts. Historical curves are not a promise of future results.
Verification and backtests
Download rights and version notes
- Author: WunderTrading(源码 © Deobald); original title: MACD Strategy; version: 3.0 (pine-facade).
- License: MPL 2.0; Coinpred ships the unmodified full source file.
- Original page: https://www.tradingview.com/script/2jDHQAJc-MACD-Strategy-with-trailing-ATR-stop/
- Pine version: v5; type: strategy().
- Charts are author showcase images; image rights are outside MPL and captions are labeled accordingly.
- Downloads follow Coinpred membership rules; modified source files must remain under MPL 2.0.