PINE LIBRARY
Sessions backend framework

Sessions_Library — Session Timing Utilities (Pine v6)
Purpose
A lightweight helper library for indicator development that converts session strings (HHMM-HHMM) into same-day start/stop timestamps and provides a best-effort UTC offset resolver based on syminfo.timezone. This library does not draw, alert, or trade and must be called by a parent script.
Core Functions
- extractHourMinute(sessionInput): Returns [hour, minute] from a "HHMM" string.
- ExtractStartStopTimestamp(sessionInput): Accepts "HHMM-HHMM" and returns [sessionStartTime, sessionEndTime] using the current date.
- GetUTCOffset(): Maps common TradingView time zones to an integer UTC offset with fallbacks for UTC± and Etc/GMT± patterns.
Key Notes
- Backend-only tools: no signals, alerts, or order execution are included.
- Designed for educational, research, and indicator-development purposes.
- Time zone offsets are best-effort and simplified to whole hours; behavior may vary with regional DST rules and half-hour regions.
- No external data requests and no user data handling.
Usage
1) Import the library into your indicator.
2) Pass session strings like "0930-1030" to ExtractStartStopTimestamp for intraday windows.
3) Use GetUTCOffset to align logic across chart and exchange time. Visualization and alerting remain in the parent script.
Disclaimer
This library provides no financial advice, recommendations, or performance guarantees. Use at your own risk for research and educational development only.
Purpose
A lightweight helper library for indicator development that converts session strings (HHMM-HHMM) into same-day start/stop timestamps and provides a best-effort UTC offset resolver based on syminfo.timezone. This library does not draw, alert, or trade and must be called by a parent script.
Core Functions
- extractHourMinute(sessionInput): Returns [hour, minute] from a "HHMM" string.
- ExtractStartStopTimestamp(sessionInput): Accepts "HHMM-HHMM" and returns [sessionStartTime, sessionEndTime] using the current date.
- GetUTCOffset(): Maps common TradingView time zones to an integer UTC offset with fallbacks for UTC± and Etc/GMT± patterns.
Key Notes
- Backend-only tools: no signals, alerts, or order execution are included.
- Designed for educational, research, and indicator-development purposes.
- Time zone offsets are best-effort and simplified to whole hours; behavior may vary with regional DST rules and half-hour regions.
- No external data requests and no user data handling.
Usage
1) Import the library into your indicator.
2) Pass session strings like "0930-1030" to ExtractStartStopTimestamp for intraday windows.
3) Use GetUTCOffset to align logic across chart and exchange time. Visualization and alerting remain in the parent script.
Disclaimer
This library provides no financial advice, recommendations, or performance guarantees. Use at your own risk for research and educational development only.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.