-
Notifications
You must be signed in to change notification settings - Fork 48
Description
instrument {
name = "GHF – ENTRADA M1 + HTF (Seta ENTRAR c/ Label)",
icon = "indicators:EMA",
overlay = true
}
-- =========================
-- INPUTS
-- =========================
input_group {
"Cores de Candles e Sinais",
comprar_color = input { default = "#0bd104", type = input.color }, -- candle verde
vender_color = input { default = "#f70202", type = input.color }, -- candle vermelho
candle_neutro = input { default = "#9e9e9e", type = input.color }, -- candle neutro
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 {
"SR – Suporte/Resistência",
upline_color = input { default = "#2e86de", type = input.color },
lowline_color = input { default = "#e74c3c", type = input.color },
line_width = input { default = 2, type = input.line_width }
}
input_group {
"ZigZag (%)",
percentage = input (3.0, "Percentage", input.double, 0.01, 100.0, 0.1),
zz_up_color = input { default = "#02f7aa", type = input.color },
zz_down_color = input { default = "#f77902", type = input.color },
zz_width = input { default = 1, type = input.line_width }
}
input_group {
"Confirmação HTF e Entrada",
htf_res = input ("15m", "HTF", input.string_selection, {"15m","30m","1h"}),
entry_on_next = input (false, "Marcar ENTRAR na próxima vela (offset=1)")
}
-- =========================
-- BASE / 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 (cor da vela)
TA = (close > close[1]) and (close > EMAA) and (EMAA > EMAA[1]) -- verde
TB = (close < close[1]) and (close < EMAA) and (EMAA < EMAA[1]) -- vermelha
bar_color = candle_neutro
if TA then bar_color = comprar_color end
if TB then bar_color = vender_color end
-- Cruzamentos HLC3
ENC = (EMAC[1] < EMAD[1]) and (EMAC > EMAD) -- rápido cruza para cima
ENV = (EMAC[1] > EMAD[1]) and (EMAC < EMAD) -- rápido cruza para baixo
-- =========================
-- CONFIRMAÇÃO NO 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 BÁSICOS
-- =========================
plot_candle(open, high, low, close, "Candles GHF", bar_color)
plot(upper, "Resistência", upline_color, line_width)
plot(lower, "Suporte", lowline_color, line_width)
-- =========================
-- 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: SETA + LABEL "ENTRAR"
-- =========================
entry_offset = entry_on_next and 1 or 0
if buy_ok then
plot_shape(1, "BUY_ENTRY", shape_style.labelup, shape_size.huge, call_color, shape_location.belowbar, entry_offset, "ENTRAR", "BUY")
end
if sell_ok then
plot_shape(1, "SELL_ENTRY", shape_style.labeldown, shape_size.huge, put_color, shape_location.abovebar, entry_offset, "ENTRAR", "SELL")
end