Untitled
unknown
plain_text
a month ago
34 kB
6
Indexable
//@version=5
indicator("Note-Taking HUD", overlay=true, max_labels_count=500, max_lines_count=500)
// ──────────────────────────────────────────────────────────────
// GENERAL SETTINGS (Tab)
// ──────────────────────────────────────────────────────────────
anchor_map(pos) =>
switch pos
"Top Right" => position.top_right
"Top Left" => position.top_left
"Bottom Right" => position.bottom_right
"Bottom Left" => position.bottom_left
=> position.top_right
anchor_input = input.string("Top Right", "Screen Anchor", options=["Top Right", "Top Left", "Bottom Right", "Bottom Left"], group="General")
text_size_input = input.string("Tiny", "Global Text Size", options=["Tiny", "Small", "Normal"], group="General")
text_color_input = input.color(color.white, "Text Color", group="General")
bull_glow = input.color(#00ff00, "Bullish Glow Color", group="General")
bear_glow = input.color(#ff3333, "Bearish Glow Color", group="General")
table_width = input.int(240, "Table Width (px)", minval=100, group="General")
offset_x = input.int(10, "Horizontal Offset", group="General")
offset_y = input.int(10, "Vertical Offset", group="General")
size_map(size_str) =>
switch size_str
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
=> size.tiny
global_size = size_map(text_size_input)
anchor = anchor_map(anchor_input)
row_height = global_size == size.tiny ? 16 : global_size == size.small ? 20 : 24
// ──────────────────────────────────────────────────────────────
// TIMEFRAME SETTINGS (Tab)
// ──────────────────────────────────────────────────────────────
// Monthly
enable_m = input.bool(true, "Enable Monthly", group="Monthly Settings")
m_bull_note = input.string("", "Bullish Note", group="Monthly Settings", inline="m_bull")
m_bull_act = input.bool(false, "Active", group="Monthly Settings", inline="m_bull")
m_bear_note = input.string("", "Bearish Note", group="Monthly Settings", inline="m_bear")
m_bear_act = input.bool(false, "Active", group="Monthly Settings", inline="m_bear")
// Weekly
enable_w = input.bool(true, "Enable Weekly", group="Weekly Settings")
w_bull_note = input.string("", "Bullish Note", group="Weekly Settings", inline="w_bull")
w_bull_act = input.bool(false, "Active", group="Weekly Settings", inline="w_bull")
w_bear_note = input.string("", "Bearish Note", group="Weekly Settings", inline="w_bear")
w_bear_act = input.bool(false, "Active", group="Weekly Settings", inline="w_bear")
// Daily
enable_d = input.bool(true, "Enable Daily", group="Daily Settings")
d_bull_note = input.string("", "Bullish Note", group="Daily Settings", inline="d_bull")
d_bull_act = input.bool(false, "Active", group="Daily Settings", inline="d_bull")
d_bear_note = input.string("", "Bearish Note", group="Daily Settings", inline="d_bear")
d_bear_act = input.bool(false, "Active", group="Daily Settings", inline="d_bear")
// 4H
enable_4h = input.bool(true, "Enable 4H", group="4H Settings")
h4_bull_note = input.string("", "Bullish Note", group="4H Settings", inline="h4_bull")
h4_bull_act = input.bool(false, "Active", group="4H Settings", inline="h4_bull")
h4_bear_note = input.string("", "Bearish Note", group="4H Settings", inline="h4_bear")
h4_bear_act = input.bool(false, "Active", group="4H Settings", inline="h4_bear")
// 1H
enable_1h = input.bool(true, "Enable 1H", group="1H Settings")
h1_bull_note = input.string("", "Bullish Note", group="1H Settings", inline="h1_bull")
h1_bull_act = input.bool(false, "Active", group="1H Settings", inline="h1_bull")
h1_bear_note = input.string("", "Bearish Note", group="1H Settings", inline="h1_bear")
h1_bear_act = input.bool(false, "Active", group="1H Settings", inline="h1_bear")
// 15m
enable_15m = input.bool(true, "Enable 15m", group="15m Settings")
m15_bull_note = input.string("", "Bullish Note", group="15m Settings", inline="m15_bull")
m15_bull_act = input.bool(false, "Active", group="15m Settings", inline="m15_bull")
m15_bear_note = input.string("", "Bearish Note", group="15m Settings", inline="m15_bear")
m15_bear_act = input.bool(false, "Active", group="15m Settings", inline="m15_bear")
// ──────────────────────────────────────────────────────────────
// PROBABILITY CALCULATIONS
// ──────────────────────────────────────────────────────────────
f_prob(bull_act, bull_note, bear_act, bear_note) =>
bull_eff = bull_act and bull_note != ""
bear_eff = bear_act and bear_note != ""
total = (bull_eff ? 1 : 0) + (bear_eff ? 1 : 0)
if total == 0
50.0
else
(bull_eff ? 1 : 0) / total * 100.0
f_color(prob, bull_c, bear_c) =>
dist = math.abs(prob - 50.0)
transp = math.round(85.0 - 1.4 * dist)
transp := math.max(0, math.min(100, transp))
if prob >= 50.0
color.new(bull_c, transp)
else
color.new(bear_c, transp)
f_display(active, note, prefix) =>
(active and note != "") ? prefix + note : prefix + "—"
// Monthly
prob_m = f_prob(m_bull_act, m_bull_note, m_bear_act, m_bear_note)
color_m = f_color(prob_m, bull_glow, bear_glow)
disp_m_bull = f_display(m_bull_act, m_bull_note, "Bull: ")
disp_m_bear = f_display(m_bear_act, m_bear_note, "Bear: ")
// Weekly
prob_w = f_prob(w_bull_act, w_bull_note, w_bear_act, w_bear_note)
color_w = f_color(prob_w, bull_glow, bear_glow)
disp_w_bull = f_display(w_bull_act, w_bull_note, "Bull: ")
disp_w_bear = f_display(w_bear_act, w_bear_note, "Bear: ")
// Daily
prob_d = f_prob(d_bull_act, d_bull_note, d_bear_act, d_bear_note)
color_d = f_color(prob_d, bull_glow, bear_glow)
disp_d_bull = f_display(d_bull_act, d_bull_note, "Bull: ")
disp_d_bear = f_display(d_bear_act, d_bear_note, "Bear: ")
// 4H
prob_4h = f_prob(h4_bull_act, h4_bull_note, h4_bear_act, h4_bear_note)
color_4h = f_color(prob_4h, bull_glow, bear_glow)
disp_4h_bull = f_display(h4_bull_act, h4_bull_note, "Bull: ")
disp_4h_bear = f_display(h4_bear_act, h4_bear_note, "Bear: ")
// 1H
prob_1h = f_prob(h1_bull_act, h1_bull_note, h1_bear_act, h1_bear_note)
color_1h = f_color(prob_1h, bull_glow, bear_glow)
disp_1h_bull = f_display(h1_bull_act, h1_bull_note, "Bull: ")
disp_1h_bear = f_display(h1_bear_act, h1_bear_note, "Bear: ")
// 15m
prob_15m = f_prob(m15_bull_act, m15_bull_note, m15_bear_act, m15_bear_note)
color_15m = f_color(prob_15m, bull_glow, bear_glow)
disp_15m_bull = f_display(m15_bull_act, m15_bull_note, "Bull: ")
disp_15m_bear = f_display(m15_bear_act, m15_bear_note, "Bear: ")
// ──────────────────────────────────────────────────────────────
// TABLE RENDERING (barstate.islast)
// ──────────────────────────────────────────────────────────────
var table[] tables = array.new_table()
if barstate.islast
// Clear old tables
for i = 0 to array.size(tables) - 1
table.delete(array.get(tables, i))
array.clear(tables)
y_cursor = 0
// Helper to draw a timeframe block
add_block(enable, tf_label, prob, col, disp_bull, disp_bear) =>
if enable
t = table.new(position=anchor, columns=1, rows=3,
bgcolor=na, border_width=0, frame_width=0,
frame_color=na, border_color=na)
// Row 0: label + probability
header_text = tf_label + " " + str.tostring(math.round(prob)) + "%"
table.cell(t, 0, 0, header_text,
width=table_width, height=row_height,
text_size=global_size, text_color=text_color_input, bgcolor=col)
// Row 1: Bullish note
table.cell(t, 0, 1, disp_bull,
width=table_width, height=row_height,
text_size=global_size, text_color=text_color_input, bgcolor=col)
// Row 2: Bearish note
table.cell(t, 0, 2, disp_bear,
width=table_width, height=row_height,
text_size=global_size, text_color=text_color_input, bgcolor=col)
table.set_position(t, anchor, x=offset_x, y=offset_y + y_cursor)
array.push(tables, t)
y_cursor + 3 * row_height
else
y_cursor
y_cursor := add_block(enable_m, "Monthly", prob_m, color_m, disp_m_bull, disp_m_bear)
y_cursor := add_block(enable_w, "Weekly", prob_w, color_w, disp_w_bull, disp_w_bear)
y_cursor := add_block(enable_d, "Daily", prob_d, color_d, disp_d_bull, disp_d_bear)
y_cursor := add_block(enable_4h, "4H", prob_4h, color_4h, disp_4h_bull, disp_4h_bear)
y_cursor := add_block(enable_1h, "1H", prob_1h, color_1h, disp_1h_bull, disp_1h_bear)
y_cursor := add_block(enable_15m,"15m", prob_15m,color_15m,disp_15m_bull,disp_15m_bear)Editor is loading...
Leave a Comment