本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Radar Institucional GEX [9 Ativos B3 + EWZ]", overlay=true, max_lines_count=50, max_labels_count=50)
// ============================================================================
// 1. ENTRADAS & PAYLOAD CONSOLIDADO (10 ATIVOS: 9 B3 + EWZ)
// Formato por ativo: TICKER|REGIME|FLIP|EM_MIN|EM_MAX|PW1|CW1|BLOCO|SIGMA1_MIN
// ============================================================================
string grp_data = "📡 Payload Institucional GEX"
string default_payload = "WIN|AMP|173360|171405|177005|173000|175000|174000|170140;" +
"BOVA11|AMP|168.40|164.75|171.25|167.00|170.00|168.00|163.50;" +
"EWZ|AMP|35.10|30.35|31.65|30.00|43.00|31.00|28.00;" +
"PETR4|AMP|45.65|44.13|46.47|44.91|46.41|46.41|43.41;" +
"VALE3|AMP|63.89|62.03|65.37|62.39|64.39|64.39|60.89;" +
"ITUB4|AMO|42.45|41.05|43.55|41.50|43.00|42.50|40.50;" +
"BBDC4|AMO|14.80|14.13|15.17|14.45|15.20|14.95|13.70;" +
"BBAS3|AMP|22.79|14.58|15.62|15.04|16.04|15.04|14.04;" +
"B3SA3|AMP|23.41|14.42|15.36|14.02|15.02|15.52|13.77;" +
"ABEV3|AMO|15.68|15.51|16.07|15.57|15.82|15.82|15.07"
string payload = input.text_area(default_payload, "String de Dados GEX", group=grp_data)
string exp_date = input.string("19/11 B3 | 20/11 EWZ", "Vencimento de Referência", group=grp_data)
string grp_vis = "🎨 Configurações Visuais"
bool show_levels = input.bool(true, "Plotar Linhas no Gráfico", group=grp_vis)
bool show_labels = input.bool(true, "Exibir Rótulos de Preço", group=grp_vis)
bool show_table = input.bool(true, "Exibir Painel Institucional", group=grp_vis)
string tbl_pos = input.string("top_right", "Posição do Painel", options=["top_right", "bottom_right", "top_left", "bottom_left"], group=grp_vis)
// ============================================================================
// 2. NORMALIZAÇÃO DO TICKER ATUAL (COMPATÍVEL COM WIN, B3 FRACIONÁRIO E EWZ)
// ============================================================================
f_normalize_ticker(string raw_ticker) =>
string t = str.upper(raw_ticker)
if str.startswith(t, "WIN")
"WIN"
else
// Remove sufixo 'F' de fracionário na B3 se houver, mantendo tickers como BOVA11 e EWZ
str.endswith(t, "F") and str.length(t) > 5 ? str.substring(t, 0, str.length(t) - 1) : t
string current_asset = f_normalize_ticker(syminfo.ticker)
// ============================================================================
// 3. PARSER DO PAYLOAD PARA O ATIVO ATIVO NO GRÁFICO
// ============================================================================
var string regime = "N/A"
var float gamma_flip = na
var float em_min = na
var float em_max = na
var float pw1 = na
var float cw1 = na
var float max_block = na
var float sigma1_min = na
var bool found = false
if barstate.islast
found := false
array<string> rows = str.split(payload, ";")
for row in rows
string clean_row = str.trim(row)
if str.length(clean_row) > 0
array<string> cols = str.split(clean_row, "|")
if array.size(cols) >= 9
string row_ticker = str.trim(array.get(cols, 0))
if row_ticker == current_asset
regime := str.trim(array.get(cols, 1))
gamma_flip := str.tonumber(str.trim(array.get(cols, 2)))
em_min := str.tonumber(str.trim(array.get(cols, 3)))
em_max := str.tonumber(str.trim(array.get(cols, 4)))
pw1 := str.tonumber(str.trim(array.get(cols, 5)))
cw1 := str.tonumber(str.trim(array.get(cols, 6)))
max_block := str.tonumber(str.trim(array.get(cols, 7)))
sigma1_min := str.tonumber(str.trim(array.get(cols, 8)))
found := true
break
// ============================================================================
// 4. PLOTAGEM DE LINHAS E RÓTULOS INSTITUCIONAIS
// ============================================================================
var line ln_flip = na, var label lb_flip = na
var line ln_cw1 = na, var label lb_cw1 = na
var line ln_pw1 = na, var label lb_pw1 = na
var line ln_emp = na, var label lb_emp = na
var line ln_emm = na, var label lb_emm = na
var line ln_blk = na, var label lb_blk = na
var line ln_sig = na, var label lb_sig = na
if barstate.islast and found and show_levels
// Limpeza antes de redesenhar
line.delete(ln_flip), label.delete(lb_flip)
line.delete(ln_cw1), label.delete(lb_cw1)
line.delete(ln_pw1), label.delete(lb_pw1)
line.delete(ln_emp), label.delete(lb_emp)
line.delete(ln_emm), label.delete(lb_emm)
line.delete(ln_blk), label.delete(lb_blk)
line.delete(ln_sig), label.delete(lb_sig)
int x1 = bar_index - 40
int x2 = bar_index + 10
int xl = bar_index + 6
// Gamma Flip (Amarelo Ouro - Divisor de Regime)
if not na(gamma_flip)
ln_flip := line.new(x1, gamma_flip, x2, gamma_flip, extend=extend.both, color=color.new(#FFD700, 0), style=line.style_solid, width=2)
if show_labels
lb_flip := label.new(xl, gamma_flip, "GAMMA FLIP: " + str.tostring(gamma_flip, format.mintick), color=color.new(#FFD700, 85), textcolor=#FFD700, style=label.style_label_left, size=size.small)
// Call Wall (CW1 - Verde Esmeralda)
if not na(cw1)
ln_cw1 := line.new(x1, cw1, x2, cw1, extend=extend.both, color=color.new(#00E676, 10), style=line.style_solid, width=2)
if show_labels
lb_cw1 := label.new(xl, cw1, "CALL WALL (CW1): " + str.tostring(cw1, format.mintick), color=color.new(#00E676, 85), textcolor=#00E676, style=label.style_label_left, size=size.small)
// Put Wall (PW1 - Vermelho Coral)
if not na(pw1)
ln_pw1 := line.new(x1, pw1, x2, pw1, extend=extend.both, color=color.new(#FF5252, 10), style=line.style_solid, width=2)
if show_labels
lb_pw1 := label.new(xl, pw1, "PUT WALL (PW1): " + str.tostring(pw1, format.mintick), color=color.new(#FF5252, 85), textcolor=#FF5252, style=label.style_label_left, size=size.small)
// Expected Move Max (EM+ - Azul Ciano Tracejado)
if not na(em_max)
ln_emp := line.new(x1, em_max, x2, em_max, extend=extend.both, color=color.new(#40C4FF, 30), style=line.style_dashed, width=1)
if show_labels
lb_emp := label.new(xl, em_max, "EM+: " + str.tostring(em_max, format.mintick), color=color.new(#40C4FF, 88), textcolor=#40C4FF, style=label.style_label_left, size=size.tiny)
// Expected Move Min (EM- - Azul Ciano Tracejado)
if not na(em_min)
ln_emm := line.new(x1, em_min, x2, em_min, extend=extend.both, color=color.new(#40C4FF, 30), style=line.style_dashed, width=1)
if show_labels
lb_emm := label.new(xl, em_min, "EM-: " + str.tostring(em_min, format.mintick), color=color.new(#40C4FF, 88), textcolor=#40C4FF, style=label.style_label_left, size=size.tiny)
// Maior Bloco OI / GEX (Roxo Pontilhado)
if not na(max_block) and max_block != cw1 and max_block != pw1
ln_blk := line.new(x1, max_block, x2, max_block, extend=extend.both, color=color.new(#E040FB, 25), style=line.style_dotted, width=1)
if show_labels
lb_blk := label.new(xl, max_block, "MAIOR BLOCO: " + str.tostring(max_block, format.mintick), color=color.new(#E040FB, 88), textcolor=#E040FB, style=label.style_label_left, size=size.tiny)
// Suporte 1σ- (Laranja Pontilhado)
if not na(sigma1_min)
ln_sig := line.new(x1, sigma1_min, x2, sigma1_min, extend=extend.both, color=color.new(#FFAB40, 25), style=line.style_dotted, width=1)
if show_labels
lb_sig := label.new(xl, sigma1_min, "SUPORTE 1σ-: " + str.tostring(sigma1_min, format.mintick), color=color.new(#FFAB40, 88), textcolor=#FFAB40, style=label.style_label_left, size=size.tiny)
// ============================================================================
// 5. PAINEL INSTITUCIONAL (HUD)
// ============================================================================
get_pos(string p) =>
switch p
"top_right" => position.top_right
"bottom_right" => position.bottom_right
"top_left" => position.top_left
=> position.bottom_left
var table hud = table.new(get_pos(tbl_pos), 2, 9, bgcolor=color.new(#12161F, 12), border_color=color.new(#2A3244, 0), border_width=1, frame_color=color.new(#3B465E, 0), frame_width=1)
if barstate.islast and show_table
table.clear(hud, 0, 0, 1, 8)
// Cabeçalho
table.cell(hud, 0, 0, "RADAR GEX • " + current_asset, text_color=color.white, bgcolor=color.new(#1E2638, 0), text_size=size.small, text_halign=text.align_left)
table.cell(hud, 1, 0, "Venc: " + exp_date, text_color=color.new(#90A4AE, 0), bgcolor=color.new(#1E2638, 0), text_size=size.tiny, text_halign=text.align_right)
if found
bool is_amp = regime == "AMP"
color reg_col = is_amp ? color.new(#FF5252, 0) : color.new(#00E676, 0)
string reg_txt = is_amp ? "🔴 AMPLIFICADO (Short Gamma)" : "🟢 AMORTECIDO (Long Gamma)"
table.cell(hud, 0, 1, "Regime GEX", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 1, reg_txt, text_color=reg_col, text_size=size.tiny, text_halign=text.align_right)
table.cell(hud, 0, 2, "Gamma Flip", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 2, str.tostring(gamma_flip, format.mintick), text_color=#FFD700, text_size=size.tiny, text_halign=text.align_right)
table.cell(hud, 0, 3, "Call Wall (CW1)", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 3, str.tostring(cw1, format.mintick), text_color=#00E676, text_size=size.tiny, text_halign=text.align_right)
table.cell(hud, 0, 4, "Put Wall (PW1)", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 4, str.tostring(pw1, format.mintick), text_color=#FF5252, text_size=size.tiny, text_halign=text.align_right)
table.cell(hud, 0, 5, "Expected Move", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 5, str.tostring(em_min, format.mintick) + " – " + str.tostring(em_max, format.mintick), text_color=#40C4FF, text_size=size.tiny, text_halign=text.align_right)
table.cell(hud, 0, 6, "Maior Bloco GEX", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 6, str.tostring(max_block, format.mintick), text_color=#E040FB, text_size=size.tiny, text_halign=text.align_right)
table.cell(hud, 0, 7, "Suporte 1σ-", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 7, str.tostring(sigma1_min, format.mintick), text_color=#FFAB40, text_size=size.tiny, text_halign=text.align_right)
string pos_flip = close > gamma_flip ? "ACIMA DO FLIP (Estabilidade)" : "ABAIXO DO FLIP (Aceleração)"
color pos_col = close > gamma_flip ? #00E676 : #FF5252
table.cell(hud, 0, 8, "Status Spot", text_color=color.silver, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 8, pos_flip, text_color=pos_col, text_size=size.tiny, text_halign=text.align_right)
else
table.cell(hud, 0, 1, "Ativo fora da grade GEX", text_color=color.gray, text_size=size.tiny, text_halign=text.align_left)
table.cell(hud, 1, 1, "9 B3 + EWZ", text_color=color.gray, text_size=size.tiny, text_halign=text.align_right)