PINE LIBRARY
업데이트됨 SessionLib

Library "SessionLib"
SessionLib — timezone, session detection, and timeframe utilities.
Extracted from TaUtilityLib during Step 13 decomposition.
Layer L0 (leaf utility, depends only on Pine builtins).
CHANGELOG v1:
- SessionState UDT for US/Asia/EU session detection
- Timeframe navigation: f_get_next_tf, f_get_prev_tf, f_get_lower_tf
- Session parsing: f_sess_part, f_hhmm_to_h, f_hhmm_to_m, f_session_tz
- Symbol activity: f_symbol_activity_1m, f_is_trading_now, f_is_active_symbol
- Status icons: f_status_icon, f_status_icon_from_1m, f_symbol_status_icon
- Utilities: f_tf_ms, f_symbol_base
f_session_state()
Detect RTH session (US/Asia/EU)
Returns: SessionState with session flags and label
f_tf_ms(tf)
Convert timeframe to milliseconds
Parameters:
tf (string): Timeframe string (e.g., "15", "240", "D")
Returns: Milliseconds as int
f_get_next_tf(tf, steps)
Gets next higher timeframe(s) from current
Parameters:
tf (string): Current timeframe string
steps (string): "1 TF Higher" for next TF, any other value for 2 TFs higher
Returns: Next timeframe string or na if at maximum
f_get_prev_tf(tf)
Gets previous lower timeframe from current
Parameters:
tf (string): Current timeframe string
Returns: Previous timeframe string or na if at minimum
f_get_lower_tf(tf)
Gets standard lower timeframe mapping
Parameters:
tf (string): Current timeframe string
Returns: Lower timeframe string or empty if at minimum
f_sess_part(sess, want_start)
Extract start or end part from session string
Parameters:
sess (string): Session string (e.g., "0900-1600")
want_start (bool): true for start, false for end
Returns: Time part string (HHMM format)
f_hhmm_to_h(hhmm)
Extract hour from HHMM string
Parameters:
hhmm (string): Time string in HHMM format
Returns: Hour as int (0-23)
f_hhmm_to_m(hhmm)
Extract minute from HHMM string
Parameters:
hhmm (string): Time string in HHMM format
Returns: Minute as int (0-59)
f_session_tz(session_tz_sel)
Convert session timezone selector to IANA timezone string
Parameters:
session_tz_sel (string): Session timezone selector
Returns: IANA timezone string
f_symbol_activity_1m(s_timeClose_1m, s_inAnySess_1m, fresh_secs)
Check symbol activity from 1m security data
Parameters:
s_timeClose_1m (float): 1m bar close time from request.security
s_inAnySess_1m (bool): 1m session status from request.security
fresh_secs (float): Freshness threshold in seconds
Returns: [tradingNow, exchangeClosed, sessionOpenButStale]
f_is_trading_now(sym, fresh_secs)
Check if symbol is actively trading
Parameters:
sym (string): Symbol string
fresh_secs (float): Freshness threshold in seconds
Returns: [tradingNow, exchangeClosed, sessionOpenButStale]
f_is_active_symbol(sym, fresh_secs)
Check if symbol is active (trading now)
Parameters:
sym (string): Symbol string
fresh_secs (float): Freshness threshold in seconds
Returns: true if trading
f_is_active_symbol(tradingNow)
Check if symbol is active (boolean overload)
Parameters:
tradingNow (bool): Trading status boolean
Returns: Same boolean (passthrough for API consistency)
f_status_icon(sym, fresh_secs)
Get status icon from symbol
Parameters:
sym (string): Symbol string
fresh_secs (float): Freshness threshold in seconds
Returns: Status emoji string
f_symbol_status_icon(tradingNow, exchangeClosed, sessionOpenButStale)
Get status icon from boolean flags
Parameters:
tradingNow (bool): Is trading
exchangeClosed (bool): Is exchange closed
sessionOpenButStale (bool): Session open but stale
Returns: Status emoji string
f_status_icon_from_1m(s_timeClose_1m, s_inAnySess_1m, fresh_secs)
Get status icon from 1m data
Parameters:
s_timeClose_1m (float): 1m bar close time
s_inAnySess_1m (bool): 1m session status
fresh_secs (float): Freshness threshold in seconds
Returns: Status emoji string
f_symbol_base(ticker_id)
Extract symbol base from ticker (removes USDT suffix)
Parameters:
ticker_id (string): Ticker ID string (e.g., "BINANCE:BTCUSDT")
Returns: Base symbol string (e.g., "BTC")
SessionState
SessionState — session detection container
Fields:
inUS (series bool): US session active (14:30-22:00 UTC)
inAsia (series bool): Asia session active (00:00-07:00 UTC)
inEU (series bool): EU session active (07:00-14:30 UTC)
label (series string): Session label string ("US", "Asia", "EU", "Off")
SessionLib — timezone, session detection, and timeframe utilities.
Extracted from TaUtilityLib during Step 13 decomposition.
Layer L0 (leaf utility, depends only on Pine builtins).
CHANGELOG v1:
- SessionState UDT for US/Asia/EU session detection
- Timeframe navigation: f_get_next_tf, f_get_prev_tf, f_get_lower_tf
- Session parsing: f_sess_part, f_hhmm_to_h, f_hhmm_to_m, f_session_tz
- Symbol activity: f_symbol_activity_1m, f_is_trading_now, f_is_active_symbol
- Status icons: f_status_icon, f_status_icon_from_1m, f_symbol_status_icon
- Utilities: f_tf_ms, f_symbol_base
f_session_state()
Detect RTH session (US/Asia/EU)
Returns: SessionState with session flags and label
f_tf_ms(tf)
Convert timeframe to milliseconds
Parameters:
tf (string): Timeframe string (e.g., "15", "240", "D")
Returns: Milliseconds as int
f_get_next_tf(tf, steps)
Gets next higher timeframe(s) from current
Parameters:
tf (string): Current timeframe string
steps (string): "1 TF Higher" for next TF, any other value for 2 TFs higher
Returns: Next timeframe string or na if at maximum
f_get_prev_tf(tf)
Gets previous lower timeframe from current
Parameters:
tf (string): Current timeframe string
Returns: Previous timeframe string or na if at minimum
f_get_lower_tf(tf)
Gets standard lower timeframe mapping
Parameters:
tf (string): Current timeframe string
Returns: Lower timeframe string or empty if at minimum
f_sess_part(sess, want_start)
Extract start or end part from session string
Parameters:
sess (string): Session string (e.g., "0900-1600")
want_start (bool): true for start, false for end
Returns: Time part string (HHMM format)
f_hhmm_to_h(hhmm)
Extract hour from HHMM string
Parameters:
hhmm (string): Time string in HHMM format
Returns: Hour as int (0-23)
f_hhmm_to_m(hhmm)
Extract minute from HHMM string
Parameters:
hhmm (string): Time string in HHMM format
Returns: Minute as int (0-59)
f_session_tz(session_tz_sel)
Convert session timezone selector to IANA timezone string
Parameters:
session_tz_sel (string): Session timezone selector
Returns: IANA timezone string
f_symbol_activity_1m(s_timeClose_1m, s_inAnySess_1m, fresh_secs)
Check symbol activity from 1m security data
Parameters:
s_timeClose_1m (float): 1m bar close time from request.security
s_inAnySess_1m (bool): 1m session status from request.security
fresh_secs (float): Freshness threshold in seconds
Returns: [tradingNow, exchangeClosed, sessionOpenButStale]
f_is_trading_now(sym, fresh_secs)
Check if symbol is actively trading
Parameters:
sym (string): Symbol string
fresh_secs (float): Freshness threshold in seconds
Returns: [tradingNow, exchangeClosed, sessionOpenButStale]
f_is_active_symbol(sym, fresh_secs)
Check if symbol is active (trading now)
Parameters:
sym (string): Symbol string
fresh_secs (float): Freshness threshold in seconds
Returns: true if trading
f_is_active_symbol(tradingNow)
Check if symbol is active (boolean overload)
Parameters:
tradingNow (bool): Trading status boolean
Returns: Same boolean (passthrough for API consistency)
f_status_icon(sym, fresh_secs)
Get status icon from symbol
Parameters:
sym (string): Symbol string
fresh_secs (float): Freshness threshold in seconds
Returns: Status emoji string
f_symbol_status_icon(tradingNow, exchangeClosed, sessionOpenButStale)
Get status icon from boolean flags
Parameters:
tradingNow (bool): Is trading
exchangeClosed (bool): Is exchange closed
sessionOpenButStale (bool): Session open but stale
Returns: Status emoji string
f_status_icon_from_1m(s_timeClose_1m, s_inAnySess_1m, fresh_secs)
Get status icon from 1m data
Parameters:
s_timeClose_1m (float): 1m bar close time
s_inAnySess_1m (bool): 1m session status
fresh_secs (float): Freshness threshold in seconds
Returns: Status emoji string
f_symbol_base(ticker_id)
Extract symbol base from ticker (removes USDT suffix)
Parameters:
ticker_id (string): Ticker ID string (e.g., "BINANCE:BTCUSDT")
Returns: Base symbol string (e.g., "BTC")
SessionState
SessionState — session detection container
Fields:
inUS (series bool): US session active (14:30-22:00 UTC)
inAsia (series bool): Asia session active (00:00-07:00 UTC)
inEU (series bool): EU session active (07:00-14:30 UTC)
label (series string): Session label string ("US", "Asia", "EU", "Off")
릴리즈 노트
v2파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.