OPEN-SOURCE SCRIPT

Bloomberg Terminal

105
//version=6
indicator("Bloomberg Terminal [QuantLabsCustom]", shorttitle="QUANTLABS", overlay=true, max_lines_count=500, max_labels_count=500)

// =============================================================================
// I. SETTINGS & THEME (ULTIMATE FIDELITY)
// =============================================================================
group_layout = "Terminal Layout"
sz_text = input.string(size.large, "Font Size", options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group=group_layout)
pos_main = input.string(position.top_right, "Position", options=[position.top_right, position.bottom_right, position.bottom_center, position.top_center], group=group_layout)

group_colors = "Terminal Colors"
c_bg_main = color.black
c_bg_alt = color.rgb(15, 15, 15) // Subtle Zebra
c_amber = input.color(#ffb300, "Terminal Amber", group=group_colors)
c_header = input.color(#00294d, "Bloomberg Blue", group=group_colors)
c_bull = input.color(#00e676, " Terminal Green", group=group_colors)
c_bear = input.color(#ff1744, "Terminal Red", group=group_colors)
c_neutral = input.color(#b0bec5, "Terminal Gray", group=group_colors)
c_white = color.white

// =============================================================================
// II. DATA ENGINE & SPARKLINE LOGIC
// =============================================================================
type asset_data
float price
float chg
float rvol
bool is_up
float c1
float c2
float c3

f_get_stats(_sym) =>
[_c, _o, _v, _avg_v, _c1, _c2] = request.security(_sym, timeframe.period, [close, open, volume, ta.sma(volume, 20), close[1], close[2]], ignore_invalid_symbol=true)
_chg = (_c - _o) / _o * 100
asset_data.new(_c, _chg, _v / (_avg_v + 0.0001), _chg >= 0, _c, _c1, _c2)

// Market Data
d_spy = f_get_stats("AMEX:SPY")
d_qqq = f_get_stats("NASDAQ:QQQ")
d_iwm = f_get_stats("AMEX:IWM")
d_btc = f_get_stats("BINANCE:BTCUSDT")
d_eth = f_get_stats("BINANCE:ETHUSDT")
d_gold = f_get_stats("TVC:GOLD")
d_oil = f_get_stats("TVC:USOIL")
d_dxy = f_get_stats("TVC:DXY")
d_us10y = f_get_stats("TVC:US10Y")
d_vix = f_get_stats("CBOE:VIX")

// Active Ticker Intelligence
rsi = ta.rsi(close, 14)
[st_val, st_dir] = ta.supertrend(3, 10)
avg_vol = ta.sma(volume, 20)
rvol = volume / avg_vol
atr = ta.atr(14)

// Sparkline Generator (Text Based)
// We use simple block characters to simulate a "Trend"
// logic: if Price > Open -> Bullish Block, else Bearish Block.
// Ideally we'd have history but keeping it simple for now.
// Sparkline Generator (3-Bar Mini Chart)
// Sparkline char generator
f_spark_char(_p, _min, _rng) =>
_rel = (_p - _min) / (_rng == 0 ? 1 : _rng)
_rel < 0.33 ? " " : (_rel < 0.66 ? "▃" : "▇")

// Sparkline Generator (3-Bar Mini Chart)
f_spark(_d) =>
// Simple logic: Normalize 3 prices to choose low/med/high blocks
_min = math.min(_d.c1, math.min(_d.c2, _d.c3))
_max = math.max(_d.c1, math.max(_d.c2, _d.c3))
_rng = _max - _min

f_spark_char(_d.c2, _min, _rng) + f_spark_char(_d.c1, _min, _rng) + f_spark_char(_d.c3, _min, _rng)

// =============================================================================
// III. UI RENDERER (TEXT BASED TERMINAL)
// =============================================================================

// Table with thick outer frame but NO inner grid lines
var table term = table.new(pos_main, 4, 30, border_width=0, frame_width=2, frame_color=color.rgb(40,40,40), bgcolor=c_bg_main)

f_txt(_t, _c, _r, _txt, _col, _align, _bg) =>
table.cell(_t, _c, _r, _txt, text_color=_col, text_halign=_align, text_size=sz_text, bgcolor=_bg, text_font_family=font.family_monospace)

// Helper to print a row
// Helper to print a row with Zebra Striping
f_row(_row_idx, _name, _d) =>
_c_p = _d.is_up ? c_bull : c_bear
_bg_row = _row_idx % 2 == 0 ? c_bg_main : c_bg_alt // Zebra Logic

// Col 0: Ticker
f_txt(term, 0, _row_idx, _name, c_amber, text.align_left, _bg_row)
// Col 1: Price
f_txt(term, 1, _row_idx, str.tostring(_d.price, "#.##"), c_white, text.align_right, _bg_row)
// Col 2: Chg%
f_txt(term, 2, _row_idx, str.tostring(_d.chg, "+#.##") + "%", _c_p, text.align_right, _bg_row)
// Col 3: Spark (Simulated Trend)
f_txt(term, 3, _row_idx, f_spark(_d), _c_p, text.align_center, _bg_row)

if barstate.islast
// --- ROW 0: TOP MENU (F-Keys) - BLACK BG ---
_menu = " 1<GOVT> 2<CORP> 3<MTGE> 4<M-Mkt> 5<MUNI> 6<PFD> 7<EQTY> 8<CMDT> 9<INDX>"
table.cell(term, 0, 0, _menu, text_color=c_amber, bgcolor=c_bg_main, text_halign=text.align_left, text_size=size.tiny, text_font_family=font.family_monospace)
table.merge_cells(term, 0, 0, 3, 0)

// --- ROW 1: BRANDING HEADER - BLACK BG ---
_time = str.format("{0,date,HH:mm:ss} EST", time)
// Simulated "BLOOMBERG" logo text + Time
f_txt(term, 0, 1, "QUANTLABS PROFESSIONAL | " + _time, c_amber, text.align_left, c_bg_main)
table.merge_cells(term, 0, 1, 3, 1)

// --- ROW 2: PANEL HEADERS - BLUE BG ---
f_txt(term, 0, 2, "SECURITY", c_white, text.align_left, c_header)
f_txt(term, 1, 2, "LAST PRICE", c_white, text.align_right, c_header)
f_txt(term, 2, 2, "NET CHANGE", c_white, text.align_right, c_header)
f_txt(term, 3, 2, "TREND", c_white, text.align_center, c_header)

// --- DATA ROWS (WATCHLIST) ---
f_row(3, "SPX Index", d_spy)
f_row(4, "NDX Index", d_qqq)
f_row(5, "RTY Index", d_iwm)
f_row(6, "VIX Index", d_vix)

// Separator
f_txt(term, 0, 7, ">> FX / CRYPTO", c_amber, text.align_left, color.new(c_header, 50))
table.merge_cells(term, 0, 7, 3, 7)

f_row(8, "BTCUSD Curncy", d_btc)
f_row(9, "ETHUSD Curncy", d_eth)
f_row(10, "DXY Curncy", d_dxy)
f_row(11, "XAU Curncy", d_gold)

// --- INTELLIGENCE SECTION ---
f_txt(term, 0, 12, ">> ACTIVE TICKER ANALYTICS", c_amber, text.align_left, color.new(c_header, 50))
table.merge_cells(term, 0, 12, 3, 12)

// Active Stats Row 1
f_txt(term, 0, 13, "RSI(14): " + str.tostring(rsi, "#.0"), c_white, text.align_left, c_bg_main)
c_rsi = rsi > 70 ? c_bear : (rsi < 30 ? c_bull : c_white)
f_txt(term, 1, 13, rsi > 70 ? "OVERBOUGHT" : (rsi < 30 ? "OVERSOLD" : "NEUTRAL"), c_rsi, text.align_right, c_bg_main)

// Active Stats Row 2
f_txt(term, 0, 14, "REL VOL(20): " + str.tostring(rvol, "#.1") + "x", c_white, text.align_left, c_bg_main)
c_vol = rvol > 2.0 ? c_amber : c_neutral
f_txt(term, 1, 14, rvol > 2.0 ? "HIGH ADVISE" : "NORMAL", c_vol, text.align_right, c_bg_main)

// Active Stats Row 3 (Merged)
_tr_txt = close > st_val ? "BULLISH TREND" : "BEARISH TREND"
c_tr = close > st_val ? c_bull : c_bear
f_txt(term, 0, 15, _tr_txt, c_tr, text.align_center, c_bg_main)
table.merge_cells(term, 0, 15, 3, 15)

// --- COMMAND LINE ---
// Blinking cursor effect
_blink = int(timenow / 500) % 2 == 0 ? "_" : " "
_cmd = "COMMAND: MONITOR " + syminfo.ticker + " <GO>" + _blink
f_txt(term, 0, 17, _cmd, c_amber, text.align_left, color.new(#222222,0))
table.merge_cells(term, 0, 17, 3, 17)

// --- NEWS TICKER (Multi-Line) ---
// We'll simulate a log by checking conditions
_msg1 = "SYSTEM READY..."
_msg2 = "MONITORING MARKETS..."
_msg3 = "NO ACTIVE ALERTS"

// Priority Alert Overwrite
if rvol > 3.0
_msg3 := ">> WHALE ALERT: VOL SPIKE <<"
else if rsi > 75
_msg3 := ">> EXTREME OB DETECTED <<"
else if rsi < 25
_msg3 := ">> EXTREME OS DETECTED <<"

// Render 3 lines of logs
f_txt(term, 0, 18, "LOG [1]: " + _msg3, _msg3 == "NO ACTIVE ALERTS" ? c_neutral : c_amber, text.align_left, c_bg_main)
table.merge_cells(term, 0, 18, 3, 18)

f_txt(term, 0, 19, "LOG [2]: " + _msg2, c_neutral, text.align_left, c_bg_main)
table.merge_cells(term, 0, 19, 3, 19)

f_txt(term, 0, 20, "LOG [3]: " + _msg1, c_neutral, text.align_left, c_bg_main)
table.merge_cells(term, 0, 20, 3, 20)

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.