PINE LIBRARY
Atualizado 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.
Notas de Lançamento
v2Added:
packLiqCluster(p, side, rowTicks, shelfThreshold)
Parameters:
p (BucketPack)
side (string)
rowTicks (int)
shelfThreshold (float)
Biblioteca do Pine
Em verdadeiro espírito TradingView, o autor publicou este código Pine como uma biblioteca de código aberto para que outros programadores Pine da nossa comunidade possam reutilizá-lo. Parabéns ao autor! Você pode usar esta biblioteca de forma privada ou em outras publicações de código aberto, mas a reutilização deste código em publicações é regida pelas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Biblioteca do Pine
Em verdadeiro espírito TradingView, o autor publicou este código Pine como uma biblioteca de código aberto para que outros programadores Pine da nossa comunidade possam reutilizá-lo. Parabéns ao autor! Você pode usar esta biblioteca de forma privada ou em outras publicações de código aberto, mas a reutilização deste código em publicações é regida pelas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.