SuperTrend + MACD Combo Indicator β Ready Pine Script
SuperTrend is one of the best trend indicators. MACD is one of the best momentum indicators. Together? A powerful combo that filters false signals and identifies high-probability entries.
In this post, I’ll hand you the complete Pine Script v5 code that combines both into a single indicator, with visual signals and alerts.
How the combo works
- SuperTrend defines trend direction (green = up, red = down)
- MACD confirms momentum (positive or negative histogram)
- BUY signal: SuperTrend turned green AND MACD histogram > 0
- SELL signal: SuperTrend turned red AND MACD histogram < 0
π‘ Why combine?
SuperTrend alone gives many false signals in a sideways market. MACD alone lags in strong trends. Combined, one filters the other’s errors. Result: fewer trades, but higher quality.
Complete Code
//@version=5
indicator("SuperTrend + MACD Combo β IA Trader Pro", overlay=true)
// === PARAMETERS ===
atrPeriod = input.int(10, "ATR Period SuperTrend")
factor = input.float(3.0, "SuperTrend Multiplier", step=0.1)
fastLen = input.int(12, "MACD Fast")
slowLen = input.int(26, "MACD Slow")
sigLen = input.int(9, "MACD Signal")
// === SUPERTREND ===
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
// === MACD ===
[macdLine, signalLine, hist] = ta.macd(close, fastLen, slowLen, sigLen)
// === SIGNALS ===
stBuy = direction < 0 and direction[1] >= 0
stSell = direction > 0 and direction[1] <= 0
comboBuy = stBuy and hist > 0
comboSell = stSell and hist < 0
// === PLOTS ===
upTrend = direction < 0 ? supertrend : na
dnTrend = direction > 0 ? supertrend : na
plot(upTrend, "ST Up", color=#b8893d, linewidth=3, style=plot.style_linebr)
plot(dnTrend, "ST Down", color=#dc2626, linewidth=3, style=plot.style_linebr)
// Background
bgcolor(direction < 0 ? color.new(#b8893d, 92) : color.new(#dc2626, 92))
// Combo signals
plotshape(comboBuy, "COMBO BUY", shape.labelup, location.belowbar, color.new(#b8893d, 0), text="π BUY", textcolor=color.white, size=size.normal)
plotshape(comboSell, "COMBO SELL", shape.labeldown, location.abovebar, color.new(#dc2626, 0), text="π SELL", textcolor=color.white, size=size.normal)
// SuperTrend-only signals (gray)
plotshape(stBuy and not comboBuy, "ST Up", shape.triangleup, location.belowbar, color.new(color.gray, 60), size=size.tiny)
plotshape(stSell and not comboSell, "ST Down", shape.triangledown, location.abovebar, color.new(color.gray, 60), size=size.tiny)
// Dashboard in top-right
var table dash = table.new(position.top_right, 2, 4, bgcolor=color.new(#fff, 20), border_width=1, border_color=color.new(color.gray, 80))
if barstate.islast
table.cell(dash, 0, 0, "Indicator", text_color=color.gray, text_size=size.tiny)
table.cell(dash, 1, 0, "Status", text_color=color.gray, text_size=size.tiny)
table.cell(dash, 0, 1, "SuperTrend", text_color=color.white, text_size=size.small)
table.cell(dash, 1, 1, direction < 0 ? "UP β²" : "DOWN βΌ", text_color=direction < 0 ? #b8893d : #dc2626, text_size=size.small)
table.cell(dash, 0, 2, "MACD Hist", text_color=color.white, text_size=size.small)
table.cell(dash, 1, 2, str.tostring(hist, "#.####"), text_color=hist > 0 ? #b8893d : #dc2626, text_size=size.small)
table.cell(dash, 0, 3, "Signal", text_color=color.white, text_size=size.small)
table.cell(dash, 1, 3, (direction < 0 and hist > 0) ? "π BUY" : (direction > 0 and hist < 0) ? "π SELL" : "βΈ WAIT", text_color=color.white, text_size=size.small)
// === ALERTS ===
alertcondition(comboBuy, "Combo BUY", "SuperTrend + MACD: BUY signal confirmed")
alertcondition(comboSell, "Combo SELL", "SuperTrend + MACD: SELL signal confirmed")
How to use
- Recommended timeframes: H1 or H4 (works best in medium-term trends)
- Assets: Forex majors, synthetic indices (V75), crypto
- Wait for the “COMBO” signal (with π BUY or π SELL label) β ignore the gray arrows
- Set up alerts to get notified when the combo fires
- Combine with 2x ATR stop loss and 4x ATR take profit (1:2 risk-reward)
β Best results
This combo works best in markets with clear trend. In choppy markets, signals become rare (which is good β it protects you from bad trades).
π Use this combo and apply on Deriv (free demo account):
Open Deriv Demo Account βπ Related
β 10 Pine Script Indicators
β Fibonacci AI Indicator
β How to Build Indicators with AI
