OPEN-SOURCE SCRIPT

MACD PRO + Filtro + Genesis

55
//version=6
indicator("MACD PRO + Filtro + Delay", overlay=true)

// ======================
// 🔧 INPUTS
// ======================
source = close
fastLen = input.int(12, "Fast")
slowLen = input.int(26, "Slow")
signalLen = input.int(9, "Signal")

delay = input.int(1, "Delay (velas após cruzamento)", minval=0, maxval=5)

emaFilterLen = input.int(100, "EMA Tendência")

// ======================
// 📊 MACD
// ======================
[macd, signal, hist] = ta.macd(source, fastLen, slowLen, signalLen)

// ======================
// 📈 FILTRO DE TENDÊNCIA
// ======================
ema = ta.ema(close, emaFilterLen)

trendBuy = close > ema
trendSell = close < ema

// ======================
// 🔀 CRUZAMENTOS
// ======================
buyCross = ta.crossover(macd, signal)
sellCross = ta.crossunder(macd, signal)

// ======================
// ⏱️ DELAY (controle de vela)
// ======================
buySignal = buyCross[delay]
sellSignal = sellCross[delay]

// ======================
// ✅ CONFIRMAÇÃO DE CANDLE
// ======================
candleBuy = close > open
candleSell = close < open

// ======================
// 🎯 SINAL FINAL (FILTROS)
// ======================
finalBuy = buySignal and trendBuy and candleBuy
finalSell = sellSignal and trendSell and candleSell

// ======================
// 📍 PLOTAGEM
// ======================
plotshape(finalBuy,
title="Compra",
style=shape.triangleup,
location=location.belowbar,
color=color.lime,
size=size.small,
text="BUY")

plotshape(finalSell,
title="Venda",
style=shape.triangledown,
location=location.abovebar,
color=color.red,
size=size.small,
text="SELL")

// ======================
// 📉 EMA NO GRÁFICO
// ======================
plot(ema, "EMA 200", color=color.orange)

// ======================
// 🔔 ALERTAS
// ======================
alertcondition(finalBuy, "Compra", "Sinal de COMPRA confirmado")
alertcondition(finalSell, "Venda", "Sinal de VENDA confirmado"

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.