Sessions backend frameworkSessions_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 from a "HHMM" string.
- ExtractStartStopTimestamp(sessionInput): Accepts "HHMM-HHMM" and returns 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.
UTC
Timing and Sessions backend frameworkTiming_Library — Timing Utilities (Pine v6)
Purpose
A lightweight timing toolkit for indicator development. It parses session strings, returns start/stop timestamps for the current day, and resolves a UTC offset for common TradingView time zones. The library itself does not draw, alert, or place trades and must be called by a parent indicator.
Core Functions
- extractHourMinute(sessionInput): Parses "HHMM" into .
- ExtractStartStopTimestamp(sessionInput): Accepts "HHMM-HHMM" and returns for the current date.
- GetUTCOffset(): Maps syminfo.timezone to an integer UTC offset (hours), with fallback parsing for UTC± patterns.
Key Notes
- Backend-only helper library: no signals, no alerts, no order execution.
- Designed for educational, research, and indicator-development purposes.
- No external data requests and no user data handling.
- Time zone handling is best-effort; behavior may vary with regional DST rules.
Usage
1) Import this library into your indicator.
2) Provide session inputs like "0930-1030" to ExtractStartStopTimestamp for same-day timestamps.
3) Use GetUTCOffset to align session logic or convert between local and exchange time where needed. Visualization and alerting remain in the parent script.
Disclaimer
This library does not provide financial advice, trade recommendations, or performance guarantees. Use at your own risk for research and educational development only.
ISODateTimeLibrary "ISODateTime"
getDateParts(dateStr)
Get year, month, day from date string.
Parameters:
dateStr : : ISO 8601 format, i.e. "2022-05-04T14:00:00.001000-04:00" or "2022-05-04T14:00:00Z"
Returns: array of int
getTimeParts(dateStr)
Get hour, minute, seconds from date string.
Parameters:
dateStr : : ISO 8601 format, i.e. "2022-05-04T14:00:00.001000-04:00" or "2022-05-04T14:00:00Z"
Returns: array of int
getUTCTimezone(dateStr)
Get UTC timezone.
Parameters:
dateStr : : ISO 8601 format, i.e. "2022-05-04T14:00:00.001000-04:00" or "2022-05-04T14:00:00Z"
Returns: string UTC timezone