PINE LIBRARY

EKTrueOpens

210
Library "EKTrueOpens"
True Opens library: calculation, drawing, history management, and price tracking table
for opening prices at multiple timeframes (yearly, quarterly, monthly, weekly, daily, session, 90-minute).
Extracted from qt-ultimate-enigma.pine lines 1951-2597.

to_tf_to_min(tf)
  Converts a timeframe string to minutes
  Parameters:
    tf (string): Timeframe string (e.g. "1", "60", "D", "W")
  Returns: Float value in minutes

to_is_visible(min_s, max_s)
  Checks if current chart timeframe is within the given min/max range
  Parameters:
    min_s (string): Minimum timeframe string
    max_s (string): Maximum timeframe string
  Returns: True if current timeframe is within range

to_get_style_const(s)
  Converts a style name string to a line style constant
  Parameters:
    s (string): Style name: "Solid", "Dashed", or "Dotted"
  Returns: line.style_* constant

to_get_active_style(cfg)
  Returns the line style for active (current) True Open lines
  Parameters:
    cfg (TOConfig): TOConfig with style_mode and custom_style settings
  Returns: line.style_* constant

to_get_sess_end(start_time)
  Calculates the hard session end time for a given start time
  Parameters:
    start_time (int): Bar time of the session start
  Returns: Timestamp of the session end (6-hour boundaries in NY time)

to_enforce_limit(arr, allow_hist, hist_count)
  Enforces the history limit on a TO_Level array, deleting excess old lines/labels
  Parameters:
    arr (array<TO_Level>): The array of TO_Level objects
    allow_hist (bool): Whether history is enabled for this timeframe
    hist_count (int): Maximum number of historical levels to keep

to_force_close_period(arr, allow_hist, cfg)
  Force-closes the current active period in an array (used at timeframe boundaries)
  Parameters:
    arr (array<TO_Level>): The array of TO_Level objects
    allow_hist (bool): Whether history is enabled for this timeframe
    cfg (TOConfig): TOConfig with style settings

to_manage_history(arr, p, start_time, txt, col, allow_hist, use_hard_end, custom_end, cfg)
  Closes the previous active level and creates a new one for the new period
  Parameters:
    arr (array<TO_Level>): The array of TO_Level objects
    p (float): The opening price for the new period
    start_time (int): Bar time of the new period start
    txt (string): Label text for the new level
    col (color): Color for the new level
    allow_hist (bool): Whether history is enabled for this timeframe
    use_hard_end (bool): Whether to calculate a hard session end time
    custom_end (int): Custom end time (0 = none, overrides hard end calc)
    cfg (TOConfig): TOConfig with style, font, and text size settings

to_maintain_lines(arr, is_vis, is_time_label_mode, allow_hist, cfg)
  Updates line extensions, visibility, colors, and label text for all levels in an array
  Parameters:
    arr (array<TO_Level>): The array of TO_Level objects
    is_vis (bool): Whether this timeframe is visible at current chart resolution
    is_time_label_mode (bool): Whether labels should show time instead of name (for sessions/90m)
    allow_hist (bool): Whether history is enabled for this timeframe
    cfg (TOConfig): TOConfig with offset, session label mode, and font settings

to_calc_yr_func()
  Calculates the True Yearly Open (April open per ICT/Daye methodology)
  Returns: Tuple [price, new_period_flag, trigger_time]

to_calc_qt_func()
  Calculates the True Quarterly Open (4th Sunday of quarter-start month)
  Returns: Tuple [price, new_period_flag, trigger_time]

to_calc_mn_func(t_hour)
  Calculates the True Monthly Open (2nd week Sunday at trigger hour)
  Parameters:
    t_hour (int): The trigger hour in NY time (typically 18)
  Returns: Tuple [price, new_period_flag, trigger_time]

to_calc_wk_func(t_hour)
  Calculates the True Weekly Open (Monday at trigger hour)
  Parameters:
    t_hour (int): The trigger hour in NY time (typically 18)
  Returns: Tuple [price, new_period_flag, trigger_time]

to_calc_dy_func()
  Calculates the True Daily Open (midnight NY time)
  Returns: Tuple [price, new_period_flag, trigger_time]

to_calc_session_func(t_h, t_m)
  Calculates a True Session Open at the given hour:minute in NY time
  Parameters:
    t_h (int): Session start hour (NY time)
    t_m (int): Session start minute (NY time)
  Returns: Tuple [price, new_period_flag, trigger_time]

to_calc_90m_func()
  Calculates the True 90-Minute Open (:23/:53 cycle boundaries)
  Returns: Tuple [price, new_period_flag, trigger_time, strict_end_time]

to_is_current_period(trigger_time, type)
  Checks if a trigger time falls within the current period of the given type
  Parameters:
    trigger_time (int): The bar time when the True Open was triggered
    type (string): Period type: "D", "W", "M", "Q", "Y", "SESS", or "90M"
  Returns: True if the trigger time is within the current period

to_get_status(lvl_price, trig_t, period_type, c_tbl_none, c_tbl_above, c_tbl_below)
  Gets the status text and color for a single True Open level vs current close
  Parameters:
    lvl_price (float): The True Open price
    trig_t (int): The trigger time for the True Open
    period_type (string): Period type string for is_current_period check
    c_tbl_none (color): Color for "Not Open" state
    c_tbl_above (color): Color for "Above" state
    c_tbl_below (color): Color for "Below" state
  Returns: Tuple [status_text, status_color]

to_get_array_status(arr, label_name, c_tbl_none, c_tbl_above, c_tbl_below)
  Gets the status for an array-based True Open (sessions, 90m) including label text
  Parameters:
    arr (array<TO_Level>): The array of TO_Level objects
    label_name (string): Display name for the table row (e.g. "Session", "90-Min")
    c_tbl_none (color): Color for "Not Open" state
    c_tbl_above (color): Color for "Above" state
    c_tbl_below (color): Color for "Below" state
  Returns: Tuple [label_text, status_text, status_color]

to_render_table(tbl_cfg, to_tbl, to_arr_sess, to_arr_90m, to_yr_p, to_yr_t, to_qt_p, to_qt_t, to_mn_p, to_mn_t, to_wk_p, to_wk_t, to_dy_p, to_dy_t)
  Renders the True Opens price tracking table with all timeframe rows
  Parameters:
    tbl_cfg (TOTableConfig): TOTableConfig with all table display settings
    to_tbl (table): The pre-created table object
    to_arr_sess (array<TO_Level>): Session TO_Level array
    to_arr_90m (array<TO_Level>): 90-minute TO_Level array
    to_yr_p (float): Yearly True Open price (from request.security)
    to_yr_t (int): Yearly trigger time
    to_qt_p (float): Quarterly True Open price
    to_qt_t (int): Quarterly trigger time
    to_mn_p (float): Monthly True Open price
    to_mn_t (int): Monthly trigger time
    to_wk_p (float): Weekly True Open price
    to_wk_t (int): Weekly trigger time
    to_dy_p (float): Daily True Open price
    to_dy_t (int): Daily trigger time

TO_Level
  Core level structure for a single True Open line/label pair
  Fields:
    l (series line): The line object drawn on chart
    lbl (series label): The label object drawn on chart
    price (series float): The opening price value
    active (series bool): Whether this level is the current (still-extending) period
    name (series string): Display name for the label (e.g. "TYO", "AO", "90m")
    c (series color): The color assigned to this level
    start_t (series int): Bar time when this level started
    end_t (series int): Hard end time (0 = no hard end, extends until next period)

TOConfig
  Configuration for True Opens general settings (replaces input.*() calls)
  Fields:
    to_style_mode (series string): "Auto" or "Custom" line style mode
    to_custom_style (series string): "Solid", "Dashed", or "Dotted" when mode is Custom
    to_hist_count_global (series int): How many past lines to keep for selected timeframes
    to_offset_val (series int): Label offset in bars
    to_textSize (series string): Text size for chart labels
    to_font_fam (series string): Font family string (font.family_monospace or font.family_default)
    to_sess_lbl_mode (series string): "Name" or "Time" for session label display

TOTableConfig
  Configuration for the True Opens price tracking table (replaces input.*() calls)
  Fields:
    to_show_table (series bool): Whether to show the table at all
    to_table_pos (series string): Table position string (e.g. position.bottom_right)
    to_table_txt_size (series string): Table text size
    to_tbl_show_90m (series bool): Show 90-Min row
    to_tbl_show_sess (series bool): Show Session row
    to_tbl_show_dy (series bool): Show Daily row
    to_tbl_show_wk (series bool): Show Weekly row
    to_tbl_show_mn (series bool): Show Monthly row
    to_tbl_show_qt (series bool): Show Quarterly row
    to_tbl_show_yr (series bool): Show Yearly row
    to_c_tbl_above (series color): Color when price is above True Open
    to_c_tbl_below (series color): Color when price is below True Open
    to_c_tbl_none (series color): Color when period is not open
    to_font_fam (series string): Font family string for table cells

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.