PINE LIBRARY
Güncellendi Volume Profile Library [1CG]

Volume Profile Library
A high-performance fixed range volume profile engine bundled with an embedded renderer. This library handles volume accumulation, core analytics (Point of Control and Value Area), and complex visual rendering natively. It features robust box and polyline display modes, handles absolute and recurring time ranges, and accepts lower-timeframe intrabar arrays to construct highly accurate volume profiles.
Supported Configurations (As Seen in Example)
By wrapping the engine in your own script, you can expose a wide array of configurations to the user. The library natively supports processing all of the following parameters:
How to Use Correctly
To use this library effectively, the consuming indicator or strategy must handle three critical tasks:
Example Integration
Pine Script®
Important Notes
A high-performance fixed range volume profile engine bundled with an embedded renderer. This library handles volume accumulation, core analytics (Point of Control and Value Area), and complex visual rendering natively. It features robust box and polyline display modes, handles absolute and recurring time ranges, and accepts lower-timeframe intrabar arrays to construct highly accurate volume profiles.
Supported Configurations (As Seen in Example)
By wrapping the engine in your own script, you can expose a wide array of configurations to the user. The library natively supports processing all of the following parameters:
- Time zone & Range Modes: Support for 'From Time' (single anchored profile), 'Between Times', 'Daily Anchor' (recurring at a specific time), and 'Daily Session' (recurring inside a specific session).
- Profile Fidelity: Configure the number of price rows (up to 49), define the Value Area percentage, and optionally split each row into estimated buy/sell volumes based on intrabar close locations.
- Visual Modes: Choose between traditional 'Boxes' (stacked volume rows), 'Polylines' (straight connective bands), and 'Curved Polylines', or disable all drawings while calculations continue.
- Appearance & Gradients: Natively handles coloring for bull/bear/total volume, fading volume out outside the Value Area, rendering gradient color bands within polylines, and highlighting the Range Box and Point of Control (POC) line/label.
- History Retention: Retain multiple historical recurring profiles on the chart at once without constantly recalculating them.
How to Use Correctly
To use this library effectively, the consuming indicator or strategy must handle three critical tasks:
- Declare Engine State: Create a persistent state instance using `var profileState = VP.createState()`. The engine requires this state to manage arrays, recycle drawings, and persist historical sessions across bars.
- Allocate Limits: Because the library manages drawing native Pine boxes, lines, and polylines, your main script must provide it with a large enough budget. You must add these limits to your `indicator()` or `strategy()` declaration (e.g., `max_boxes_count = 500`, `max_polylines_count = 100`).
- Fetch Intrabar Data: Pine Script restricts `request.security_lower_tf()` inside loops and libraries. You must fetch these arrays (High, Low, Close, Volume) at the global scope of your consumer script and pass them directly into `VP.update()`.
Example Integration
Important Notes
- Bars without lower-timeframe coverage will automatically fall back to the chart bar's data during accumulation.
- Ensure you guard against missing volume in your main script (e.g., `if not na(volume)`), as the engine strictly requires volume data to function.
Sürüm Notları
v2Small fix for function return values.
Sürüm Notları
v3Update - Expanded Rendering and Session Management
This update extends the original engine while preserving the same state-driven integration pattern. The library now manages a broader visual system, exposes more retained statistics, and resolves Pine drawing limits automatically for recurring profiles.
What Changed
- Expanded profile rendering: Box, straight-polyline, and curved-polyline displays now share the same row calculation. Polyline regions support None, Solid, and Gradient fill modes.
- Adaptive gradient allocation: Gradient fills automatically use between three and eight ribbons per region. The engine reduces the ribbon count before reducing the number of fully drawn sessions.
- Independent level visuals: Point of Control, Value Area High, and Value Area Low lines now have independent visibility, style, width, color, and label controls.
- One-session level extension: Completed recurring-session levels can extend through the following session. The newest completed session follows the current bar until its successor is available.
- Budget-aware history: The requested history count can exceed the number of row profiles that fit Pine's drawing limits. Fully drawn sessions are retained first; remaining sessions keep their requested range box and level drawings.
- Range-box priority: When range boxes are enabled, the engine reserves one for every represented session before allocating boxes to row profiles.
- Retained diagnostics: ProfileState now exposes the resolved full-history count, lower-tier history count, fill-band count, latest bar count, and latest total volume.
- Memory cleanup: Source-entry arrays are released when a profile completes, and row arrays are released when a session leaves the fully drawn tier.
Updated Integration Requirements
- Use the current library import and continue storing ProfileState and ProfileConfig with var.
- Pass fixed input.time timestamps directly. The timezone config applies to recurring anchors, recurring sessions, and level-label dates.
- Declare max_boxes_count = 500, max_polylines_count = 100, max_lines_count = 500, and max_labels_count = 500 in the consuming script.
- Continue fetching lower-timeframe High, Low, Close, and Volume arrays in the consumer. Missing intrabar coverage falls back to chart-bar data.
- Use PolylineFill.None, PolylineFill.Solid, or PolylineFill.Gradient through ProfileConfig.polylineFill instead of manually selecting a gradient-band count.
Current Integration Shape
Sürüm Notları
v4Update - Extended Row Limit, POC Volume Metrics, Custom Label Prefixes & Formats
This update expands the library's row capacity, adds POC volume calculations and programmatic access, and introduces customizable level label prefixes and date formats.
What Changed
- Increased Row Capacity: `MAX_ROW_COUNT` is now `200`, offering significantly higher price resolution for single and fixed profiles.
- POC Buy & Sell Volume Analytics: The engine now calculates `pocVolume`, `pocBuyVolume`, and `pocSellVolume` on every profile and retains them across session gaps.
- Programmatic POC Volume Access: Added `VP.getMostRecentPocVolumes(ProfileState)` returning `[totalVolume, buyVolume, sellVolume]` for easy consumption in external scripts, Data Window plots, and debug tables.
- Custom Label Prefixes & Date Visibility: `ProfileStyle` now includes configurable prefixes (`pocLabelPrefix`, `vahLabelPrefix`, `valLabelPrefix`) and individual date toggles (`showPocDate`, `showValueAreaDate`).
- Flexible Date Formatting: Added exported `DateFormat` enum supporting `DayMonth` (e.g. Mon Aug 31), `FullDay` (Monday), `ShortDay` (Mon), `DayMonthNum` (31/08), `MonthDayNum` (08/31), and `IsoDate` (2026-08-31).
- Customizable Drawing Budgets: Added `maxBoxBudget` and `maxPolylineBudget` to `ProfileConfig`, allowing consumer indicators and strategies sharing chart resources to specify custom drawing limits.
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazarı tebrik ederiz! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun yayınlarda yeniden kullanılması Topluluk Kuralları tarafından yönetilir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazarı tebrik ederiz! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun yayınlarda yeniden kullanılması Topluluk Kuralları tarafından yönetilir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.