PINE LIBRARY
Güncellendi 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")
Sürüm Notları
v2Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazarı tebrik ederiz! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun yayınlarda yeniden kullanılması Topluluk Kuralları tarafından yönetilir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazarı tebrik ederiz! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun yayınlarda yeniden kullanılması Topluluk Kuralları tarafından yönetilir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.