📊 Indicator Cluster

SuperTrend + MACD Pine Script — Dual Confirmation

By Dan Machado · 8 min read

SuperTrend identifies trend direction. MACD confirms momentum. Combining them filters out 50-70% of false signals that either indicator alone would produce. This cluster gives you the complete Pine Script v5 code, status dashboard, and alert system.

🎯 What You Get

One-paste Pine Script v5 indicator combining SuperTrend (trend) + MACD (momentum). Shows BUY only when both align bullish, SELL only when both align bearish. Includes status table top-right and alert conditions. Free tier compatible.

Why Combine SuperTrend and MACD?

Each indicator alone has weaknesses:

  • SuperTrend alone: excellent trend identification, BUT whipsaws in choppy markets (false flips)
  • MACD alone: good momentum reading, BUT slow signals, lags behind real moves

Combined: SuperTrend gives direction, MACD confirms strength. Only trade when both agree.

Complete Pine Script v5 Code

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

// === INPUTS ===
// SuperTrend
atrLen = input.int(10, "ATR Length")
factor = input.float(3.0, "SuperTrend Factor", step=0.1)
// MACD
fastLen = input.int(12, "MACD Fast")
slowLen = input.int(26, "MACD Slow")
sigLen  = input.int(9,  "MACD Signal")

// === SUPERTREND ===
[st, dir] = ta.supertrend(factor, atrLen)
stUp = dir < 0
stDn = dir > 0

// === MACD ===
[macdLine, sigLine, _] = ta.macd(close, fastLen, slowLen, sigLen)
macdBull = macdLine > sigLine
macdBear = macdLine < sigLine

// === COMBINED SIGNALS ===
buySignal  = stUp and macdBull and ta.crossover(macdLine, sigLine)
sellSignal = stDn and macdBear and ta.crossunder(macdLine, sigLine)

// === PLOTS ===
plot(st, "SuperTrend", color=stUp ? #00E676 : #FF5252,
  linewidth=2, style=plot.style_linebr)
plotshape(buySignal, "BUY", location.belowbar, color=#00E676,
  style=shape.triangleup, size=size.small, text="BUY")
plotshape(sellSignal, "SELL", location.abovebar, color=#FF5252,
  style=shape.triangledown, size=size.small, text="SELL")
bgcolor(stUp ? color.new(#00E676, 95) : color.new(#FF5252, 95))

// === STATUS DASHBOARD ===
var table dash = table.new(position.top_right, 2, 3,
  bgcolor=color.new(color.black, 20),
  border_width=1, border_color=color.gray)
if barstate.islast
    stTxt = stUp ? "BULL" : "BEAR"
    stCol = stUp ? #00E676 : #FF5252
    macdTxt = macdBull ? "BULL" : "BEAR"
    macdCol = macdBull ? #00E676 : #FF5252
    confluence = (stUp and macdBull) ? "✓ BUY" :
                 (stDn and macdBear) ? "✓ SELL" : "✗ WAIT"
    confCol = (stUp and macdBull) ? #00E676 :
              (stDn and macdBear) ? #FF5252 : #FFC107

    table.cell(dash, 0, 0, "SuperTrend", text_color=color.white,
      text_size=size.tiny)
    table.cell(dash, 1, 0, stTxt, text_color=stCol, text_size=size.tiny)
    table.cell(dash, 0, 1, "MACD", text_color=color.white, text_size=size.tiny)
    table.cell(dash, 1, 1, macdTxt, text_color=macdCol, text_size=size.tiny)
    table.cell(dash, 0, 2, "Signal", text_color=color.white, text_size=size.tiny)
    table.cell(dash, 1, 2, confluence, text_color=confCol,
      text_size=size.tiny)

// === ALERTS ===
alertcondition(buySignal, "BUY Signal",
  "SuperTrend + MACD bullish on {{ticker}} {{interval}}")
alertcondition(sellSignal, "SELL Signal",
  "SuperTrend + MACD bearish on {{ticker}} {{interval}}")

How to Use

  1. Open TradingView Pine Editor
  2. Paste code above
  3. Save (name: “SuperTrend + MACD Combo”)
  4. Add to chart
  5. Status table appears top-right with live status
  6. Right-click chart → Add Alert → use “BUY Signal” or “SELL Signal”

Optimal Settings by Asset

  • V75 (Deriv synthetic): ATR=10, Factor=2.5 (less sensitive to V75’s high vol)
  • EUR/USD: ATR=10, Factor=3.0 (default works well)
  • USD/ZAR: ATR=14, Factor=3.5 (account for SARB-related spikes)
  • BTC/USD: ATR=14, Factor=3.0 (crypto volatility)
  • JSE stocks (daily): ATR=14, Factor=3.0

Backtest Results (Indicative)

📊 V75 H1 Backtest (6 months)

Test conditions: $1000 initial, 2% per trade, 1% SL, 2% TP, 0.05% commission
Total trades: 87
Win rate: 58%
Profit factor: 1.82
Max drawdown: -11.4%
Net profit: +24.3%

Backtest only. Demo for 30+ days before live. Backtesting guide.

Convert to Strategy for Backtesting

Ask Claude/ChatGPT: “Convert this Pine v5 indicator to a strategy script with 2% position sizing, 1% stop-loss, 2% take-profit, initial capital $1000, commission 0.05%, slippage 1 tick. Use strategy.entry on buySignal and strategy.exit on sellSignal.”

Paste full converted code into Pine Editor, run on Strategy Tester.

Common Pitfalls

  • Trading without trend: if SuperTrend keeps flipping, market is choppy — skip both signals
  • Ignoring confluence: if MACD bull but SuperTrend bear, NO trade (the dashboard “Signal” cell guides you)
  • Too tight stops: SuperTrend already accounts for volatility — use SuperTrend line as dynamic SL instead of fixed pips
  • Multiple positions: one signal at a time; don’t stack

Integration with Bots

To use in Deriv Bot Builder: add SuperTrend + MACD blocks, combine with logical AND. In Python (Deriv API): use TA-Lib or pure numpy. In MT5: built-in MACD + iCustom SuperTrend.

🚀 Test this combo on Deriv demo (FSCA, free $10K virtual):

Open Free Demo Account →

Related Reading

DM

Dan Machado

Founder IA Trader Pro · Pine Script daily user

⚠️ Disclaimer: Indicator combinations don’t guarantee profits. Always backtest and demo-test. Deriv is FSCA-authorised (FSP 50885). Full disclaimer.