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"

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.