PINE LIBRARY
מעודכן PackLib

PackLib — a generic price-row "pack" database for footprint and flow indicators.
What it does
PackLib gives you a reusable, memory-frugal way to store and query per-price-row volume data. A BucketPack indexes buy, sell and liquidation volume by price row, where row height is set by a rowTicks parameter and mapped to the chart via syminfo.mintick. It is the data backbone for footprint, volume-profile and liquidation-heatmap style scripts.
Why it exists
Building a row-bucketed flow store inline tends to allocate fresh arrays every tick, which exhausts memory on lower timeframes. PackLib solves this with a reuse-in-place pattern: you allocate one pack and one rolling profile once, then clear-and-refill them each bar. No per-tick allocation, bounded ring buffers, and guarded loops throughout.
How to use it
1. Import the library and allocate a var BucketPack with emptyPack().
2. Each bar, size it with resetPack(minRow, maxRow, rowTicks, src) or clearPack() when out of window.
3. Fill it with accumulateOhlcv() and accumulateLiqNorm() from your lower-timeframe arrays.
4. Read features with packVA() for value area, plus liquidation-normalisation and imbalance helpers.
5. For a stationary profile across recent bars, allocate a var RollingProfile with newRollingProfile(), call update() each bar, then rollingVA().
Notes
Row math (priceToTick, tickToRow, rowMid, rowLo, rowHi, rowForPrice) is stateless and rowTicks-parameterised, so the same pack works for any symbol or timeframe. The "src" field is an opaque caller-owned tag; channel meaning (volume, liquidations, or other data) is decided by the caller, making the framework reusable beyond any single indicator.
This is a library. It exports functions only and plots nothing on its own — import it into your indicator or strategy.
What it does
PackLib gives you a reusable, memory-frugal way to store and query per-price-row volume data. A BucketPack indexes buy, sell and liquidation volume by price row, where row height is set by a rowTicks parameter and mapped to the chart via syminfo.mintick. It is the data backbone for footprint, volume-profile and liquidation-heatmap style scripts.
Why it exists
Building a row-bucketed flow store inline tends to allocate fresh arrays every tick, which exhausts memory on lower timeframes. PackLib solves this with a reuse-in-place pattern: you allocate one pack and one rolling profile once, then clear-and-refill them each bar. No per-tick allocation, bounded ring buffers, and guarded loops throughout.
How to use it
1. Import the library and allocate a var BucketPack with emptyPack().
2. Each bar, size it with resetPack(minRow, maxRow, rowTicks, src) or clearPack() when out of window.
3. Fill it with accumulateOhlcv() and accumulateLiqNorm() from your lower-timeframe arrays.
4. Read features with packVA() for value area, plus liquidation-normalisation and imbalance helpers.
5. For a stationary profile across recent bars, allocate a var RollingProfile with newRollingProfile(), call update() each bar, then rollingVA().
Notes
Row math (priceToTick, tickToRow, rowMid, rowLo, rowHi, rowForPrice) is stateless and rowTicks-parameterised, so the same pack works for any symbol or timeframe. The "src" field is an opaque caller-owned tag; channel meaning (volume, liquidations, or other data) is decided by the caller, making the framework reusable beyond any single indicator.
This is a library. It exports functions only and plots nothing on its own — import it into your indicator or strategy.
הערות שחרור
v2Added:
packLiqCluster(p, side, rowTicks, shelfThreshold)
Parameters:
p (BucketPack)
side (string)
rowTicks (int)
shelfThreshold (float)
ספריית Pine
ברוח האמיתית של TradingView, המחבר לפרסם את הקוד של Pine הזה כספרייה בקוד פתוח, כך שמתכנתים אחרים בקהילתנו יעשו שימוש חוזר. כל הכבוד למחבר! ניתן להשתמש בספרייה הזו באופן פרטי או בומים בקוד פתוח, אך השימוש בחוזר בקוד הזה בפרסומים כפוף ל-כללי הבית.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
ספריית Pine
ברוח האמיתית של TradingView, המחבר לפרסם את הקוד של Pine הזה כספרייה בקוד פתוח, כך שמתכנתים אחרים בקהילתנו יעשו שימוש חוזר. כל הכבוד למחבר! ניתן להשתמש בספרייה הזו באופן פרטי או בומים בקוד פתוח, אך השימוש בחוזר בקוד הזה בפרסומים כפוף ל-כללי הבית.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.