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)
Thư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Thư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.