PINE LIBRARY
Kerbal_Helpers

Library "kerbal_helpers"
Kerbal Indicators Shared Library - Drawing object helpers
This library provides utilities for managing labels, boxes, and areas within Pine Script limits (500 each).
Includes deduplication, cleanup, filtering, and zone management functions.
ageFilter(barIndex, creationBar, maxAge)
Check if an object is too old based on bar index
Parameters:
barIndex (int): Current bar index
creationBar (int): Bar index when object was created
maxAge (int): Maximum age in bars
Returns: True if object should be filtered out (too old)
distanceFilter(price, referencePrice, atrMultiplier, atr)
Check if price is within acceptable distance from reference
Parameters:
price (float): The price to check
referencePrice (float): The reference price
atrMultiplier (float): ATR multiplier for distance
atr (float): The ATR value
Returns: True if within acceptable distance
weightFilter(weight, minWeight)
Check if weight meets minimum threshold
Parameters:
weight (float): The weight value
minWeight (float): Minimum acceptable weight
Returns: True if weight is acceptable
perfectionFilter(isPerfected, requirePerfection)
Check perfection requirement (for Price Exhaustion clusters)
Parameters:
isPerfected (bool): Whether the signal is perfected
requirePerfection (bool): Whether perfection is required
Returns: True if passes perfection filter
boxOverlaps(box1Top, box1Bot, box2Top, box2Bot)
Check if two boxes overlap in price space
Parameters:
box1Top (float): Top price of first box
box1Bot (float): Bottom price of first box
box2Top (float): Top price of second box
box2Bot (float): Bottom price of second box
Returns: True if boxes overlap
boxMerge(box1Top, box1Bot, box2Top, box2Bot)
Calculate the merged boundaries of two overlapping boxes
Parameters:
box1Top (float): Top price of first box
box1Bot (float): Bottom price of first box
box2Top (float): Top price of second box
box2Bot (float): Bottom price of second box
Returns: Tuple [mergedTop, mergedBot]
priceInZone(price, boxTop, boxBot)
Check if a price is within a box/zone
Parameters:
price (float): The price to check
boxTop (float): Top of the box
boxBot (float): Bottom of the box
Returns: True if price is within box boundaries
zoneCenter(boxTop, boxBot)
Calculate the center price of a zone
Parameters:
boxTop (float): Top of the zone
boxBot (float): Bottom of the zone
Returns: Center price
zoneWidth(boxTop, boxBot)
Calculate zone width/thickness
Parameters:
boxTop (float): Top of the zone
boxBot (float): Bottom of the zone
Returns: Zone width
labelsNearby(x1, y1, x2, y2, barTolerance, priceTolerance)
Check if two labels would be too close (for deduplication)
Parameters:
x1 (int): Bar index of first label
y1 (float): Price of first label
x2 (int): Bar index of second label
y2 (float): Price of second label
barTolerance (int): Maximum bar distance for considering labels duplicate
priceTolerance (float): Maximum price distance for considering labels duplicate
Returns: True if labels are close enough to be considered duplicates
labelDistance(x1, y1, x2, y2, atr)
Calculate distance score between two label positions (lower is closer)
Parameters:
x1 (int): Bar index of first label
y1 (float): Price of first label
x2 (int): Bar index of second label
y2 (float): Price of second label
atr (float): ATR value for price normalization
Returns: Distance score (0+ range, lower means closer)
clusterType(hasSession, hasPivot, hasVolume, weight, goldThreshold, limeThreshold)
Classify cluster composition based on anchor types present
Parameters:
hasSession (bool): Whether cluster contains session anchors (daily/weekly)
hasPivot (bool): Whether cluster contains pivot anchors
hasVolume (bool): Whether cluster contains volume anchors
weight (float): Total cluster weight
goldThreshold (float): Weight threshold for "gold" classification
limeThreshold (float): Weight threshold for "lime" classification
Returns: Cluster type: "GOLD", "LIME", "MIXED", "SESSION", "PIVOT", "VOLUME"
clusterColor(clusterType)
Get color for cluster based on type
Parameters:
clusterType (string): The cluster type string
Returns: Appropriate color for the cluster type
zoneSignificant(weight, width, minWeight, maxWidth)
Check if a zone is significant enough to display
Parameters:
weight (float): Zone weight
width (float): Zone width in price
minWeight (float): Minimum weight threshold
maxWidth (float): Maximum width threshold (ATR-based)
Returns: True if zone should be displayed
mergeZones(prices, widths, tolerance)
Merge multiple nearby zones into a single wider zone
Parameters:
prices (array<float>): Array of zone center prices
widths (array<float>): Array of zone widths
tolerance (float): Merging tolerance (typically ATR-based)
Returns: Tuple of [mergedCenters, mergedWidths] arrays
findSupportResistance(prices, currentPrice)
Calculate support and resistance levels from an array of prices
Parameters:
prices (array<float>): Array of price levels
currentPrice (float): Current market price
Returns: Tuple of [nearestSupport, nearestResistance]
zoneStrength(weight, age, touches, width, maxAge, maxTouches, optimalWidth)
Calculate zone strength score based on multiple factors
Parameters:
weight (float): Zone weight (volume participation)
age (int): Bars since zone creation
touches (int): Number of price touches/tests
width (float): Zone width
maxAge (int): Maximum age for full score
maxTouches (int): Maximum touches for full score
optimalWidth (float): Optimal zone width (narrower is better)
Returns: Strength score 0-100
Kerbal Indicators Shared Library - Drawing object helpers
This library provides utilities for managing labels, boxes, and areas within Pine Script limits (500 each).
Includes deduplication, cleanup, filtering, and zone management functions.
ageFilter(barIndex, creationBar, maxAge)
Check if an object is too old based on bar index
Parameters:
barIndex (int): Current bar index
creationBar (int): Bar index when object was created
maxAge (int): Maximum age in bars
Returns: True if object should be filtered out (too old)
distanceFilter(price, referencePrice, atrMultiplier, atr)
Check if price is within acceptable distance from reference
Parameters:
price (float): The price to check
referencePrice (float): The reference price
atrMultiplier (float): ATR multiplier for distance
atr (float): The ATR value
Returns: True if within acceptable distance
weightFilter(weight, minWeight)
Check if weight meets minimum threshold
Parameters:
weight (float): The weight value
minWeight (float): Minimum acceptable weight
Returns: True if weight is acceptable
perfectionFilter(isPerfected, requirePerfection)
Check perfection requirement (for Price Exhaustion clusters)
Parameters:
isPerfected (bool): Whether the signal is perfected
requirePerfection (bool): Whether perfection is required
Returns: True if passes perfection filter
boxOverlaps(box1Top, box1Bot, box2Top, box2Bot)
Check if two boxes overlap in price space
Parameters:
box1Top (float): Top price of first box
box1Bot (float): Bottom price of first box
box2Top (float): Top price of second box
box2Bot (float): Bottom price of second box
Returns: True if boxes overlap
boxMerge(box1Top, box1Bot, box2Top, box2Bot)
Calculate the merged boundaries of two overlapping boxes
Parameters:
box1Top (float): Top price of first box
box1Bot (float): Bottom price of first box
box2Top (float): Top price of second box
box2Bot (float): Bottom price of second box
Returns: Tuple [mergedTop, mergedBot]
priceInZone(price, boxTop, boxBot)
Check if a price is within a box/zone
Parameters:
price (float): The price to check
boxTop (float): Top of the box
boxBot (float): Bottom of the box
Returns: True if price is within box boundaries
zoneCenter(boxTop, boxBot)
Calculate the center price of a zone
Parameters:
boxTop (float): Top of the zone
boxBot (float): Bottom of the zone
Returns: Center price
zoneWidth(boxTop, boxBot)
Calculate zone width/thickness
Parameters:
boxTop (float): Top of the zone
boxBot (float): Bottom of the zone
Returns: Zone width
labelsNearby(x1, y1, x2, y2, barTolerance, priceTolerance)
Check if two labels would be too close (for deduplication)
Parameters:
x1 (int): Bar index of first label
y1 (float): Price of first label
x2 (int): Bar index of second label
y2 (float): Price of second label
barTolerance (int): Maximum bar distance for considering labels duplicate
priceTolerance (float): Maximum price distance for considering labels duplicate
Returns: True if labels are close enough to be considered duplicates
labelDistance(x1, y1, x2, y2, atr)
Calculate distance score between two label positions (lower is closer)
Parameters:
x1 (int): Bar index of first label
y1 (float): Price of first label
x2 (int): Bar index of second label
y2 (float): Price of second label
atr (float): ATR value for price normalization
Returns: Distance score (0+ range, lower means closer)
clusterType(hasSession, hasPivot, hasVolume, weight, goldThreshold, limeThreshold)
Classify cluster composition based on anchor types present
Parameters:
hasSession (bool): Whether cluster contains session anchors (daily/weekly)
hasPivot (bool): Whether cluster contains pivot anchors
hasVolume (bool): Whether cluster contains volume anchors
weight (float): Total cluster weight
goldThreshold (float): Weight threshold for "gold" classification
limeThreshold (float): Weight threshold for "lime" classification
Returns: Cluster type: "GOLD", "LIME", "MIXED", "SESSION", "PIVOT", "VOLUME"
clusterColor(clusterType)
Get color for cluster based on type
Parameters:
clusterType (string): The cluster type string
Returns: Appropriate color for the cluster type
zoneSignificant(weight, width, minWeight, maxWidth)
Check if a zone is significant enough to display
Parameters:
weight (float): Zone weight
width (float): Zone width in price
minWeight (float): Minimum weight threshold
maxWidth (float): Maximum width threshold (ATR-based)
Returns: True if zone should be displayed
mergeZones(prices, widths, tolerance)
Merge multiple nearby zones into a single wider zone
Parameters:
prices (array<float>): Array of zone center prices
widths (array<float>): Array of zone widths
tolerance (float): Merging tolerance (typically ATR-based)
Returns: Tuple of [mergedCenters, mergedWidths] arrays
findSupportResistance(prices, currentPrice)
Calculate support and resistance levels from an array of prices
Parameters:
prices (array<float>): Array of price levels
currentPrice (float): Current market price
Returns: Tuple of [nearestSupport, nearestResistance]
zoneStrength(weight, age, touches, width, maxAge, maxTouches, optimalWidth)
Calculate zone strength score based on multiple factors
Parameters:
weight (float): Zone weight (volume participation)
age (int): Bars since zone creation
touches (int): Number of price touches/tests
width (float): Zone width
maxAge (int): Maximum age for full score
maxTouches (int): Maximum touches for full score
optimalWidth (float): Optimal zone width (narrower is better)
Returns: Strength score 0-100
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.