📈 Indicator Cluster

SuperTrend + MACD Pine Script — Combo Dual Confirmation

Bởi Dan Machado · 9 phút đọc · Code ready

SuperTrend + MACD là một trong những combos hiệu quả nhất cho trend trading. SuperTrend xác định trend direction, MACD confirm momentum. Dual confirmation này giảm whipsaws 50-70% so với single indicator. Tutorial có code Pine Script v5 ready.

Tại Sao Combo SuperTrend + MACD?

📊 SuperTrend (Trend)

  • Xác định trend direction rõ ràng
  • Dựa trên ATR (volatility-adjusted)
  • Color-coded: green up, red down
  • Acts như dynamic support/resistance
  • Yếu điểm: Whipsaws trong sideways markets

⚡ MACD (Momentum)

  • Confirm momentum strength
  • Histogram shows acceleration/deceleration
  • Zero-line cross = trend confirmation
  • Divergence = early reversal warning
  • Yếu điểm: Lagging trong fast moves

✓ Synergy

SuperTrend weak trong sideways → MACD filters those out (no momentum). MACD lagging → SuperTrend gives early direction. Together: chỉ trade khi cả trend VÀ momentum align. Fewer trades, higher quality.

AI Prompt để Generate

📋 PROMPT

“Tạo Pine Script v5 indicator combo SuperTrend (ATR 10, multiplier 3) + MACD (12, 26, 9). Buy signal: SuperTrend flips green AND MACD histogram > 0. Sell signal: SuperTrend flips red AND MACD histogram < 0. Plot SuperTrend line on chart, MACD trong separate logic. Add arrows cho signals, alerts cho both. Overlay=true.”

Code Complete — SuperTrend + MACD

▸ Pine Script v5 · SuperTrend + MACD Combo COPY ↗
//@version=5
indicator("SuperTrend + MACD Combo — IA Trader Pro", overlay=true)

// === INPUTS ===
atrPeriod = input.int(10, "SuperTrend ATR Period")
atrMult = input.float(3.0, "SuperTrend Multiplier", step=0.1)
macdFast = input.int(12, "MACD Fast")
macdSlow = input.int(26, "MACD Slow")
macdSignal = input.int(9, "MACD Signal")

// === SUPERTREND CALCULATION ===
[supertrend, direction] = ta.supertrend(atrMult, atrPeriod)

// === MACD CALCULATION ===
[macdLine, signalLine, histLine] = ta.macd(close, macdFast, macdSlow, macdSignal)

// === SUPERTREND FLIP DETECTION ===
flipUp = direction < 0 and direction[1] >= 0    // changed to uptrend
flipDown = direction > 0 and direction[1] <= 0  // changed to downtrend

// === COMBO SIGNALS (DUAL CONFIRMATION) ===
buySignal = flipUp and histLine > 0
sellSignal = flipDown and histLine < 0

// === ALSO: ongoing confirmation ===
trendBullish = direction < 0 and histLine > 0
trendBearish = direction > 0 and histLine < 0

// === PLOT SUPERTREND ===
upTrend = direction < 0 ? supertrend : na
downTrend = direction > 0 ? supertrend : na

plot(upTrend, "Up Trend", color=color.new(#00E676, 0), linewidth=2, style=plot.style_linebr)
plot(downTrend, "Down Trend", color=color.new(#FF5252, 0), linewidth=2, style=plot.style_linebr)

// === BACKGROUND COLOR ===
bgcolor(trendBullish ? color.new(#00E676, 92) : na, title="Bullish Zone")
bgcolor(trendBearish ? color.new(#FF5252, 92) : na, title="Bearish Zone")

// === PLOT SIGNALS ===
plotshape(buySignal, title="BUY",
  location=location.belowbar,
  color=color.new(#00E676, 0),
  style=shape.labelup,
  size=size.normal,
  text="BUY",
  textcolor=color.white)

plotshape(sellSignal, title="SELL",
  location=location.abovebar,
  color=color.new(#FF5252, 0),
  style=shape.labeldown,
  size=size.normal,
  text="SELL",
  textcolor=color.white)

// === STATUS DASHBOARD ===
var table dash = table.new(position.top_right, 2, 4,
  bgcolor=color.new(color.black, 20),
  border_width=1, border_color=color.gray)

if barstate.islast
    stStatus = direction < 0 ? "BULLISH" : "BEARISH"
    stColor = direction < 0 ? #00E676 : #FF5252
    macdStatus = histLine > 0 ? "BULLISH" : "BEARISH"
    macdColor = histLine > 0 ? #00E676 : #FF5252
    combo = (direction < 0 and histLine > 0) ? "🟢 ALIGNED BULL" :
            (direction > 0 and histLine < 0) ? "🔴 ALIGNED BEAR" : "⚪ MIXED"
    comboColor = (direction < 0 and histLine > 0) ? #00E676 :
                 (direction > 0 and histLine < 0) ? #FF5252 : color.gray
    
    table.cell(dash, 0, 0, "INDICATOR", text_color=color.white,
      text_size=size.small, bgcolor=color.new(#448AFF, 30))
    table.cell(dash, 1, 0, "STATUS", text_color=color.white,
      text_size=size.small, bgcolor=color.new(#448AFF, 30))
    table.cell(dash, 0, 1, "SuperTrend", text_color=color.white, text_size=size.tiny)
    table.cell(dash, 1, 1, stStatus, text_color=stColor, text_size=size.tiny)
    table.cell(dash, 0, 2, "MACD", text_color=color.white, text_size=size.tiny)
    table.cell(dash, 1, 2, macdStatus, text_color=macdColor, text_size=size.tiny)
    table.cell(dash, 0, 3, "COMBO", text_color=color.white, text_size=size.tiny,
      bgcolor=color.new(#FFC107, 60))
    table.cell(dash, 1, 3, combo, text_color=comboColor, text_size=size.tiny,
      bgcolor=color.new(#FFC107, 80))

// === ALERTS ===
alertcondition(buySignal, title="SuperTrend+MACD BUY",
  message="BUY: SuperTrend flipped bullish + MACD histogram positive")
alertcondition(sellSignal, title="SuperTrend+MACD SELL",
  message="SELL: SuperTrend flipped bearish + MACD histogram negative")

Cách Sử Dụng

  1. Mở TradingView, chọn asset (V75, EUR/USD, BTC)
  2. Click “Pine Editor” tab
  3. Paste code, save (Ctrl+S)
  4. Click “Add to chart”
  5. SuperTrend line plot, dashboard top-right show status
  6. Trade chỉ khi dashboard show “🟢 ALIGNED BULL” hoặc “🔴 ALIGNED BEAR”

Trading Strategy

Entry Rules

  • BUY: SuperTrend flips green (uptrend) + MACD histogram > 0 simultaneously
  • SELL: SuperTrend flips red (downtrend) + MACD histogram < 0 simultaneously

Exit Rules

  • Exit BUY: SuperTrend flips red, HOẶC MACD histogram turns negative
  • Exit SELL: SuperTrend flips green, HOẶC MACD histogram turns positive
  • Stop loss: SuperTrend line acts như dynamic SL

Best Timeframes

  • H1-H4: Best cho forex/crypto trend trading
  • M15-M30: Cho V75 synthetic indices
  • Avoid M1-M5: Quá nhiều noise, whipsaws

Parameter Tuning

🔧 Adjust Theo Asset

V75 (high volatility): ATR multiplier 3.5-4.0 (wider, fewer whipsaws)
Forex majors (low volatility): ATR multiplier 2.5-3.0
Crypto (very volatile): ATR multiplier 4.0-5.0
ATR period: 10 standard, 14 cho smoother (less responsive)
Backtest mỗi setting — xem guide backtest.

Pros & Cons

✓ Pros

1. Whipsaws reduced 50-70% vs single indicator
2. Clear visual signals — dashboard + arrows
3. Dynamic stop loss built-in (SuperTrend line)
4. Works cross-asset — forex, crypto, synthetic
5. Trend-following — rides big moves

⚠️ Cons

1. Lagging entries — confirmation costs early entry points
2. Fewer signals — dual confirmation = patience needed
3. Sideways markets — still some whipsaws
4. V75 less ideal — synthetic favors mean reversion over trend

Customize với AI

Modify combo với follow-up prompts:

  • “Add EMA 200 filter — chỉ BUY khi price > EMA 200”
  • “Convert sang strategy script cho backtest”
  • “Add ATR-based take profit (2x ATR target)”
  • “Add volume confirmation — signal chỉ khi volume > average”

🚀 Test SuperTrend + MACD combo trên Deriv V75 demo:

Mở Demo Deriv Miễn Phí

Bài Liên Quan

DM

Dan Machado

Founder IA Trader Pro · Trend trading 5+ năm

⚠️ Disclaimer: Indicators không guarantee profit. Backtest trước live. Deriv không được cấp phép bởi SBV. Bài viết này có chứa affiliate link Deriv. Disclaimer đầy đủ.