本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("24H Hourly Open & Confirmation Levels", overlay=true, max_lines_count=500, max_boxes_count=500)
// ==========================================
// 1. INPUTS
// ==========================================
grp_time = "Time & Timezone"
tz_input = input.string("Europe/Belgrade", "Timezone", options=["Europe/Belgrade", "Europe/Skopje", "America/New_York", "Europe/London", "UTC"], group=grp_time)
grp_logic = "Hourly Cycle Logic (24H)"
confirm_min = input.int(10, "Secondary Confirmation Minute (e.g., 10 for HH:10)", minval=1, maxval=59, group=grp_logic)
open_extend = input.int(20, "Hourly Open Line Length (Bars)", minval=5, maxval=240, group=grp_logic)
hl_extend = input.int(20, "Confirmation High/Low & Box Length (Bars)", minval=1, maxval=120, group=grp_logic)
grp_visual = "Visuals & Line Styles"
show_v_prio = input.bool(true, "Show Primary Vertical Line (HH:00)", group=grp_visual)
v_col_prio = input.color(color.new(#d4af37, 20), "Primary Vertical Line Color (HH:00)", group=grp_visual)
v_width_prio = input.int(1, "Primary Vertical Line Width", minval=1, maxval=5, group=grp_visual)
v_style_prio_in = input.string("Dashed", "Primary Vertical Line Style (HH:00)", options=["Solid", "Dashed", "Dotted"], group=grp_visual)
show_open_h = input.bool(true, "Show Hourly Open Horizontal Line (HH:00)", group=grp_visual)
h_col_open = input.color(color.new(#d4af37, 10), "Hourly Open Line Color", group=grp_visual)
h_width_open = input.int(2, "Hourly Open Line Width", minval=1, maxval=5, group=grp_visual)
show_v_sec = input.bool(true, "Show Secondary Vertical Line (Confirmation)", group=grp_visual)
v_col_sec = input.color(color.new(#f7f8f8, 60), "Secondary Vertical Line Color", group=grp_visual)
v_width_sec = input.int(1, "Secondary Vertical Line Width", minval=1, maxval=5, group=grp_visual)
v_style_sec_in = input.string("Dotted", "Secondary Vertical Line Style (Confirmation)", options=["Solid", "Dashed", "Dotted"], group=grp_visual)
show_sec_hl = input.bool(true, "Show Confirmation Candle High/Low Lines (HH:MM)", group=grp_visual)
h_col_sec = input.color(color.new(#f8fafa, 22), "Confirmation High/Low Line Color", group=grp_visual)
h_width_sec = input.int(1, "Confirmation High/Low Line Width", minval=1, maxval=5, group=grp_visual)
show_sec_box = input.bool(true, "Show Confirmation Candle Box (HH:MM)", group=grp_visual)
box_bg_sec = input.color(color.new(#fbfcfc, 77), "Confirmation Box Background Color", group=grp_visual)
box_border_sec = input.color(color.new(#f5f8f8, 100), "Confirmation Box Border Color", group=grp_visual)
// Helper function to convert line style input
get_line_style(s) =>
switch s
"Solid" => line.style_solid
"Dashed" => line.style_dashed
"Dotted" => line.style_dotted
=> line.style_solid
v_style_prio = get_line_style(v_style_prio_in)
v_style_sec = get_line_style(v_style_sec_in)
// ==========================================
// 2. CHART PLOTTING
// ==========================================
cur_h = hour(time, tz_input)
cur_m = minute(time, tz_input)
cur_bar_mins = cur_h * 60 + cur_m
is_new_minute = ta.change(cur_bar_mins) != 0
if is_new_minute
// A) Primary Time: Top of the Hour (HH:00) -> Hourly Open Level
if cur_m == 0
if show_v_prio
line.new(bar_index, low, bar_index, high, xloc=xloc.bar_index, extend=extend.both, color=v_col_prio, style=v_style_prio, width=v_width_prio)
if show_open_h
line.new(bar_index, open, bar_index + open_extend, open, xloc=xloc.bar_index, color=h_col_open, style=line.style_solid, width=h_width_open)
// B) Secondary Time: Confirmation Minute (HH:confirm_min) -> Confirmation Candle Range & Box
if cur_m == confirm_min
if show_v_sec
line.new(bar_index, low, bar_index, high, xloc=xloc.bar_index, extend=extend.both, color=v_col_sec, style=v_style_sec, width=v_width_sec)
if show_sec_hl
line.new(bar_index, high, bar_index + hl_extend, high, xloc=xloc.bar_index, color=h_col_sec, style=line.style_solid, width=h_width_sec)
line.new(bar_index, low, bar_index + hl_extend, low, xloc=xloc.bar_index, color=h_col_sec, style=line.style_solid, width=h_width_sec)
if show_sec_box
box.new(bar_index, high, bar_index + hl_extend, low, xloc=xloc.bar_index, border_color=box_border_sec, border_width=1, bgcolor=box_bg_sec)