PINE LIBRARY
已更新 XZ_Display_Primitives

Library "XZ_Display_Primitives"
Generic bar-time drawing primitives for Pine scripts. Creates, updates or deletes lines, labels and boxes from caller-supplied presentation facts. Contains no trading methodology or analytical authority.
horizontalLine(id, visible, leftTime, rightTime, price, extendRight, lineColor, lineStyle, lineWidth)
Creates, updates or deletes one horizontal bar-time line.
Parameters:
id (line): Existing line handle, or na.
visible (bool): Whether the line should exist.
leftTime (int): Left endpoint time.
rightTime (int): Right endpoint time used when the line is finite and as the current anchor when projected.
price (float): Horizontal price.
extendRight (bool): True to project with extend.right, false for a finite segment.
lineColor (color): Line color.
lineStyle (string): Pine line style.
lineWidth (int): Line width.
Returns: Updated line handle, or na when hidden/invalid.
segmentLine(id, visible, firstTime, firstPrice, secondTime, secondPrice, lineColor, lineStyle, lineWidth)
Creates, updates or deletes one finite bar-time line segment.
Parameters:
id (line): Existing line handle, or na.
visible (bool): Whether the line should exist.
firstTime (int): First endpoint time.
firstPrice (float): First endpoint price.
secondTime (int): Second endpoint time.
secondPrice (float): Second endpoint price.
lineColor (color): Line color.
lineStyle (string): Pine line style.
lineWidth (int): Line width.
Returns: Updated line handle, or na when hidden/invalid.
priceLabel(id, visible, xTime, price, labelText, textColor, backgroundColor, labelStyle, labelSize, tooltipText, textAlign)
Creates, updates or deletes one price-anchored bar-time label.
Parameters:
id (label): Existing label handle, or na.
visible (bool): Whether the label should exist.
xTime (int): Label time coordinate.
price (float): Label price coordinate.
labelText (string): Visible label text.
textColor (color): Label text color.
backgroundColor (color): Label background color.
labelStyle (string): Pine label style.
labelSize (string): Pine label size.
tooltipText (string): Tooltip text.
textAlign (string): Pine text alignment.
Returns: Updated label handle, or na when hidden/invalid.
timeBox(id, visible, leftTime, rightTime, top, bottom, extendRight, fillColor, borderColor, borderStyle, borderWidth)
Creates, updates or deletes one bar-time box.
Parameters:
id (box): Existing box handle, or na.
visible (bool): Whether the box should exist.
leftTime (int): Left box time.
rightTime (int): Right box time used when finite and as the current anchor when projected.
top (float): Top price.
bottom (float): Bottom price.
extendRight (bool): True to project with extend.right, false for finite geometry.
fillColor (color): Box fill color. May be na.
borderColor (color): Box border color. May be na.
borderStyle (string): Pine line style for the border.
borderWidth (int): Border width.
Returns: Updated box handle, or na when hidden/invalid.
setBoxColors(id, fillColor, borderColor)
Applies fill and border colors to an existing box without changing geometry.
Parameters:
id (box): Box handle.
fillColor (color): New fill color.
borderColor (color): New border color.
Returns: True after the no-op or update.
setBoxBorderColor(id, borderColor)
Applies only a border color to an existing box without changing geometry.
Parameters:
id (box): Box handle.
borderColor (color): New border color.
Returns: True after the no-op or update.
setLabelTextColor(id, textColor)
Applies text color to an existing label without changing its geometry or text.
Parameters:
id (label): Label handle.
textColor (color): New text color.
Returns: True after the no-op or update.
clearBoxText(id)
Clears box text without changing geometry or styling.
Parameters:
id (box): Box handle.
Returns: True after the no-op or update.
Generic bar-time drawing primitives for Pine scripts. Creates, updates or deletes lines, labels and boxes from caller-supplied presentation facts. Contains no trading methodology or analytical authority.
horizontalLine(id, visible, leftTime, rightTime, price, extendRight, lineColor, lineStyle, lineWidth)
Creates, updates or deletes one horizontal bar-time line.
Parameters:
id (line): Existing line handle, or na.
visible (bool): Whether the line should exist.
leftTime (int): Left endpoint time.
rightTime (int): Right endpoint time used when the line is finite and as the current anchor when projected.
price (float): Horizontal price.
extendRight (bool): True to project with extend.right, false for a finite segment.
lineColor (color): Line color.
lineStyle (string): Pine line style.
lineWidth (int): Line width.
Returns: Updated line handle, or na when hidden/invalid.
segmentLine(id, visible, firstTime, firstPrice, secondTime, secondPrice, lineColor, lineStyle, lineWidth)
Creates, updates or deletes one finite bar-time line segment.
Parameters:
id (line): Existing line handle, or na.
visible (bool): Whether the line should exist.
firstTime (int): First endpoint time.
firstPrice (float): First endpoint price.
secondTime (int): Second endpoint time.
secondPrice (float): Second endpoint price.
lineColor (color): Line color.
lineStyle (string): Pine line style.
lineWidth (int): Line width.
Returns: Updated line handle, or na when hidden/invalid.
priceLabel(id, visible, xTime, price, labelText, textColor, backgroundColor, labelStyle, labelSize, tooltipText, textAlign)
Creates, updates or deletes one price-anchored bar-time label.
Parameters:
id (label): Existing label handle, or na.
visible (bool): Whether the label should exist.
xTime (int): Label time coordinate.
price (float): Label price coordinate.
labelText (string): Visible label text.
textColor (color): Label text color.
backgroundColor (color): Label background color.
labelStyle (string): Pine label style.
labelSize (string): Pine label size.
tooltipText (string): Tooltip text.
textAlign (string): Pine text alignment.
Returns: Updated label handle, or na when hidden/invalid.
timeBox(id, visible, leftTime, rightTime, top, bottom, extendRight, fillColor, borderColor, borderStyle, borderWidth)
Creates, updates or deletes one bar-time box.
Parameters:
id (box): Existing box handle, or na.
visible (bool): Whether the box should exist.
leftTime (int): Left box time.
rightTime (int): Right box time used when finite and as the current anchor when projected.
top (float): Top price.
bottom (float): Bottom price.
extendRight (bool): True to project with extend.right, false for finite geometry.
fillColor (color): Box fill color. May be na.
borderColor (color): Box border color. May be na.
borderStyle (string): Pine line style for the border.
borderWidth (int): Border width.
Returns: Updated box handle, or na when hidden/invalid.
setBoxColors(id, fillColor, borderColor)
Applies fill and border colors to an existing box without changing geometry.
Parameters:
id (box): Box handle.
fillColor (color): New fill color.
borderColor (color): New border color.
Returns: True after the no-op or update.
setBoxBorderColor(id, borderColor)
Applies only a border color to an existing box without changing geometry.
Parameters:
id (box): Box handle.
borderColor (color): New border color.
Returns: True after the no-op or update.
setLabelTextColor(id, textColor)
Applies text color to an existing label without changing its geometry or text.
Parameters:
id (label): Label handle.
textColor (color): New text color.
Returns: True after the no-op or update.
clearBoxText(id)
Clears box text without changing geometry or styling.
Parameters:
id (box): Box handle.
Returns: True after the no-op or update.
發行說明
v2Added:
finiteOrProjectedHorizontalLine(id, visible, leftTime, rightAnchorTime, finiteRightTime, projectLive, price, lineColor, lineStyle, lineWidth)
Creates/updates a horizontal line whose right side is projected or finite.
Parameters:
id (line)
visible (bool)
leftTime (int)
rightAnchorTime (int)
finiteRightTime (int)
projectLive (bool)
price (float)
lineColor (color)
lineStyle (string)
lineWidth (int)
midpointPriceLabel(id, visible, firstTime, firstPrice, secondTime, secondPrice, labelText, textColor, backgroundColor, labelStyle, labelSize, tooltipText, textAlign)
Creates/updates a price label at the midpoint between two endpoints.
Parameters:
id (label)
visible (bool)
firstTime (int)
firstPrice (float)
secondTime (int)
secondPrice (float)
labelText (string)
textColor (color)
backgroundColor (color)
labelStyle (string)
labelSize (string)
tooltipText (string)
textAlign (string)
fiveLevelPriceLabelPool(pool, slot, visible, rightTime, q0, q25, q50, q75, q100, textColor, backgroundColor, labelStyle, labelSize, textAlign)
Updates one five-label 0/25/50/75/100 pool slot.
Parameters:
pool (array<label>)
slot (int)
visible (bool)
rightTime (int)
q0 (float)
q25 (float)
q50 (float)
q75 (float)
q100 (float)
textColor (color)
backgroundColor (color)
labelStyle (string)
labelSize (string)
textAlign (string)
newBarRelativeLabel(xTime, price, labelText, aboveBar, textColor, labelSize, tooltipText)
Creates one above-bar/below-bar label.
Parameters:
xTime (int)
price (float)
labelText (string)
aboveBar (bool)
textColor (color)
labelSize (string)
tooltipText (string)
deleteLabelArray(ids)
Deletes every label in an array and clears the array.
Parameters:
ids (array<label>)
ensureLinePool(pool, targetSize)
Ensures a line-handle pool contains at least targetSize elements.
Parameters:
pool (array<line>)
targetSize (int)
ensureBoxPool(pool, targetSize)
Ensures a box-handle pool contains at least targetSize elements.
Parameters:
pool (array<box>)
targetSize (int)
ensureLabelPool(pool, targetSize)
Ensures a label-handle pool contains at least targetSize elements.
Parameters:
pool (array<label>)
targetSize (int)
發行說明
v3Added:
deleteLineArray(ids)
Deletes every line in an array and clears the array.
Parameters:
ids (array<line>)
deleteBoxArray(ids)
Deletes every box in an array and clears the array.
Parameters:
ids (array<box>)
發行說明
v4Added:
resolveLabelSize(key)
Resolves the common XZ label-size selector.
Parameters:
key (string)
resolveLineStyle(key)
Resolves Solid/Dashed/Dotted into a Pine line style.
Parameters:
key (string)
registerHistoricalLabel(ids, detailSequences, horizonBars, confirmTimes, originalTexts, id, detailSequence, horizonBar, confirmTime, limit)
Registers a historical label plus caller-owned parallel metadata and enforces a bounded label count.
Parameters:
ids (array<label>)
detailSequences (array<int>)
horizonBars (array<int>)
confirmTimes (array<int>)
originalTexts (array<string>)
id (label)
detailSequence (int)
horizonBar (int)
confirmTime (int)
limit (int)
registerHistoricalLine(ids, detailSequences, horizonBars, confirmTimes, originalColors, id, originalColor, detailSequence, horizonBar, confirmTime, limit)
Registers a historical line plus caller-owned parallel metadata and enforces a bounded line count.
Parameters:
ids (array<line>)
detailSequences (array<int>)
horizonBars (array<int>)
confirmTimes (array<int>)
originalColors (array<color>)
id (line)
originalColor (color)
detailSequence (int)
horizonBar (int)
confirmTime (int)
limit (int)
registerHistoricalBox(ids, detailSequences, horizonBars, confirmTimes, originalColors, id, originalColor, detailSequence, horizonBar, confirmTime, limit)
Registers a historical box plus caller-owned parallel metadata and enforces a bounded box count.
Parameters:
ids (array<box>)
detailSequences (array<int>)
horizonBars (array<int>)
confirmTimes (array<int>)
originalColors (array<color>)
id (box)
originalColor (color)
detailSequence (int)
horizonBar (int)
confirmTime (int)
limit (int)
deleteHistoricalLabel(ids, detailSequences, horizonBars, confirmTimes, originalTexts, id)
Removes one registered historical label and matching parallel metadata.
Parameters:
ids (array<label>)
detailSequences (array<int>)
horizonBars (array<int>)
confirmTimes (array<int>)
originalTexts (array<string>)
id (label)
historicalLabelText(ids, originalTexts, id)
Retrieves the original text stored for a registered label.
Parameters:
ids (array<label>)
originalTexts (array<string>)
id (label)
restoreSemanticLabel(id, originalText, semanticColor, textOnly, labelSize)
Restores semantic label presentation without changing geometry or tooltip.
Parameters:
id (label)
originalText (string)
semanticColor (color)
textOnly (bool)
labelSize (string)
muteLabel(id, textTransparency, backgroundTransparency)
Applies a quiet contextual mute to a label without changing geometry or text.
Parameters:
id (label)
textTransparency (int)
backgroundTransparency (int)
muteLine(id, baseColor, transparency)
Applies a transparency-only contextual mute to a line.
Parameters:
id (line)
baseColor (color)
transparency (int)
muteBox(id, baseColor, minimumTransparency)
Applies a minimum transparency contextual mute to a box fill and border.
Parameters:
id (box)
baseColor (color)
minimumTransparency (int)
setLineColor(id, lineColor)
Sets one line color without changing geometry.
Parameters:
id (line)
lineColor (color)
發行說明
v5Added:
focusedString(focused, overrideValue, nativeValue, inheritToken)
Resolves a shared string override only when the caller-selected family is focused and the override is not the inherit token.
Parameters:
focused (bool)
overrideValue (string)
nativeValue (string)
inheritToken (string)
focusedPositiveInt(focused, overrideValue, nativeValue)
Resolves a positive integer override only when the caller-selected family is focused; non-positive override values inherit the native value.
Parameters:
focused (bool)
overrideValue (int)
nativeValue (int)
parseWidth(key)
Parses the standard Native/1/2/3/4 width selector. Native returns zero so callers can inherit their family default.
Parameters:
key (string)
familyColor(unified, focused, overrideColor, nativeColor, transparency)
Resolves an override/native family colour and applies caller-supplied transparency. Unified applies the override to every family; focused applies it only to the selected family.
Parameters:
unified (bool)
focused (bool)
overrideColor (color)
nativeColor (color)
transparency (int)
focusedInt(focused, overrideEnabled, overrideValue, nativeValue)
Resolves an integer presentation override behind an explicit enable switch for one focused family.
Parameters:
focused (bool)
overrideEnabled (bool)
overrideValue (int)
nativeValue (int)
發行說明
v6Added:
suppressLabel(id)
Fully suppresses one label without deleting its handle or changing its geometry/tooltip.
Parameters:
id (label)
suppressLabelArray(ids)
Fully suppresses every non-na label in an array without deleting handles.
Parameters:
ids (array<label>)
setLabelTextSize(id, labelText, labelSize)
Applies caller-supplied text and size to one existing label without changing geometry, colors or tooltip.
Parameters:
id (label)
labelText (string)
labelSize (string)
restyleHistoricalLinesBoxes(lineIds, lineDetailSequences, lineHorizonBars, lineConfirmTimes, lineColors, boxIds, boxDetailSequences, boxHorizonBars, boxConfirmTimes, boxColors, eventCountNow, recentDetailEvents, currentOnly, allHistory, horizonStartBar, useManualStart, manualStartTime, olderHistoryMode, olderHistoryFade)
Restyles caller-owned historical line/box registries for temporal scope, older-history fade and Current-only suppression. All analytical meaning is resolved by the caller before invocation.
Parameters:
lineIds (array<line>)
lineDetailSequences (array<int>)
lineHorizonBars (array<int>)
lineConfirmTimes (array<int>)
lineColors (array<color>)
boxIds (array<box>)
boxDetailSequences (array<int>)
boxHorizonBars (array<int>)
boxConfirmTimes (array<int>)
boxColors (array<color>)
eventCountNow (int)
recentDetailEvents (int)
currentOnly (bool)
allHistory (bool)
horizonStartBar (int)
useManualStart (bool)
manualStartTime (int)
olderHistoryMode (string)
olderHistoryFade (int)
muteHistoricalRegistries(labelIds, labelDetailSequences, labelHorizonBars, labelConfirmTimes, lineIds, lineDetailSequences, lineHorizonBars, lineConfirmTimes, lineColors, boxIds, boxDetailSequences, boxHorizonBars, boxConfirmTimes, boxColors, eventCountNow, recentDetailEvents, currentOnly, allHistory, horizonStartBar, useManualStart, manualStartTime, olderHistoryMode, labelTextTransparency, labelBackgroundTransparency, lineTransparency, boxTransparency)
Contextually mutes only historical objects that are presently visible under caller-supplied temporal/detail scope. It never determines analytical relevance or focus membership.
Parameters:
labelIds (array<label>)
labelDetailSequences (array<int>)
labelHorizonBars (array<int>)
labelConfirmTimes (array<int>)
lineIds (array<line>)
lineDetailSequences (array<int>)
lineHorizonBars (array<int>)
lineConfirmTimes (array<int>)
lineColors (array<color>)
boxIds (array<box>)
boxDetailSequences (array<int>)
boxHorizonBars (array<int>)
boxConfirmTimes (array<int>)
boxColors (array<color>)
eventCountNow (int)
recentDetailEvents (int)
currentOnly (bool)
allHistory (bool)
horizonStartBar (int)
useManualStart (bool)
manualStartTime (int)
olderHistoryMode (string)
labelTextTransparency (int)
labelBackgroundTransparency (int)
lineTransparency (int)
boxTransparency (int)
發行說明
v7Added:
newHistoricalRegistry()
Creates an empty generic historical drawing registry.
registryLabelCount(state)
Number of retained labels in a generic historical registry.
Parameters:
state (HistoricalRegistry)
registryLineCount(state)
Number of retained lines in a generic historical registry.
Parameters:
state (HistoricalRegistry)
registryBoxCount(state)
Number of retained boxes in a generic historical registry.
Parameters:
state (HistoricalRegistry)
registerRegistryLabel(state, id, detailSequence, horizonBar, confirmTime, compactText, limit)
Registers a label with caller-resolved original/compact text and enforces a bounded count.
Parameters:
state (HistoricalRegistry)
id (label)
detailSequence (int)
horizonBar (int)
confirmTime (int)
compactText (string)
limit (int)
registerRegistryLine(state, id, originalColor, detailSequence, horizonBar, confirmTime, limit)
Registers a line with caller-resolved colour and enforces a bounded count.
Parameters:
state (HistoricalRegistry)
id (line)
originalColor (color)
detailSequence (int)
horizonBar (int)
confirmTime (int)
limit (int)
registerRegistryBox(state, id, originalColor, detailSequence, horizonBar, confirmTime, limit)
Registers a box with caller-resolved colour and enforces a bounded count.
Parameters:
state (HistoricalRegistry)
id (box)
originalColor (color)
detailSequence (int)
horizonBar (int)
confirmTime (int)
limit (int)
deleteRegistryLabel(state, id)
Removes one label and matching registry metadata.
Parameters:
state (HistoricalRegistry)
id (label)
registryOriginalLabelText(state, id)
Retrieves caller-supplied original text for one retained label.
Parameters:
state (HistoricalRegistry)
id (label)
registryMutatedOnBar(state, horizonBar)
True when any registry family most recently admitted an object on the supplied horizon bar.
Parameters:
state (HistoricalRegistry)
horizonBar (int)
restyleRegistry(state, eventCountNow, recentDetailEvents, currentOnly, allHistory, horizonStartBar, useManualStart, manualStartTime, olderHistoryMode, olderHistoryFade)
Applies temporal/detail presentation to all three drawing families. Compact label text is caller supplied at registration; no semantic transformation occurs here.
Parameters:
state (HistoricalRegistry)
eventCountNow (int)
recentDetailEvents (int)
currentOnly (bool)
allHistory (bool)
horizonStartBar (int)
useManualStart (bool)
manualStartTime (int)
olderHistoryMode (string)
olderHistoryFade (int)
muteRegistry(state, eventCountNow, recentDetailEvents, currentOnly, allHistory, horizonStartBar, useManualStart, manualStartTime, olderHistoryMode, labelTextTransparency, labelBackgroundTransparency, lineTransparency, boxTransparency)
Applies generic contextual muting across a bundled historical registry.
Parameters:
state (HistoricalRegistry)
eventCountNow (int)
recentDetailEvents (int)
currentOnly (bool)
allHistory (bool)
horizonStartBar (int)
useManualStart (bool)
manualStartTime (int)
olderHistoryMode (string)
labelTextTransparency (int)
labelBackgroundTransparency (int)
lineTransparency (int)
boxTransparency (int)
HistoricalRegistry
Bundles generic historical drawing handles and caller-supplied presentation metadata.
Fields:
label_ids (array<label>)
label_detail_sequences (array<int>)
label_horizon_bars (array<int>)
label_confirm_times (array<int>)
label_original_texts (array<string>)
label_compact_texts (array<string>)
line_ids (array<line>)
line_detail_sequences (array<int>)
line_horizon_bars (array<int>)
line_confirm_times (array<int>)
line_colors (array<color>)
box_ids (array<box>)
box_detail_sequences (array<int>)
box_horizon_bars (array<int>)
box_confirm_times (array<int>)
box_colors (array<color>)
發行說明
v8Added:
registryHasLabel(state, id)
True when a label ID is still retained by the generic historical registry.
Parameters:
state (HistoricalRegistry)
id (label)
registryHasLine(state, id)
True when a line ID is still retained by the generic historical registry.
Parameters:
state (HistoricalRegistry)
id (line)
registryHasBox(state, id)
True when a box ID is still retained by the generic historical registry.
Parameters:
state (HistoricalRegistry)
id (box)
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。