PINE LIBRARY
업데이트됨 XZ_Core_Utilities

Library "XZ_Core_Utilities"
Generic formatting, identifier parsing and neutral geometry helpers for XZ scripts. Contains no XZ methodology or analytical authority.
csvContainsPositiveInt(objectId, csvIds)
Returns true when a positive integer ID occurs as a comma-separated token.
Parameters:
objectId (int): Positive integer to search for.
csvIds (string): Comma-separated integer text. Spaces are ignored.
Returns: True when objectId occurs as an exact parsed token.
csvFirstPositiveInt(csvIds)
Returns the first positive integer token in comma-separated text.
Parameters:
csvIds (string): Comma-separated integer text. Spaces are ignored.
Returns: First parsed positive integer, or 0 when none exists.
nearDuplicateBounds(lowA, highA, lowB, highB, tolerancePct)
Tests whether two low/high geometries are near-duplicates under a supplied percentage tolerance.
Parameters:
lowA (float): First lower bound.
highA (float): First upper bound.
lowB (float): Second lower bound.
highB (float): Second upper bound.
tolerancePct (float): Tolerance as a percentage of the wider geometry.
Returns: True when both corresponding boundaries fall within the calculated tolerance.
formatDate(eventTime, timezone)
Formats a timestamp as yyyy-MM-dd in the supplied timezone.
Parameters:
eventTime (int): UNIX timestamp in milliseconds.
timezone (string): Timezone string accepted by str.format_time().
Returns: Formatted date, or an em dash for na.
formatPercent(value)
Formats a percentage value with up to two decimals.
Parameters:
value (float): Percentage value.
Returns: Percentage text, or an em dash for na.
formatSignedPercent(value)
Formats a signed percentage value with up to two decimals.
Parameters:
value (float): Percentage value.
Returns: Signed percentage text, or an em dash for na.
timeframeLabel(tf)
Converts common TradingView timeframe strings into compact readable labels.
Parameters:
tf (string): TradingView timeframe string.
Returns: Compact label such as 1D, 1W, 4H or 15m.
formatDistance(distance, useTicks, minTick)
Formats an absolute price distance as points or ticks. Unit policy is supplied by the caller.
Parameters:
distance (float): Raw price distance.
useTicks (bool): True to convert distance to ticks.
minTick (float): Instrument minimum tick.
Returns: Formatted absolute distance with explicit unit.
directionalMovePct(fromPrice, toPrice, minTick)
Calculates signed percentage move from one price to another.
Parameters:
fromPrice (float): Chronological starting price.
toPrice (float): Chronological ending price.
minTick (float): Instrument minimum tick used to reject a near-zero denominator.
Returns: Signed percentage move, or na when unavailable.
normalizedPositionPct(currentValue, lowPrice, highPrice)
Calculates normalized position of a value within low-to-high geometry.
Parameters:
currentValue (float): Value being located.
lowPrice (float): Geometry lower bound.
highPrice (float): Geometry upper bound.
Returns: Position percentage where 0 is the lower bound and 100 is the upper bound. Values may fall outside 0-100.
formatElapsedDays(fromTime, toTime)
Formats elapsed milliseconds between two timestamps as fractional days.
Parameters:
fromTime (int): Starting timestamp.
toTime (int): Ending timestamp.
Returns: Day text with singular/plural unit, or an em dash when invalid.
quartilePrice(low, high, levelIndex)
Returns one of five equally spaced 0/25/50/75/100 geometry levels.
Parameters:
low (float): Lower geometry bound.
high (float): Upper geometry bound.
levelIndex (int): Integer level index from 0 to 4.
Returns: Price at the requested quartile level.
quartileText(levelIndex)
Returns the display text for quartile level index 0-4.
Parameters:
levelIndex (int): Integer level index from 0 to 4.
Returns: 0%, 25%, 50%, 75% or 100%.
appendUniqueToken(current, token, separator)
Appends a token only when it is not already present in a separator-delimited string.
Parameters:
current (string): Existing token string.
token (string): Token to append.
separator (string): Delimiter between tokens.
Returns: Original or extended token string.
Generic formatting, identifier parsing and neutral geometry helpers for XZ scripts. Contains no XZ methodology or analytical authority.
csvContainsPositiveInt(objectId, csvIds)
Returns true when a positive integer ID occurs as a comma-separated token.
Parameters:
objectId (int): Positive integer to search for.
csvIds (string): Comma-separated integer text. Spaces are ignored.
Returns: True when objectId occurs as an exact parsed token.
csvFirstPositiveInt(csvIds)
Returns the first positive integer token in comma-separated text.
Parameters:
csvIds (string): Comma-separated integer text. Spaces are ignored.
Returns: First parsed positive integer, or 0 when none exists.
nearDuplicateBounds(lowA, highA, lowB, highB, tolerancePct)
Tests whether two low/high geometries are near-duplicates under a supplied percentage tolerance.
Parameters:
lowA (float): First lower bound.
highA (float): First upper bound.
lowB (float): Second lower bound.
highB (float): Second upper bound.
tolerancePct (float): Tolerance as a percentage of the wider geometry.
Returns: True when both corresponding boundaries fall within the calculated tolerance.
formatDate(eventTime, timezone)
Formats a timestamp as yyyy-MM-dd in the supplied timezone.
Parameters:
eventTime (int): UNIX timestamp in milliseconds.
timezone (string): Timezone string accepted by str.format_time().
Returns: Formatted date, or an em dash for na.
formatPercent(value)
Formats a percentage value with up to two decimals.
Parameters:
value (float): Percentage value.
Returns: Percentage text, or an em dash for na.
formatSignedPercent(value)
Formats a signed percentage value with up to two decimals.
Parameters:
value (float): Percentage value.
Returns: Signed percentage text, or an em dash for na.
timeframeLabel(tf)
Converts common TradingView timeframe strings into compact readable labels.
Parameters:
tf (string): TradingView timeframe string.
Returns: Compact label such as 1D, 1W, 4H or 15m.
formatDistance(distance, useTicks, minTick)
Formats an absolute price distance as points or ticks. Unit policy is supplied by the caller.
Parameters:
distance (float): Raw price distance.
useTicks (bool): True to convert distance to ticks.
minTick (float): Instrument minimum tick.
Returns: Formatted absolute distance with explicit unit.
directionalMovePct(fromPrice, toPrice, minTick)
Calculates signed percentage move from one price to another.
Parameters:
fromPrice (float): Chronological starting price.
toPrice (float): Chronological ending price.
minTick (float): Instrument minimum tick used to reject a near-zero denominator.
Returns: Signed percentage move, or na when unavailable.
normalizedPositionPct(currentValue, lowPrice, highPrice)
Calculates normalized position of a value within low-to-high geometry.
Parameters:
currentValue (float): Value being located.
lowPrice (float): Geometry lower bound.
highPrice (float): Geometry upper bound.
Returns: Position percentage where 0 is the lower bound and 100 is the upper bound. Values may fall outside 0-100.
formatElapsedDays(fromTime, toTime)
Formats elapsed milliseconds between two timestamps as fractional days.
Parameters:
fromTime (int): Starting timestamp.
toTime (int): Ending timestamp.
Returns: Day text with singular/plural unit, or an em dash when invalid.
quartilePrice(low, high, levelIndex)
Returns one of five equally spaced 0/25/50/75/100 geometry levels.
Parameters:
low (float): Lower geometry bound.
high (float): Upper geometry bound.
levelIndex (int): Integer level index from 0 to 4.
Returns: Price at the requested quartile level.
quartileText(levelIndex)
Returns the display text for quartile level index 0-4.
Parameters:
levelIndex (int): Integer level index from 0 to 4.
Returns: 0%, 25%, 50%, 75% or 100%.
appendUniqueToken(current, token, separator)
Appends a token only when it is not already present in a separator-delimited string.
Parameters:
current (string): Existing token string.
token (string): Token to append.
separator (string): Delimiter between tokens.
Returns: Original or extended token string.
릴리즈 노트
v2Added:
csvPositiveInts(csvIds)
Parses all positive integer tokens from comma-separated text.
Parameters:
csvIds (string): Comma-separated integer text. Spaces are ignored.
Returns: Array of positive integers in source order.
appendSeparatedText(base, item, separator)
Appends text using a separator only when the base is non-empty.
Parameters:
base (string)
item (string)
separator (string)
pushUniqueIntLimited(values, value, limit)
Pushes a non-negative integer only when absent and capacity remains.
Parameters:
values (array<int>)
value (int)
limit (int)
prioritizeUniqueIntLimited(values, value, limit)
Moves/inserts a non-negative integer to the front and enforces a maximum size.
Parameters:
values (array<int>)
value (int)
limit (int)
distanceUsesTicks(unitMode, instrumentType)
Resolves an Auto/Points/Ticks policy into a ticks boolean.
Parameters:
unitMode (string)
instrumentType (string)
positionRelationshipText(currentValue, lowPrice, highPrice, objectName)
Builds a generic normalized-position sentence for a bounded object.
Parameters:
currentValue (float)
lowPrice (float)
highPrice (float)
objectName (string)
릴리즈 노트
v3Added:
dispatchAlertOncePerBarClose(message)
Dispatches a non-empty caller-built alert message once per bar close. The importing script remains authority for event existence, admission and message meaning.
Parameters:
message (string)
dispatchAlertOncePerBar(message)
Dispatches a non-empty caller-built alert message once per bar. The importing script remains authority for event existence, admission and message meaning.
Parameters:
message (string)
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.