Input Library [1CG]

Overview
The Input Library is a Pine Script® v6 utility library that standardizes and simplifies common user input patterns across indicators, strategies, and libraries.
It provides:
- Predefined timezone enums mapped to IANA/Olson strings
- 24-hour and 60-minute enumerations
- Standardized line styles, sizes, label styles, and box alignment options
- Helper methods for converting enums into TradingView constants
- Utility functions for time formatting and span calculations
This library is designed to:
- Reduce repetitive input boilerplate
- Improve UI consistency across scripts
- Prevent string-based input errors
- Encourage clean, readable configuration logic
Library Declaration
To use the library in your script:
Timezone Enums
Timezones
Provides a comprehensive list of IANA timezone identifiers using short, intuitive enum names.
Examples include:
- utc → "UTC"
- exch → Exchange timezone (syminfo.timezone)
- ny → "America/New_York"
- lon → "Europe/London"
- tokyo → "Asia/Tokyo"
- syd → "Australia/Sydney"
Method: timezoneToString()
Resolves the enum to a valid timezone string.
Behavior:
- If Timezones.exch is selected, returns syminfo.timezone
- Otherwise returns the mapped IANA timezone string
Time Formatting Enums
hours
Represents 24-hour values from "00" through "23".
minutes
Represents minute values from "00" through "59".
Function: combineTime()
Combines hour and minute enums into a "HHMM" formatted string.
Example output:
- "0930"
- "1600"
Drawing Style Enums
The library standardizes visual input options and converts them into TradingView constants.
LineStyle
- solid
- dotted
- dashed
- lArrow
- rArrow
- bArrow
Method: lineStyle()
LineSize
- thin → 1px
- normal → 2px
- heavy → 3px
- thick → 4px
- wide → 5px
Method: lineSize()
TextSize
- auto
- tiny
- small
- normal
- large
- huge
Method: textSize()
Box Alignment Enums
BoxHAlign
- left
- center
- right
BoxVAlign
- top
- center
- bottom
Methods:
Line Extension
LineExtend
- none
- right
- left
- both
Method: lineExtend()
Label Styles
LabelStyle
- center
- down
- left
- right
- up
- lowLeft
- lowRight
- upperLeft
- upperRight
Method: labelStyle()
String-Based Conversion Helpers
For compatibility with legacy scripts or string inputs:
- lineStyleFromString()
- lineSizeFromString()
These functions convert common string descriptions into valid TradingView constants.
Timezone Offset Utility
Function: getTZOffset()
Calculates the difference between a specified timezone and UTC.
Returns:
- Millisecond difference between UTC and the specified timezone
- Accounts for daylight saving time
Time Span Utility
Function: timeSpan()
Converts common span names into milliseconds.
Supported values:
- "Minute"
- "Half Hour"
- "Hour"
- "4 Hours"
- "8 Hours"
- "12 Hours"
- "Day"
- "Week"
Example:
Best Practices
- Prefer enums over raw strings for safer configuration
- Use conversion methods directly on enum inputs
- Standardize visual settings across scripts using shared enums
- Avoid hardcoding timezone strings where possible
Limitations
- timeSpan() supports predefined span names only
- getTZOffset() returns raw millisecond difference, not formatted hours
- Library does not enforce input validation beyond enum constraints
Summary
The Input Library centralizes common input patterns into a reusable, structured framework. It improves script consistency, reduces UI friction, and ensures proper conversion between user selections and TradingView internal constants.
Designed for Pine Script® v6.
Perpustakaan pine
Dengan semangat TradingView yang sesungguhnya, penulis telah menerbitkan kode Pine ini sebagai pustaka sumber terbuka agar programmer Pine lain dari komunitas kami dapat menggunakannya kembali. Salut untuk penulis! Anda dapat menggunakan pustaka ini secara pribadi atau dalam publikasi sumber terbuka lainnya, tetapi penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib.
Pernyataan Penyangkalan
Perpustakaan pine
Dengan semangat TradingView yang sesungguhnya, penulis telah menerbitkan kode Pine ini sebagai pustaka sumber terbuka agar programmer Pine lain dari komunitas kami dapat menggunakannya kembali. Salut untuk penulis! Anda dapat menggunakan pustaka ini secara pribadi atau dalam publikasi sumber terbuka lainnya, tetapi penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib.