PINE LIBRARY

Input Library [1CG]

189
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:
  • 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:

Pine 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.

Pine Script®
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.

Pine Script®
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()

Pine Script®
lineStyleValue = styleInput.lineStyle()



LineSize
  • thin → 1px
  • normal → 2px
  • heavy → 3px
  • thick → 4px
  • wide → 5px


Method: lineSize()

Pine Script®
width = sizeInput.lineSize()



TextSize
  • auto
  • tiny
  • small
  • normal
  • large
  • huge


Method: textSize()

Pine Script®
textSizeValue = textSizeInput.textSize()



Box Alignment Enums

BoxHAlign
  • left
  • center
  • right


BoxVAlign
  • top
  • center
  • bottom


Methods:
Pine Script®
hAlign = hAlignInput.boxHAlign() vAlign = vAlignInput.boxVAlign()



Line Extension

LineExtend
  • none
  • right
  • left
  • both


Method: lineExtend()

Pine Script®
extendValue = extendInput.lineExtend()



Label Styles

LabelStyle
  • center
  • down
  • left
  • right
  • up
  • lowLeft
  • lowRight
  • upperLeft
  • upperRight


Method: labelStyle()

Pine Script®
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.

Pine Script®
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:
Pine Script®
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.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน