-
Notifications
You must be signed in to change notification settings - Fork 48
Description
instrument {
name = "GHF – ENTRADA M1 + HTF (Velas Cinza / Próxima Vela)",
icon = "indicators:EMA",
overlay = true
}
-- =========================
-- INPUTS
-- =========================
input_group {
"Cores de Candles e Sinais",
candle_neutro = input { default = "#9e9e9e", type = input.color }, -- velas sempre cinza
call_color = input { default = "#34d399", type = input.color }, -- seta buy
put_color = input { default = "#f87171", type = input.color } -- seta sell
}
input_group {
"Períodos",
doch_time = input { default = 10, type = input.integer, min = 1, max = 10000 },
emaa_per = input { default = 10, type = input.integer, min = 1, max = 10000 }, -- micro
emab_per = input { default = 100, type = input.integer, min = 1, max = 10000 }, -- macro
emac_per = input { default = 3, type = input.integer, min = 1, max = 10000 }, -- rápida (HLC3)
emad_per = input { default = 13, type = input.integer, min = 1, max = 10000 } -- lenta (HLC3)
}
input_group {
"Confirmação HTF",
htf_res = input ("15m", "HTF", input.string_selection, {"15m","30m","1h"})
}
-- =========================
-- SÉRIES M1
-- =========================
HLC3 = (high + low + close) / 3.0
EMAA = ema(close, emaa_per) -- micro
EMAB = ema(close, emab_per) -- macro
EMAC = ema(HLC3, emac_per) -- rápida (HLC3)
EMAD = ema(HLC3, emad_per) -- lenta (HLC3)
upper = highest(high, doch_time)
lower = lowest(low, doch_time)
-- Micro-tendência (apenas pra lógica; NÃO colore vela)
TA = (close > close[1]) and (close > EMAA) and (EMAA > EMAA[1])
TB = (close < close[1]) and (close < EMAA) and (EMAA < EMAA[1])
-- Cruzamentos HLC3
ENC = (EMAC[1] < EMAD[1]) and (EMAC > EMAD) -- rápido cruza p/ cima
ENV = (EMAC[1] > EMAD[1]) and (EMAC < EMAD) -- rápido cruza p/ baixo
-- =========================
-- CONFIRMAÇÃO HTF
-- =========================
sec = security(current_ticker_id, htf_res)
if sec then
htf_close = sec.close
htf_emab = ema(htf_close, emab_per)
htf_macro_up = (htf_close > htf_emab) and (htf_emab > htf_emab[1])
htf_macro_dn = (htf_close < htf_emab) and (htf_emab < htf_emab[1])
else
htf_macro_up, htf_macro_dn = true, true -- fallback se HTF indisponível
end
-- =========================
-- PLOTS: velas SEMPRE CINZA + SR
-- =========================
plot_candle(open, high, low, close, "Candles GHF", candle_neutro)
plot(upper, "Resistência", "#2e86de", 2)
plot(lower, "Suporte", "#e74c3c", 2)
-- =========================
-- PADRÕES + CONFLUÊNCIA
-- =========================
bull_engulf = (close[1] < open[1]) and (close > open) and (close > high[1]) and (close[2] >= open)
bear_engulf = (close[1] > open[1]) and (close < open) and (close < low[1]) and (close[2] <= open)
bull_seq = (close > close[1]) and (close[1] > open[2]) and (close[3] > close[2])
bear_seq = (close < close[1]) and (close[1] < open[2]) and (close[3] < close[2])
buy_raw = (bull_engulf or bull_seq) and TA and ENC
sell_raw = (bear_engulf or bear_seq) and TB and ENV
buy_ok = buy_raw and htf_macro_up
sell_ok = sell_raw and htf_macro_dn
-- =========================
-- ENTRADA NA PRÓXIMA VELA (offset = 1)
-- =========================
entry_offset = 1
if buy_ok then
plot_shape(1, "BUY_NEXT", shape_style.labelup, shape_size.huge, call_color, shape_location.belowbar, entry_offset, "ENTRAR", "BUY")
end
if sell_ok then
plot_shape(1, "SELL_NEXT", shape_style.labeldown, shape_size.huge, put_color, shape_location.abovebar, entry_offset, "ENTRAR", "SELL")
end