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
Market Trading Sessions (TG Fork)Visualize trading sessions opening hours of several international exchanges on a grid. Contrary to other indicators, this one automatically aligns the session with the current chart's timezone.
This is helpful for bar replay or manual backtesting, to spot patterns of correlations (this can also be used in conjunction with correlation indicators, see my other indicators).
Original indicator by Gunzo, if you like this indicator, please show the original author some love:
This indicator is also inspired by the following indicators:
ZenAndTheArtOfTrading with
UnknownUnicorn468659 with
This fork implements the following features:
Converted to PineScript v5.
Adapted default color palette to dark mode, as is the default in TradingView now.
Fix drawing issues, now the design shows as it was originally meant to be.
Fixed mistiming issue that made some sessions display with a delay compared to the real session, especially the first session was bar at the start of the session was not displayed.
Inputted the accurate timings for each session, instead of the default 0800-1600 in the original indicator.
Essentially, you can just add this indicator and it should work out of the box. If not, please let me know, and I'll try to fix it!
How To Calculate Symbol's UTC NumberVarious methods to calculate a symbol's timezone offset as a numerical value in hours and decimal minutes. This value may be useful to script authors in certain situations where timezone information needs to be available in a numerical format while using intraday charts. Special thanks to @LucF and TradingView Support for their efficiency advisements!
NOTICE: This is an example script and not meant to be used as an actual strategy. By using this script or any portion thereof, you acknowledge that you have read and understood that this is for research purposes only and I am not responsible for any financial losses you may incur by using this script!
[RESEARCH] Litecoin Halving UTC CountdownAccording to this source www.litecoinblockhalf.com
The day, hour and minute of the halving date can be customized manually in case of mining troubles.
[RESEARCH] UTC ClockThe one of the most important indicators every trader must use is time :)
Sometimes it has a lag due to the script recalculation per each candle tick (not every second)