OPEN-SOURCE SCRIPT

MACD PRO + Filtro + Genesis

57
//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"

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.