PINE LIBRARY
PubLibPivot

Library "PubLibPivot"
Pivot detection library for harmonic pattern analysis - Fractal and ZigZag methods with validation and utility functions
fractalPivotHigh(depth)
Fractal pivot high condition
Parameters:
depth (int)
Returns: bool
fractalPivotLow(depth)
Fractal pivot low condition
Parameters:
depth (int)
Returns: bool
fractalPivotHighPrice(depth, occurrence)
Get fractal pivot high price
Parameters:
depth (int)
occurrence (simple int)
Returns: float
fractalPivotLowPrice(depth, occurrence)
Get fractal pivot low price
Parameters:
depth (int)
occurrence (simple int)
Returns: float
fractalPivotHighBarIndex(depth, occurrence)
Get fractal pivot high bar index
Parameters:
depth (int)
occurrence (simple int)
Returns: int
fractalPivotLowBarIndex(depth, occurrence)
Get fractal pivot low bar index
Parameters:
depth (int)
occurrence (simple int)
Returns: int
zigzagPivotHigh(deviation, backstep, useATR, atrLength)
ZigZag pivot high condition
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
Returns: bool
zigzagPivotLow(deviation, backstep, useATR, atrLength)
ZigZag pivot low condition
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
Returns: bool
zigzagPivotHighPrice(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot high price
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: float
zigzagPivotLowPrice(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot low price
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: float
zigzagPivotHighBarIndex(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot high bar index
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: int
zigzagPivotLowBarIndex(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot low bar index
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: int
isValidPivotVolume(pivotPrice, pivotBarIndex, minVolumeRatio, volumeLength)
Validate pivot quality based on volume
Parameters:
pivotPrice (float)
pivotBarIndex (int)
minVolumeRatio (float)
volumeLength (int)
Returns: bool
isValidPivotATR(pivotPrice, lastPivotPrice, minATRMultiplier, atrLength)
Validate pivot based on minimum ATR movement
Parameters:
pivotPrice (float)
lastPivotPrice (float)
minATRMultiplier (float)
atrLength (simple int)
Returns: bool
isValidPivotTime(pivotBarIndex, lastPivotBarIndex, minBars)
Validate pivot based on minimum time between pivots
Parameters:
pivotBarIndex (int)
lastPivotBarIndex (int)
minBars (int)
Returns: bool
isPivotConfirmed(pivotBarIndex, depth)
Check if pivot is not repainting (confirmed)
Parameters:
pivotBarIndex (int)
depth (int)
Returns: bool
addPivotToArray(pivotArray, barArray, pivotPrice, pivotBarIndex, maxSize)
Add pivot to array with validation
Parameters:
pivotArray (array<float>)
barArray (array<int>)
pivotPrice (float)
pivotBarIndex (int)
maxSize (int)
Returns: array<float> - updated pivot array
getPivotFromArray(pivotArray, barArray, index)
Get pivot from array by index
Parameters:
pivotArray (array<float>)
barArray (array<int>)
index (int)
Returns: tuple<float, int> - (price, bar_index)
getPivotsInRange(pivotArray, barArray, startIndex, count)
Get all pivots in range
Parameters:
pivotArray (array<float>)
barArray (array<int>)
startIndex (int)
count (int)
Returns: tuple<array<float>, array<int>> - (prices, bar_indices)
pivotDistance(barIndex1, barIndex2)
Calculate distance between two pivots in bars
Parameters:
barIndex1 (int)
barIndex2 (int)
Returns: int - distance in bars
pivotPriceRatio(price1, price2)
Calculate price ratio between two pivots
Parameters:
price1 (float)
price2 (float)
Returns: float - price ratio
pivotRetracementRatio(startPrice, endPrice, currentPrice)
Calculate retracement ratio
Parameters:
startPrice (float)
endPrice (float)
currentPrice (float)
Returns: float - retracement ratio (0-1)
pivotExtensionRatio(startPrice, endPrice, currentPrice)
Calculate extension ratio
Parameters:
startPrice (float)
endPrice (float)
currentPrice (float)
Returns: float - extension ratio (>1 for extension)
isInFibZone(startPrice, endPrice, currentPrice, fibLevel, tolerance)
Check if price is in Fibonacci retracement zone
Parameters:
startPrice (float)
endPrice (float)
currentPrice (float)
fibLevel (float)
tolerance (float)
Returns: bool - true if in zone
getPivotType(pivotPrice, pivotBarIndex, lookback)
Get pivot type (high/low) based on surrounding prices
Parameters:
pivotPrice (float)
pivotBarIndex (int)
lookback (int)
Returns: string - "high", "low", or "unknown"
calculatePivotStrength(pivotPrice, pivotBarIndex, lookback)
Calculate pivot strength based on volume and price action
Parameters:
pivotPrice (float)
pivotBarIndex (int)
lookback (int)
Returns: float - strength score (0-100)
Pivot detection library for harmonic pattern analysis - Fractal and ZigZag methods with validation and utility functions
fractalPivotHigh(depth)
Fractal pivot high condition
Parameters:
depth (int)
Returns: bool
fractalPivotLow(depth)
Fractal pivot low condition
Parameters:
depth (int)
Returns: bool
fractalPivotHighPrice(depth, occurrence)
Get fractal pivot high price
Parameters:
depth (int)
occurrence (simple int)
Returns: float
fractalPivotLowPrice(depth, occurrence)
Get fractal pivot low price
Parameters:
depth (int)
occurrence (simple int)
Returns: float
fractalPivotHighBarIndex(depth, occurrence)
Get fractal pivot high bar index
Parameters:
depth (int)
occurrence (simple int)
Returns: int
fractalPivotLowBarIndex(depth, occurrence)
Get fractal pivot low bar index
Parameters:
depth (int)
occurrence (simple int)
Returns: int
zigzagPivotHigh(deviation, backstep, useATR, atrLength)
ZigZag pivot high condition
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
Returns: bool
zigzagPivotLow(deviation, backstep, useATR, atrLength)
ZigZag pivot low condition
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
Returns: bool
zigzagPivotHighPrice(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot high price
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: float
zigzagPivotLowPrice(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot low price
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: float
zigzagPivotHighBarIndex(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot high bar index
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: int
zigzagPivotLowBarIndex(deviation, backstep, useATR, atrLength, occurrence)
Get ZigZag pivot low bar index
Parameters:
deviation (float)
backstep (int)
useATR (bool)
atrLength (simple int)
occurrence (simple int)
Returns: int
isValidPivotVolume(pivotPrice, pivotBarIndex, minVolumeRatio, volumeLength)
Validate pivot quality based on volume
Parameters:
pivotPrice (float)
pivotBarIndex (int)
minVolumeRatio (float)
volumeLength (int)
Returns: bool
isValidPivotATR(pivotPrice, lastPivotPrice, minATRMultiplier, atrLength)
Validate pivot based on minimum ATR movement
Parameters:
pivotPrice (float)
lastPivotPrice (float)
minATRMultiplier (float)
atrLength (simple int)
Returns: bool
isValidPivotTime(pivotBarIndex, lastPivotBarIndex, minBars)
Validate pivot based on minimum time between pivots
Parameters:
pivotBarIndex (int)
lastPivotBarIndex (int)
minBars (int)
Returns: bool
isPivotConfirmed(pivotBarIndex, depth)
Check if pivot is not repainting (confirmed)
Parameters:
pivotBarIndex (int)
depth (int)
Returns: bool
addPivotToArray(pivotArray, barArray, pivotPrice, pivotBarIndex, maxSize)
Add pivot to array with validation
Parameters:
pivotArray (array<float>)
barArray (array<int>)
pivotPrice (float)
pivotBarIndex (int)
maxSize (int)
Returns: array<float> - updated pivot array
getPivotFromArray(pivotArray, barArray, index)
Get pivot from array by index
Parameters:
pivotArray (array<float>)
barArray (array<int>)
index (int)
Returns: tuple<float, int> - (price, bar_index)
getPivotsInRange(pivotArray, barArray, startIndex, count)
Get all pivots in range
Parameters:
pivotArray (array<float>)
barArray (array<int>)
startIndex (int)
count (int)
Returns: tuple<array<float>, array<int>> - (prices, bar_indices)
pivotDistance(barIndex1, barIndex2)
Calculate distance between two pivots in bars
Parameters:
barIndex1 (int)
barIndex2 (int)
Returns: int - distance in bars
pivotPriceRatio(price1, price2)
Calculate price ratio between two pivots
Parameters:
price1 (float)
price2 (float)
Returns: float - price ratio
pivotRetracementRatio(startPrice, endPrice, currentPrice)
Calculate retracement ratio
Parameters:
startPrice (float)
endPrice (float)
currentPrice (float)
Returns: float - retracement ratio (0-1)
pivotExtensionRatio(startPrice, endPrice, currentPrice)
Calculate extension ratio
Parameters:
startPrice (float)
endPrice (float)
currentPrice (float)
Returns: float - extension ratio (>1 for extension)
isInFibZone(startPrice, endPrice, currentPrice, fibLevel, tolerance)
Check if price is in Fibonacci retracement zone
Parameters:
startPrice (float)
endPrice (float)
currentPrice (float)
fibLevel (float)
tolerance (float)
Returns: bool - true if in zone
getPivotType(pivotPrice, pivotBarIndex, lookback)
Get pivot type (high/low) based on surrounding prices
Parameters:
pivotPrice (float)
pivotBarIndex (int)
lookback (int)
Returns: string - "high", "low", or "unknown"
calculatePivotStrength(pivotPrice, pivotBarIndex, lookback)
Calculate pivot strength based on volume and price action
Parameters:
pivotPrice (float)
pivotBarIndex (int)
lookback (int)
Returns: float - strength score (0-100)
Biblioteka Pine
W duchu TradingView autor opublikował ten kod Pine jako bibliotekę open-source, aby inni programiści Pine z naszej społeczności mogli go ponownie wykorzystać. Brawa dla autora! Możesz używać tej biblioteki prywatnie lub w innych publikacjach open-source, ale ponowne wykorzystanie tego kodu w publikacjach podlega Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Biblioteka Pine
W duchu TradingView autor opublikował ten kod Pine jako bibliotekę open-source, aby inni programiści Pine z naszej społeczności mogli go ponownie wykorzystać. Brawa dla autora! Możesz używać tej biblioteki prywatnie lub w innych publikacjach open-source, ale ponowne wykorzystanie tego kodu w publikacjach podlega Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.