Pineify Updated   
The "Pineify/common" library presents a specialized toolkit crafted to empower traders and script developers with state-of-the-art time manipulation functions on the TradingView platform. It is instead a foundational utility aimed at enriching your script's ability to process and interpret time-based data with unparalleled precision.

Key Features

String Splitter:

The 'str_split_into_two' function is a universal string handler that separates any given input into two distinct strings based on a specified delimiter. This function is especially useful in parsing time strings or any scenario where a string needs to be divided into logical parts efficiently.


[a, b] = str_split_into_two("a:b", ":")
// a = "a"
// b = "b"

Time Parser:

With 'time_to_hour_minute', users can effortlessly convert a time string into numerical hours and minutes. This function is pivotal for those who need to exact specific time series data or wish to schedule their trades down to the minute.


[time_hour, time_minute] = time_to_hour_minute("02:30")
// time_hour = 2
// time_minute = 30

Unix Time Converter

The 'time_range_to_unix_time' function transcends traditional boundaries by converting a given time range into Unix timestamp format. This integration of date, time, and timezone, accounts for a comprehensive approach, allowing scripts to make timed decisions, perform historical analyses, and account for international markets across different time zones.


// Support 'hhmm-hhmm' and 'hh:mm-hh:mm'
[start_unix_time, end_unix_time] = time_range_to_unix_time("09:30-12:00")


Each function is meticulously designed to minimize complexity and maximize versatility. Whether you are a programmer seeking to streamline your code, or a trader requiring precise timing for your strategies, our library provides the logical framework that aligns with your needs.

The "Pineify/common" library is the bridge between high-level time concepts and actionable trading insights. It serves a multitude of purposes – from crafting elegant time-based triggers to dissecting complex string data. Embrace the power of precision with "Pineify/common" and elevate your TradingView scripting experience to new heights.
Release Notes:

time_range_to_start_unix_time(time_range, date_time, timezone)
  Convert the time range to start unix time
    time_range (string): timeRange
    date_time (int): The Unix timestamp for the date.
    timezone (string): Timezone
  Returns: start_unix_time

time_range_to_end_unix_time(time_range, date_time, timezone)
  Convert the time range to end unix time
    time_range (string): timeRange
    date_time (int): The Unix timestamp for the date.
    timezone (string): Timezone
  Returns: end_unix_time
Release Notes:

  Convert the timeframe to seconds
    tf (simple string): timeframe
  Returns: seconds
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 a publication is governed by House Rules.


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.

Want to use this library?

Copy the following line and paste it in your script.