PINE LIBRARY
Input Library [1CG]

Input Library (v1) – User Guide
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:
This library is designed to:
Library Declaration
To use the library in your script:
Pine Script®
Timezone Enums
Timezones
Provides a comprehensive list of IANA timezone identifiers using short, intuitive enum names.
Examples include:
Method: timezoneToString()
Resolves the enum to a valid timezone string.
Pine Script®
Behavior:
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.
Pine Script®
Example output:
Drawing Style Enums
The library standardizes visual input options and converts them into TradingView constants.
LineStyle
Method: lineStyle()
Pine Script®
LineSize
Method: lineSize()
Pine Script®
TextSize
Method: textSize()
Pine Script®
Box Alignment Enums
BoxHAlign
BoxVAlign
Methods:
Pine Script®
Line Extension
LineExtend
Method: lineExtend()
Pine Script®
Label Styles
LabelStyle
Method: labelStyle()
Pine Script®
String-Based Conversion Helpers
For compatibility with legacy scripts or string inputs:
These functions convert common string descriptions into valid TradingView constants.
Timezone Offset Utility
Function: getTZOffset()
Calculates the difference between a specified timezone and UTC.
Pine Script®
Returns:
Time Span Utility
Function: timeSpan()
Converts common span names into milliseconds.
Supported values:
Example:
Pine Script®
Best Practices
Limitations
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.
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:
//@version=6
import OneCleverGuy/InputLibrary/1 as IL
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.
tzString = tzInput.timezoneToString()
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.
sessionTime = IL.combineTime(hourInput, minuteInput)
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()
lineStyleValue = styleInput.lineStyle()
LineSize
- thin → 1px
- normal → 2px
- heavy → 3px
- thick → 4px
- wide → 5px
Method: lineSize()
width = sizeInput.lineSize()
TextSize
- auto
- tiny
- small
- normal
- large
- huge
Method: textSize()
textSizeValue = textSizeInput.textSize()
Box Alignment Enums
BoxHAlign
- left
- center
- right
BoxVAlign
- top
- center
- bottom
Methods:
hAlign = hAlignInput.boxHAlign()
vAlign = vAlignInput.boxVAlign()
Line Extension
LineExtend
- none
- right
- left
- both
Method: lineExtend()
extendValue = extendInput.lineExtend()
Label Styles
LabelStyle
- center
- down
- left
- right
- up
- lowLeft
- lowRight
- upperLeft
- upperRight
Method: labelStyle()
labelStyleValue = labelInput.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.
offset = IL.getTZOffset("America/New_York")
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:
ms = IL.timeSpan("Hour")
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.
Pineライブラリ
TradingViewの精神に則り、作者はこのPineコードをオープンソースライブラリとして公開してくれました。コミュニティの他のPineプログラマーが再利用できるようにという配慮です。作者に拍手を!このライブラリは個人利用や他のオープンソースの公開コンテンツで使用できますが、公開物でのコードの再利用はハウスルールに準じる必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
Pineライブラリ
TradingViewの精神に則り、作者はこのPineコードをオープンソースライブラリとして公開してくれました。コミュニティの他のPineプログラマーが再利用できるようにという配慮です。作者に拍手を!このライブラリは個人利用や他のオープンソースの公開コンテンツで使用できますが、公開物でのコードの再利用はハウスルールに準じる必要があります。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。