FREE TRADINGVIEW PINE SCRIPT

12 INDICATORS.ONE CLEAN MATRIX.

Alpha Capital MTF Trend Matrix (aka. Efmus System) combines MACD, RSI, Pivot, EMA Cross, moving-average filters and pullback detection inside one TradingView dashboard.

✓ Pine Script v5 + v6 ✓ Free source code ✓ Built for TradingView
ALPHA CAPITALMTF TREND MATRIX
12
INDICATORSinside one dashboard
MACDRSIPIVOTEMA CROSS EMA 21SMA 50EMA 55EMA 89 EMA 144SMA 200MTF FILTERPULLBACK
One dashboard instead of a chart full of separate indicators.Choose your Pine version, copy the code and add it to TradingView.
1. COPY2. PASTE IN PINE EDITOR3. ADD TO CHART
SOURCE CODE

Choose your Pine Script version.

Version 5 is kept for users of the original script. Version 6 is the newer edition.

PINE SCRIPTVersion 5

	  
//@version=5
indicator("Alpha Capital — MTF Trend Matrix", shorttitle="Alpha Capital — MTF Trend Matrix", overlay=false, precision=0, max_labels_count=200)

//──────────────────────────────────────────────────────────────────────────────
// Alpha Capital — Multi Timeframe Trend Matrix
// Cleaner visual version of the original: MACD, RSI, Pivot, EMA Cross, Pullback,
// and moving-average trend filters in one readable dashboard.
//──────────────────────────────────────────────────────────────────────────────

// ── Groups
GRP_TIME   = "01. Timeframe"
GRP_MA     = "02. Moving Averages"
GRP_CROSS  = "03. EMA Cross"
GRP_RSI    = "04. RSI"
GRP_MACD   = "05. MACD"
GRP_VISUAL = "06. Visual Settings"

// ── Inputs
higher_tf = input.timeframe("D", "Indicator Timeframe", group=GRP_TIME)

ema1 = input.int(21,  "EMA 1",  minval=1, group=GRP_MA)
sma1 = input.int(50,  "SMA 1",  minval=1, group=GRP_MA)
ema2 = input.int(55,  "EMA 2",  minval=1, group=GRP_MA)
ema3 = input.int(89,  "EMA 3",  minval=1, group=GRP_MA)
ema4 = input.int(144, "EMA 4",  minval=1, group=GRP_MA)
sma2 = input.int(200, "SMA 2",  minval=1, group=GRP_MA)

fastCrossLen = input.int(13, "Fast EMA Cross", minval=1, maxval=300, group=GRP_CROSS)
slowCrossLen = input.int(48, "Slow EMA Cross", minval=1, maxval=300, group=GRP_CROSS)

rsiLen   = input.int(9,  "RSI Length", minval=1, group=GRP_RSI)
rsiUpper = input.int(70, "RSI Upper Level", minval=1, maxval=100, group=GRP_RSI)
rsiLower = input.int(30, "RSI Lower Level", minval=1, maxval=100, group=GRP_RSI)

macdFast = input.int(12, "MACD Fast MA", minval=1, group=GRP_MACD)
macdSlow = input.int(26, "MACD Slow MA", minval=1, group=GRP_MACD)
macdSig  = input.int(9,  "MACD Signal",  minval=1, group=GRP_MACD)

showTD       = input.bool(true,  "Show Pullback Marks", group=GRP_VISUAL)
showTable    = input.bool(true,  "Show Dashboard Table", group=GRP_VISUAL)
showBgSignal = input.bool(false, "Soft Background on Strong Signal", group=GRP_VISUAL)

// ── Premium Color Palette
bullStrong = color.rgb(22, 163, 74)
bullSoft   = color.rgb(74, 222, 128)
bearStrong = color.rgb(220, 38, 38)
bearSoft   = color.rgb(248, 113, 113)
neutral    = color.rgb(148, 163, 184)
darkPanel  = color.rgb(2, 6, 23)
lineSoft   = color.rgb(30, 41, 59)
gold       = color.rgb(245, 158, 11)

// ── Multi-timeframe values
[closeTF, closeTFPrev, ma21, ma50, ma55, ma89, ma144, ma200, crossFast, crossSlow] = request.security(syminfo.tickerid,higher_tf,[close, close[1], ta.ema(close, ema1), ta.sma(close, sma1), ta.ema(close, ema2), ta.ema(close, ema3), ta.ema(close, ema4), ta.sma(close, sma2), ta.ema(close, fastCrossLen), ta.ema(close, slowCrossLen)])

// ── Helpers
f_trendColor(bool bull, bool bear) => bull ? bullStrong : bear ? bearStrong : neutral
f_statusText(bool bull, bool bear) => bull ? "Bullish" : bear ? "Bearish" : "Neutral"
f_icon(bool bull, bool bear) => bull ? "▲" : bear ? "▼" : "•"
f_maColor(float ma) => closeTF > ma ? bullStrong : bearStrong
f_maText(float ma) => closeTF > ma ? "Above" : "Below"

// ── RSI
rsiUp   = ta.rma(math.max(ta.change(closeTF), 0), rsiLen)
rsiDown = ta.rma(-math.min(ta.change(closeTF), 0), rsiLen)
rsi     = rsiDown == 0 ? 100 : rsiUp == 0 ? 0 : 100 - 100 / (1 + rsiUp / rsiDown)

rsiOverbought = rsi > rsiUpper
rsiOversold   = rsi < rsiLower
rsiBullish    = rsi > 50
rsiBearish    = rsi < 50
rsiColor      = rsiOverbought ? bullStrong : rsiOversold ? bearStrong : rsiBullish ? bullSoft : rsiBearish ? bearSoft : neutral

// ── MACD
[currMacd, _, _] = ta.macd(closeTF, macdFast, macdSlow, macdSig)
[prevMacd, _, _] = ta.macd(closeTFPrev, macdFast, macdSlow, macdSig)
macdRising  = currMacd > prevMacd
macdBullish = currMacd > 0
macdBearish = currMacd < 0
macdColor   = macdBullish ? macdRising ? bullSoft : bullStrong : macdRising ? bearSoft : bearStrong

// ── EMA Cross
crossBullish = crossFast > crossSlow
crossBearish = crossFast < crossSlow
crossColor   = f_trendColor(crossBullish, crossBearish)

// ── Pivot
pivot = (high + low + close) / 3.0
pivotTF = timeframe.isintraday ? "W" : "M"
mtfPivot = request.security(syminfo.tickerid, pivotTF, pivot[0])
pivotBullish = close > mtfPivot
pivotBearish = close < mtfPivot
pivotColor   = f_trendColor(pivotBullish, pivotBearish)

// ── Pullback Pullback Logic
priceUp   = close > close[4]
priceDown = close < close[4]

var int countUp = 0
var int countDown = 0

if priceUp
    countUp += 1
    countDown := 0
else if priceDown
    countDown += 1
    countUp := 0
else
    countUp := 0
    countDown := 0

buy9  = countDown == 9
buy13 = countDown == 13
buy14 = countDown == 14
buy15 = countDown == 15
buy16 = countDown == 16

sell9  = countUp == 9
sell13 = countUp == 13
sell14 = countUp == 14
sell15 = countUp == 15
sell16 = countUp == 16

tdLong  = buy9 or buy13 or buy14 or buy15 or buy16
tdShort = sell9 or sell13 or sell14 or sell15 or sell16

plotchar(showTD and sell9,  title="TD Sell 9",  char="▼", size=size.tiny,  color=bearStrong, location=location.abovebar, force_overlay=true)
plotchar(showTD and sell13, title="TD Sell 13", char="▼", size=size.small, color=color.new(bearStrong, 10), location=location.abovebar, force_overlay=true)
plotchar(showTD and sell14, title="TD Sell 14", char="▼", size=size.small, color=color.new(bearStrong, 20), location=location.abovebar, force_overlay=true)
plotchar(showTD and sell15, title="TD Sell 15", char="▼", size=size.small, color=color.new(bearStrong, 30), location=location.abovebar, force_overlay=true)
plotchar(showTD and sell16, title="TD Sell 16", char="▼", size=size.small, color=color.new(bearStrong, 40), location=location.abovebar, force_overlay=true)

plotchar(showTD and buy9,  title="TD Buy 9",  char="▲", size=size.tiny,  color=bullStrong, location=location.belowbar, force_overlay=true)
plotchar(showTD and buy13, title="TD Buy 13", char="▲", size=size.small, color=color.new(bullStrong, 10), location=location.belowbar, force_overlay=true)
plotchar(showTD and buy14, title="TD Buy 14", char="▲", size=size.small, color=color.new(bullStrong, 20), location=location.belowbar, force_overlay=true)
plotchar(showTD and buy15, title="TD Buy 15", char="▲", size=size.small, color=color.new(bullStrong, 30), location=location.belowbar, force_overlay=true)
plotchar(showTD and buy16, title="TD Buy 16", char="▲", size=size.small, color=color.new(bullStrong, 40), location=location.belowbar, force_overlay=true)

// ── Global Signal
signalBullish = macdBullish and pivotBullish and crossBullish and rsiBullish
signalBearish = macdBearish and pivotBearish and crossBearish and rsiBearish
signalColor   = signalBullish ? bullStrong : signalBearish ? bearStrong : neutral

score = 0
score += pivotBullish ? 1 : pivotBearish ? -1 : 0
score += macdBullish  ? 1 : macdBearish  ? -1 : 0
score += crossBullish ? 1 : crossBearish ? -1 : 0
score += rsiBullish   ? 1 : rsiBearish   ? -1 : 0
score += closeTF > ma21  ? 1 : -1
score += closeTF > ma50  ? 1 : -1
score += closeTF > ma55  ? 1 : -1
score += closeTF > ma89  ? 1 : -1
score += closeTF > ma144 ? 1 : -1
score += closeTF > ma200 ? 1 : -1

scoreText  = score >= 7 ? "Strong Bullish" : score >= 3 ? "Bullish" : score <= -7 ? "Strong Bearish" : score <= -3 ? "Bearish" : "Mixed"
scoreColor = score >= 3 ? bullStrong : score <= -3 ? bearStrong : gold

bgcolor(showBgSignal and signalBullish ? color.new(bullStrong, 90) : showBgSignal and signalBearish ? color.new(bearStrong, 90) : na)

// ── Visual Trend Matrix
plot(110, color=pivotColor, style=plot.style_columns, title="Pivot", linewidth=18, histbase=100)
plot(92,  color=macdColor,  style=plot.style_columns, title="MACD", linewidth=18, histbase=82)
plot(74,  color=crossColor, style=plot.style_columns, title="EMA Cross", linewidth=18, histbase=64)
plot(56,  color=rsiColor,   style=plot.style_columns, title="RSI", linewidth=18, histbase=46)

plot(28,  color=f_maColor(ma21),  style=plot.style_columns, title="EMA 21",  linewidth=10, histbase=22)
plot(16,  color=f_maColor(ma50),  style=plot.style_columns, title="SMA 50",  linewidth=10, histbase=10)
plot(4,   color=f_maColor(ma55),  style=plot.style_columns, title="EMA 55",  linewidth=10, histbase=-2)
plot(-8,  color=f_maColor(ma89),  style=plot.style_columns, title="EMA 89",  linewidth=10, histbase=-14)
plot(-20, color=f_maColor(ma144), style=plot.style_columns, title="EMA 144", linewidth=10, histbase=-26)
plot(-32, color=f_maColor(ma200), style=plot.style_columns, title="SMA 200", linewidth=10, histbase=-38)

hline(122, "Top", color=color.new(lineSoft, 70))
hline(40,  "Separator", color=color.new(lineSoft, 70))
hline(-44, "Bottom", color=color.new(lineSoft, 70))

// ── Dashboard Table
var table dash = table.new(position.bottom_right, 3, 13, bgcolor=darkPanel, border_width=1, border_color=lineSoft, frame_width=1, frame_color=lineSoft, force_overlay=true)

if showTable and barstate.islastconfirmedhistory
    table.cell(dash, 0, 0, "Alpha Capital", text_color=color.white, bgcolor=color.rgb(15, 23, 42), text_size=size.small)
    table.cell(dash, 1, 0, "State",         text_color=color.white, bgcolor=color.rgb(15, 23, 42), text_size=size.small)
    table.cell(dash, 2, 0, higher_tf,        text_color=color.white, bgcolor=color.rgb(15, 23, 42), text_size=size.small)

    table.cell(dash, 0, 1, "Market Bias", text_color=color.white, bgcolor=color.new(scoreColor, 75), text_size=size.small)
    table.cell(dash, 1, 1, scoreText,      text_color=scoreColor, bgcolor=color.new(scoreColor, 90), text_size=size.small)
    table.cell(dash, 2, 1, str.tostring(score) + "/10", text_color=scoreColor, bgcolor=color.new(scoreColor, 90), text_size=size.small)

    table.cell(dash, 0, 2, "Pivot",     text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 2, f_icon(pivotBullish, pivotBearish) + " " + f_statusText(pivotBullish, pivotBearish), text_color=pivotColor, text_size=size.small)
    table.cell(dash, 2, 2, str.tostring(mtfPivot, format.mintick), text_color=pivotColor, text_size=size.small)

    table.cell(dash, 0, 3, "MACD",      text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 3, f_icon(macdBullish, macdBearish) + " " + f_statusText(macdBullish, macdBearish), text_color=macdColor, text_size=size.small)
    table.cell(dash, 2, 3, str.tostring(currMacd, "#.###"), text_color=macdColor, text_size=size.small)

    table.cell(dash, 0, 4, "EMA Cross", text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 4, f_icon(crossBullish, crossBearish) + " " + f_statusText(crossBullish, crossBearish), text_color=crossColor, text_size=size.small)
    table.cell(dash, 2, 4, str.tostring(fastCrossLen) + "/" + str.tostring(slowCrossLen), text_color=crossColor, text_size=size.small)

    table.cell(dash, 0, 5, "RSI",       text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 5, f_icon(rsiBullish, rsiBearish) + " " + f_statusText(rsiBullish, rsiBearish), text_color=rsiColor, text_size=size.small)
    table.cell(dash, 2, 5, str.tostring(rsi, "#.##"), text_color=rsiColor, text_size=size.small)

    table.cell(dash, 0, 6, "EMA 21",  text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 6, f_maText(ma21),  text_color=f_maColor(ma21),  text_size=size.small)
    table.cell(dash, 2, 6, str.tostring(ma21, format.mintick),  text_color=f_maColor(ma21),  text_size=size.small)

    table.cell(dash, 0, 7, "SMA 50",  text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 7, f_maText(ma50),  text_color=f_maColor(ma50),  text_size=size.small)
    table.cell(dash, 2, 7, str.tostring(ma50, format.mintick),  text_color=f_maColor(ma50),  text_size=size.small)

    table.cell(dash, 0, 8, "EMA 55",  text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 8, f_maText(ma55),  text_color=f_maColor(ma55),  text_size=size.small)
    table.cell(dash, 2, 8, str.tostring(ma55, format.mintick),  text_color=f_maColor(ma55),  text_size=size.small)

    table.cell(dash, 0, 9, "EMA 89",  text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 9, f_maText(ma89),  text_color=f_maColor(ma89),  text_size=size.small)
    table.cell(dash, 2, 9, str.tostring(ma89, format.mintick),  text_color=f_maColor(ma89),  text_size=size.small)

    table.cell(dash, 0, 10, "EMA 144", text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 10, f_maText(ma144), text_color=f_maColor(ma144), text_size=size.small)
    table.cell(dash, 2, 10, str.tostring(ma144, format.mintick), text_color=f_maColor(ma144), text_size=size.small)

    table.cell(dash, 0, 11, "SMA 200", text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 11, f_maText(ma200), text_color=f_maColor(ma200), text_size=size.small)
    table.cell(dash, 2, 11, str.tostring(ma200, format.mintick), text_color=f_maColor(ma200), text_size=size.small)

    table.cell(dash, 0, 12, "Pullback", text_color=neutral, text_size=size.small)
    table.cell(dash, 1, 12, tdLong ? "Pullback Buy" : tdShort ? "Pullback Sell" : "Waiting", text_color=tdLong ? bullStrong : tdShort ? bearStrong : neutral, text_size=size.small)
    table.cell(dash, 2, 12, tdLong ? "▲" : tdShort ? "▼" : "•", text_color=tdLong ? bullStrong : tdShort ? bearStrong : neutral, text_size=size.small)

// ── Alerts
alertcondition(signalBullish, title="Bullish Signal", message="Alpha Capital MTF Matrix: Bullish Signal")
alertcondition(signalBearish, title="Bearish Signal", message="Alpha Capital MTF Matrix: Bearish Signal")
alertcondition(tdLong,        title="Pullback Buy", message="Alpha Capital MTF Matrix: Pullback Buy")
alertcondition(tdShort,       title="Pullback Sell", message="Alpha Capital MTF Matrix: Pullback Sell")
	  
	  
PINE SCRIPTVersion 6

	  
//@version=6
indicator('Trend Matrix (12 INDICATORS IN 1 : MACD.RSI.PIVOTS.EMA-CROSS + 7 MA + PULLBACK Detector)', shorttitle = '12 INDICATORS IN 1', overlay = false, max_labels_count = 500)

//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// COLORS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

BG = color.rgb(8, 12, 21)
PANEL = color.rgb(15, 23, 42)
BORDER = color.rgb(51, 65, 85)
BULL = color.rgb(34, 197, 94)
BEAR = color.rgb(239, 68, 68)
NEUTRAL = color.rgb(148, 163, 184)
GOLD = color.rgb(245, 158, 11)
BLUE = color.rgb(59, 130, 246)
TEXT = color.rgb(226, 232, 240)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUT GROUPS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

groupGeneral = '01 • General'
groupSignal = '02 • Signal Engine'
groupMA = '03 • Moving Averages'
groupRSI = '04 • RSI'
groupMACD = '05 • MACD'
groupCross = '06 • EMA Cross'
groupPivot = '07 • Pivot'
groupFilter = '08 • Quality Filter'
groupExhaustion = '09 • Price Exhaustion'
groupVisual = '10 • Visuals'


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

confirmOnClose = input.bool(true, 'Confirm signals on bar close', group = groupGeneral)
colorBars = input.bool(false, 'Color chart candles', group = groupGeneral)

signalThreshold = input.int(60, 'Minimum confluence score', minval = 20, maxval = 100, step = 10, group = groupSignal)

ema1Length = input.int(21, 'EMA 1', minval = 1, group = groupMA)
ema2Length = input.int(55, 'EMA 2', minval = 1, group = groupMA)
ema3Length = input.int(89, 'EMA 3', minval = 1, group = groupMA)
ema4Length = input.int(144, 'EMA 4', minval = 1, group = groupMA)
sma1Length = input.int(50, 'SMA 1', minval = 1, group = groupMA)
sma2Length = input.int(200, 'SMA 2', minval = 1, group = groupMA)

rsiLength = input.int(9, 'RSI Length', minval = 1, group = groupRSI)
rsiUpper = input.float(70, 'Upper Level', minval = 50, maxval = 100, group = groupRSI)
rsiLower = input.float(30, 'Lower Level', minval = 0, maxval = 50, group = groupRSI)

macdFast = input.int(12, 'Fast Length', minval = 1, group = groupMACD)
macdSlow = input.int(26, 'Slow Length', minval = 2, group = groupMACD)
macdSignalLength = input.int(9, 'Signal Length', minval = 1, group = groupMACD)

fastCrossLength = input.int(13, 'Fast EMA', minval = 1, maxval = 500, group = groupCross)
slowCrossLength = input.int(48, 'Slow EMA', minval = 2, maxval = 500, group = groupCross)

automaticPivot = input.bool(true, 'Automatic Pivot Timeframe', group = groupPivot)
manualPivotTimeframe = input.timeframe('W', 'Manual Pivot Timeframe', group = groupPivot)

useAdxFilter = input.bool(true, 'Use ADX Filter', group = groupFilter)
diLength = input.int(14, 'DI Length', minval = 1, group = groupFilter)
adxSmoothing = input.int(14, 'ADX Smoothing', minval = 1, group = groupFilter)
minimumAdx = input.float(18, 'Minimum ADX', minval = 1, step = 0.5, group = groupFilter)

showExhaustion = input.bool(true, 'Show exhaustion markers', group = groupExhaustion)
showExtendedExhaustion = input.bool(true, 'Show extended exhaustion', group = groupExhaustion)

showScore = input.bool(true, 'Show confluence score', group = groupVisual)
showBackground = input.bool(true, 'Show regime background', group = groupVisual)
showDashboard = input.bool(true, 'Show premium dashboard', group = groupVisual)
showMovingAverages = input.bool(false, 'Show moving averages', group = groupVisual)
showPivotLine = input.bool(false, 'Show pivot line', group = groupVisual)
showSignalLabels = input.bool(true, 'Show signal labels', group = groupVisual)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// MOVING AVERAGES
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

ema21 = ta.ema(close, ema1Length)
sma50 = ta.sma(close, sma1Length)
ema55 = ta.ema(close, ema2Length)
ema89 = ta.ema(close, ema3Length)
ema144 = ta.ema(close, ema4Length)
sma200 = ta.sma(close, sma2Length)

ema21Bull = close > ema21
ema21Bear = close < ema21

sma50Bull = close > sma50
sma50Bear = close < sma50

ema55Bull = close > ema55
ema55Bear = close < ema55

ema89Bull = close > ema89
ema89Bear = close < ema89

ema144Bull = close > ema144
ema144Bear = close < ema144

sma200Bull = close > sma200
sma200Bear = close < sma200


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SMA 200 VISUAL FILTER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

// Above SMA 200: bearish/red colors become 50% transparent.
// Below SMA 200: bullish/green colors become 50% transparent.

bullVisualColor = close < sma200 ? color.new(BULL, 50) : BULL
bearVisualColor = close > sma200 ? color.new(BEAR, 50) : BEAR


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// RSI
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

rsiValue = ta.rsi(close, rsiLength)

rsiBull = rsiValue > 50
rsiBear = rsiValue < 50

rsiZone = 'MID'

if rsiValue >= rsiUpper
    rsiZone := 'OB'
    rsiZone
else if rsiValue <= rsiLower
    rsiZone := 'OS'
    rsiZone


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// MACD
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[macdLine, macdSignal, macdHistogram] = ta.macd(close, macdFast, macdSlow, macdSignalLength)

macdBull = macdLine > 0
macdBear = macdLine < 0

macdDirection = ''

if macdLine > macdLine[1]
    macdDirection := ' UP'
    macdDirection
else if macdLine < macdLine[1]
    macdDirection := ' DOWN'
    macdDirection


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// EMA CROSS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

fastCrossEMA = ta.ema(close, fastCrossLength)
slowCrossEMA = ta.ema(close, slowCrossLength)

crossBull = fastCrossEMA > slowCrossEMA
crossBear = fastCrossEMA < slowCrossEMA

crossSpread = slowCrossEMA != 0 ? (fastCrossEMA - slowCrossEMA) / slowCrossEMA * 100 : 0


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CONFIRMED HIGHER-TIMEFRAME PIVOT
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

pivotTimeframe = automaticPivot ? timeframe.isintraday ? 'W' : 'M' : manualPivotTimeframe

confirmedPivot = request.security(syminfo.tickerid, pivotTimeframe, hlc3[1], lookahead = barmerge.lookahead_on)

pivotBull = close > confirmedPivot
pivotBear = close < confirmedPivot


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ADX QUALITY FILTER
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

[plusDI, minusDI, adxValue] = ta.dmi(diLength, adxSmoothing)

adxPass = not useAdxFilter or not na(adxValue) and adxValue >= minimumAdx


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CONFLUENCE SCORE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

f_vote(bool bullish, bool bearish) =>
    bullish ? 1 : bearish ? -1 : 0

voteTotal = f_vote(pivotBull, pivotBear) + f_vote(macdBull, macdBear) + f_vote(crossBull, crossBear) + f_vote(rsiBull, rsiBear) + f_vote(ema21Bull, ema21Bear) + f_vote(sma50Bull, sma50Bear) + f_vote(ema55Bull, ema55Bear) + f_vote(ema89Bull, ema89Bear) + f_vote(ema144Bull, ema144Bear) + f_vote(sma200Bull, sma200Bear)

confluenceScore = voteTotal * 10

bullishVotes = (pivotBull ? 1 : 0) + (macdBull ? 1 : 0) + (crossBull ? 1 : 0) + (rsiBull ? 1 : 0) + (ema21Bull ? 1 : 0) + (sma50Bull ? 1 : 0) + (ema55Bull ? 1 : 0) + (ema89Bull ? 1 : 0) + (ema144Bull ? 1 : 0) + (sma200Bull ? 1 : 0)

bearishVotes = (pivotBear ? 1 : 0) + (macdBear ? 1 : 0) + (crossBear ? 1 : 0) + (rsiBear ? 1 : 0) + (ema21Bear ? 1 : 0) + (sma50Bear ? 1 : 0) + (ema55Bear ? 1 : 0) + (ema89Bear ? 1 : 0) + (ema144Bear ? 1 : 0) + (sma200Bear ? 1 : 0)

neutralVotes = 10 - bullishVotes - bearishVotes


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SIGNAL ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

bullishSetup = confluenceScore >= signalThreshold and adxPass
bearishSetup = confluenceScore <= -signalThreshold and adxPass

confirmationReady = not confirmOnClose or barstate.isconfirmed

newBullishSignal = confirmationReady and bullishSetup and not bullishSetup[1]
newBearishSignal = confirmationReady and bearishSetup and not bearishSetup[1]

bullishExit = confirmationReady and not bullishSetup and bullishSetup[1]
bearishExit = confirmationReady and not bearishSetup and bearishSetup[1]


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// MARKET REGIME
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

marketRegime = 'NEUTRAL'

if confluenceScore >= 80 and adxValue >= minimumAdx
    marketRegime := 'STRONG BULL'
    marketRegime
else if confluenceScore >= signalThreshold
    marketRegime := 'BULLISH'
    marketRegime
else if confluenceScore >= 20
    marketRegime := 'LEAN BULL'
    marketRegime
else if confluenceScore <= -80 and adxValue >= minimumAdx
    marketRegime := 'STRONG BEAR'
    marketRegime
else if confluenceScore <= -signalThreshold
    marketRegime := 'BEARISH'
    marketRegime
else if confluenceScore <= -20
    marketRegime := 'LEAN BEAR'
    marketRegime

regimeColor = NEUTRAL

if bullishSetup
    regimeColor := bullVisualColor
    regimeColor
else if bearishSetup
    regimeColor := bearVisualColor
    regimeColor
else if confluenceScore > 0
    regimeColor := close < sma200 ? color.new(BULL, 50) : color.new(BULL, 20)
    regimeColor
else if confluenceScore < 0
    regimeColor := close > sma200 ? color.new(BEAR, 50) : color.new(BEAR, 20)
    regimeColor


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// PRICE EXHAUSTION
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

priceUp = not na(close[4]) and close > close[4]
priceDown = not na(close[4]) and close < close[4]

var int upSequence = 0
var int downSequence = 0

if priceUp
    upSequence := upSequence + 1
    upSequence
else
    upSequence := 0
    upSequence

if priceDown
    downSequence := downSequence + 1
    downSequence
else
    downSequence := 0
    downSequence

// Internal count is never displayed.
sellExhaustion = upSequence == 9
buyExhaustion = downSequence == 9

sellProgress = upSequence >= 10 and upSequence <= 12
buyProgress = downSequence >= 10 and downSequence <= 12

sellExtended = upSequence >= 13 and upSequence <= 16
buyExtended = downSequence >= 13 and downSequence <= 16


// Initial exhaustion arrows.
plotchar(showExhaustion and sellExhaustion, title = 'Sell Exhaustion', char = '⤵', location = location.abovebar, color = bearVisualColor, size = size.tiny, force_overlay = true)
plotchar(showExhaustion and buyExhaustion, title = 'Buy Exhaustion', char = '⤴', location = location.belowbar, color = bullVisualColor, size = size.tiny, force_overlay = true)

// Continuation points.
plotchar(showExhaustion and sellProgress, title = 'Sell Exhaustion Progress', char = '•', location = location.abovebar, color = bearVisualColor, size = size.small, force_overlay = true)
plotchar(showExhaustion and buyProgress, title = 'Buy Exhaustion Progress', char = '•', location = location.belowbar, color = bullVisualColor, size = size.small, force_overlay = true)

// Large extended exhaustion arrows.
plotchar(showExhaustion and showExtendedExhaustion and sellExtended, title = 'Extended Sell Exhaustion', char = '⤵', location = location.abovebar, color = bearVisualColor, size = size.small, force_overlay = true)
plotchar(showExhaustion and showExtendedExhaustion and buyExtended, title = 'Extended Buy Exhaustion', char = '⤴', location = location.belowbar, color = bullVisualColor, size = size.small, force_overlay = true)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SCORE OSCILLATOR
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

plot(showScore ? confluenceScore : na, title = 'Confluence Score', color = color.new(regimeColor, 10), linewidth = 4, style = plot.style_columns, histbase = 0)
plot(showScore ? confluenceScore : na, title = 'Score Line', color = regimeColor, linewidth = 2)

plot(showScore ? signalThreshold : na, title = 'Bullish Threshold', color = color.new(bullVisualColor, 45), linewidth = 1)
plot(showScore ? -signalThreshold : na, title = 'Bearish Threshold', color = color.new(bearVisualColor, 45), linewidth = 1)
plot(showScore ? 0 : na, title = 'Neutral Line', color = color.new(NEUTRAL, 70), linewidth = 1)

bgcolor(showBackground ? color.new(regimeColor, 94) : na)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// OPTIONAL CHART OVERLAYS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

plot(showMovingAverages ? ema21 : na, title = 'EMA 21', color = BLUE, linewidth = 2, force_overlay = true)
plot(showMovingAverages ? sma50 : na, title = 'SMA 50', color = GOLD, linewidth = 2, force_overlay = true)
plot(showMovingAverages ? ema55 : na, title = 'EMA 55', color = color.aqua, linewidth = 1, force_overlay = true)
plot(showMovingAverages ? ema89 : na, title = 'EMA 89', color = color.purple, linewidth = 1, force_overlay = true)
plot(showMovingAverages ? ema144 : na, title = 'EMA 144', color = color.orange, linewidth = 1, force_overlay = true)
plot(showMovingAverages ? sma200 : na, title = 'SMA 200', color = BEAR, linewidth = 3, force_overlay = true)

plot(showPivotLine ? confirmedPivot : na, title = 'Confirmed Pivot', color = GOLD, linewidth = 2, style = plot.style_stepline, force_overlay = true)

plotshape(showSignalLabels and newBullishSignal, title = 'Bullish Signal', style = shape.labelup, location = location.belowbar, color = bullVisualColor, text = 'BULL', textcolor = color.white, size = size.small, force_overlay = true)
plotshape(showSignalLabels and newBearishSignal, title = 'Bearish Signal', style = shape.labeldown, location = location.abovebar, color = bearVisualColor, text = 'BEAR', textcolor = color.white, size = size.small, force_overlay = true)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CANDLE COLORS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

chartBarColor = NEUTRAL

if bullishSetup
    chartBarColor := bullVisualColor
    chartBarColor
else if bearishSetup
    chartBarColor := bearVisualColor
    chartBarColor
else if confluenceScore > 0
    chartBarColor := close < sma200 ? color.new(BULL, 50) : color.new(BULL, 35)
    chartBarColor
else if confluenceScore < 0
    chartBarColor := close > sma200 ? color.new(BEAR, 50) : color.new(BEAR, 35)
    chartBarColor

barcolor(colorBars ? chartBarColor : na)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// DASHBOARD FUNCTIONS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

f_state(bool bullish, bool bearish) =>
    bullish ? 'BULLISH' : bearish ? 'BEARISH' : 'NEUTRAL'

f_stateColor(bool bullish, bool bearish) =>
    bullish ? bullVisualColor : bearish ? bearVisualColor : NEUTRAL

f_row(table tableId, int row, string name, bool bullish, bool bearish, string value) =>
    rowColor = f_stateColor(bullish, bearish)
    table.cell(tableId, 0, row, name, bgcolor = PANEL, text_color = TEXT, text_size = size.small, text_halign = text.align_left)
    table.cell(tableId, 1, row, f_state(bullish, bearish), bgcolor = color.new(rowColor, 84), text_color = rowColor, text_size = size.small, text_halign = text.align_center)
    table.cell(tableId, 2, row, value, bgcolor = PANEL, text_color = NEUTRAL, text_size = size.small, text_halign = text.align_right)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// PREMIUM DASHBOARD
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

var table dashboard = table.new(position.bottom_right, 3, 13, bgcolor = BG, frame_color = BORDER, frame_width = 1, border_color = BORDER, border_width = 1, force_overlay = true)

if barstate.isfirst
    table.merge_cells(dashboard, 0, 0, 2, 0)

if barstate.islast
    if showDashboard
        dashboardTitle = 'EFMUS PREMIUM | ' + syminfo.ticker + ' | SCORE ' + str.tostring(confluenceScore, '#')

        table.cell(dashboard, 0, 0, dashboardTitle, bgcolor = BG, text_color = regimeColor, text_size = size.normal, text_halign = text.align_center)

        table.cell(dashboard, 0, 1, 'COMPONENT', bgcolor = PANEL, text_color = NEUTRAL, text_size = size.small)
        table.cell(dashboard, 1, 1, 'STATE', bgcolor = PANEL, text_color = NEUTRAL, text_size = size.small, text_halign = text.align_center)
        table.cell(dashboard, 2, 1, 'VALUE', bgcolor = PANEL, text_color = NEUTRAL, text_size = size.small, text_halign = text.align_right)

        f_row(dashboard, 2, 'HTF Pivot', pivotBull, pivotBear, str.tostring(confirmedPivot, format.mintick))
        f_row(dashboard, 3, 'MACD', macdBull, macdBear, str.tostring(macdLine, '#.####') + macdDirection)
        f_row(dashboard, 4, 'EMA Cross', crossBull, crossBear, str.tostring(crossSpread, '#.00') + '%')
        f_row(dashboard, 5, 'RSI', rsiBull, rsiBear, str.tostring(rsiValue, '#.0') + ' ' + rsiZone)
        f_row(dashboard, 6, 'EMA ' + str.tostring(ema1Length), ema21Bull, ema21Bear, str.tostring(ema21, format.mintick))
        f_row(dashboard, 7, 'SMA ' + str.tostring(sma1Length), sma50Bull, sma50Bear, str.tostring(sma50, format.mintick))
        f_row(dashboard, 8, 'EMA ' + str.tostring(ema2Length), ema55Bull, ema55Bear, str.tostring(ema55, format.mintick))
        f_row(dashboard, 9, 'EMA ' + str.tostring(ema3Length), ema89Bull, ema89Bear, str.tostring(ema89, format.mintick))
        f_row(dashboard, 10, 'EMA ' + str.tostring(ema4Length), ema144Bull, ema144Bear, str.tostring(ema144, format.mintick))
        f_row(dashboard, 11, 'SMA ' + str.tostring(sma2Length), sma200Bull, sma200Bear, str.tostring(sma200, format.mintick))

        table.cell(dashboard, 0, 12, 'REGIME', bgcolor = BG, text_color = TEXT, text_size = size.small)
        table.cell(dashboard, 1, 12, marketRegime, bgcolor = color.new(regimeColor, 82), text_color = regimeColor, text_size = size.small, text_halign = text.align_center)
        table.cell(dashboard, 2, 12, str.tostring(bullishVotes) + 'B / ' + str.tostring(bearishVotes) + 'S / ' + str.tostring(neutralVotes) + 'N | ADX ' + str.tostring(adxValue, '#.0'), bgcolor = BG, text_color = NEUTRAL, text_size = size.small, text_halign = text.align_right)
    else
        table.clear(dashboard, 0, 0, 2, 12)


//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ALERTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

alertcondition(newBullishSignal, title = 'EFMUS - New Bullish Signal', message = '{{ticker}} {{interval}} | New bullish confluence | Close: {{close}}')
alertcondition(newBearishSignal, title = 'EFMUS - New Bearish Signal', message = '{{ticker}} {{interval}} | New bearish confluence | Close: {{close}}')
alertcondition(bullishExit, title = 'EFMUS - Bullish Regime Ended', message = '{{ticker}} {{interval}} | Bullish confluence ended | Close: {{close}}')
alertcondition(bearishExit, title = 'EFMUS - Bearish Regime Ended', message = '{{ticker}} {{interval}} | Bearish confluence ended | Close: {{close}}')
	  
	  
Paste the code into TradingView Pine Editor, save it, then add the script to your chart.
FROM INDICATORS TO A COMPLETE PROCESS

This script organizes indicators.Alpha AI goes further.

The free matrix helps organize technical conditions in one place. Alpha AI is built around the full strategy process.

FREE MTF TREND MATRIX

Organize the signals.

MACDRSIPIVOTEMAMA FILTERSPULLBACK

Multiple technical readings combined into one cleaner TradingView view.

ALPHA AI

Follow one defined process.

ENTRYPOSITION SIZEEXITRECORDED RESULT

One Alpha AI logic applied across 80+ supported markets, with public historical and recent records.

WANT TO GO BEYOND INDICATORS?Explore the strategy behind Alpha AI.
Important: This free script is provided for informational and research purposes. Trading involves risk. Historical or technical signals do not guarantee future results.

Disclaimer: Alpha Capital is operated by WideMena FZC, Building 8, Dubai Media City, UAE (License No. 95026), a technology company providing trading software, strategies and educational content. Alpha Capital is not a broker-dealer, financial advisor or asset manager, and never holds client funds. Nothing on this site is personalized investment advice: you decide on, and place, every trade in your own account. Trading, especially leveraged products such as CFDs, involves a high risk of losing money and is not suitable for everyone. Live results come from our own account at Capital.com, read through the broker’s API since January 2025; Capital.com does not endorse Alpha Capital. Historical results shown on TradingView apply Alpha’s rules to past market data; they are not trades from a live account. Past performance does not guarantee future results.