PINE LIBRARY
Cập nhật 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.
Phát hành các Ghi chú
v2Added:
packLiqCluster(p, side, rowTicks, shelfThreshold)
Parameters:
p (BucketPack)
side (string)
rowTicks (int)
shelfThreshold (float)
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.