PINE LIBRARY
Cập nhật CyberVisLib

# CyberVisLib v5
CyberVisLib provides rendering and visualization utilities for multi-oscillator indicators: color blending, sub-pane management, diagnostic tables, and tooltip formatting. Pure visualization layer—no market logic.
## What it does
Delivers four capabilities: color utilities (RGB blending, diverging/sequential gradients, confidence-to-transparency), sub-pane management (vertical space allocation for multiple oscillators), diagnostic tables (key-value pairs, dynamic coloring), and tooltip formatting. Stack RSI, MACD, Stochastic in non-overlapping vertical bands.
Outputs color values, MiniSubPane structs (band coordinates), table objects, formatted strings. All stateless, rendering-focused.
## How it works
Color blending: `RGB_out = (1-t)×RGB_a + t×RGB_b`. Diverging gradients split at zero (negative→red-yellow, positive→yellow-green). Transparency: `90 - 60×confidence`.
Sub-pane management:
1. Register oscillators (MiniOscMeta)
2. Finalize layout (STACK_TOP/BOTTOM/EQUAL_SPLIT policies)
3. Map values: `pane.band_y(unit_val)` converts [0,1] to vertical coordinate
Diagnostic tables: key-value pairs, multi-column grids, conditional formatting.
## Why this is original
Only TradingView library with complete rendering toolkit. Existing libraries mix rendering with market logic.
Unique features:
- Sub-pane vertical allocation (automatic band calculation)
- Lightweight UDT variants (co-import with OscLib)
- Diverging gradients with zero-centering
- Confidence-to-transparency mapping
- Regime color enum (consistent color mapping)
Separation of concerns: VisLib (rendering), NumLib (math), SignalLib (signals).
## How to use it
```pine
//version=6
indicator("CyberVisLib Demo", overlay=false)
import cybermediaboy/CyberVisLib/5 as VL
// Diverging gradient
rsi = ta.rsi(close, 14)
z_rsi = (rsi - 50.0) / 25.0
color rsi_color = VL.f_diverging_rgyg(z_rsi)
plot(rsi, "RSI", color=rsi_color)
// Sub-pane management
var spm = VL.f_subpane_manager_new(VL.SubPanePolicy.EQUAL_SPLIT, 5.0)
if barstate.isfirst
spm.register(VL.f_meta_unipolar0100("rsi", "RSI", color.blue))
spm.register(VL.f_meta_bipolar("macd", "MACD", color.orange))
spm.finalize()
var pane_rsi = array.get(spm.panes, 0)
rsi_y = pane_rsi.band_y(pane_rsi.meta.to_unit(rsi))
plot(rsi_y, "RSI Pane", color.blue)
// Confidence transparency
conf = math.abs(rsi - 50.0) / 50.0
bgcolor(color.new(color.green, VL.f_transp(conf)))
```
## Key functions
- `f_blend()` - RGB color blending
- `f_diverging_rgyg()` - Diverging gradient (zero-centered)
- `f_transp()` - Confidence-to-transparency mapping
- `f_subpane_manager_new()` - Sub-pane allocation
- `f_regime_color()` - Regime color enum
- `f_kv_tooltip()` - Tooltip formatting
## Limitations
- Sub-pane allocation static after finalize
- RGB-only blending (no HSL/HSV)
- No automatic label/line cleanup
- Tables require manual cell updates
- Assumes `overlay=false` (separate pane indicators only)
CyberVisLib provides rendering and visualization utilities for multi-oscillator indicators: color blending, sub-pane management, diagnostic tables, and tooltip formatting. Pure visualization layer—no market logic.
## What it does
Delivers four capabilities: color utilities (RGB blending, diverging/sequential gradients, confidence-to-transparency), sub-pane management (vertical space allocation for multiple oscillators), diagnostic tables (key-value pairs, dynamic coloring), and tooltip formatting. Stack RSI, MACD, Stochastic in non-overlapping vertical bands.
Outputs color values, MiniSubPane structs (band coordinates), table objects, formatted strings. All stateless, rendering-focused.
## How it works
Color blending: `RGB_out = (1-t)×RGB_a + t×RGB_b`. Diverging gradients split at zero (negative→red-yellow, positive→yellow-green). Transparency: `90 - 60×confidence`.
Sub-pane management:
1. Register oscillators (MiniOscMeta)
2. Finalize layout (STACK_TOP/BOTTOM/EQUAL_SPLIT policies)
3. Map values: `pane.band_y(unit_val)` converts [0,1] to vertical coordinate
Diagnostic tables: key-value pairs, multi-column grids, conditional formatting.
## Why this is original
Only TradingView library with complete rendering toolkit. Existing libraries mix rendering with market logic.
Unique features:
- Sub-pane vertical allocation (automatic band calculation)
- Lightweight UDT variants (co-import with OscLib)
- Diverging gradients with zero-centering
- Confidence-to-transparency mapping
- Regime color enum (consistent color mapping)
Separation of concerns: VisLib (rendering), NumLib (math), SignalLib (signals).
## How to use it
```pine
//version=6
indicator("CyberVisLib Demo", overlay=false)
import cybermediaboy/CyberVisLib/5 as VL
// Diverging gradient
rsi = ta.rsi(close, 14)
z_rsi = (rsi - 50.0) / 25.0
color rsi_color = VL.f_diverging_rgyg(z_rsi)
plot(rsi, "RSI", color=rsi_color)
// Sub-pane management
var spm = VL.f_subpane_manager_new(VL.SubPanePolicy.EQUAL_SPLIT, 5.0)
if barstate.isfirst
spm.register(VL.f_meta_unipolar0100("rsi", "RSI", color.blue))
spm.register(VL.f_meta_bipolar("macd", "MACD", color.orange))
spm.finalize()
var pane_rsi = array.get(spm.panes, 0)
rsi_y = pane_rsi.band_y(pane_rsi.meta.to_unit(rsi))
plot(rsi_y, "RSI Pane", color.blue)
// Confidence transparency
conf = math.abs(rsi - 50.0) / 50.0
bgcolor(color.new(color.green, VL.f_transp(conf)))
```
## Key functions
- `f_blend()` - RGB color blending
- `f_diverging_rgyg()` - Diverging gradient (zero-centered)
- `f_transp()` - Confidence-to-transparency mapping
- `f_subpane_manager_new()` - Sub-pane allocation
- `f_regime_color()` - Regime color enum
- `f_kv_tooltip()` - Tooltip formatting
## Limitations
- Sub-pane allocation static after finalize
- RGB-only blending (no HSL/HSV)
- No automatic label/line cleanup
- Tables require manual cell updates
- Assumes `overlay=false` (separate pane indicators only)
Phát hành các Ghi chú
v2Added:
f_feat_importance_new(pos_str, n_feat, n_quality, n_meta, show_lower)
Create new Feature Importance Table
Parameters:
pos_str (string): position string: "top_left", "top_right", "bottom_left", "bottom_right"
n_feat (int): number of feature rows (e.g., 6 for WickID, 8 for CMD)
n_quality (int): number of quality metric rows (e.g., 3 for WickQ/EffQ/BE%, 5 for +Stop%+MedR)
n_meta (int): number of metadata rows (e.g., 4 for Mode/Rows/RowSz/Upd)
show_lower (bool): true for dual-model (U/L), false for single-model
method header(fit)
Render header row — parametric based on show_lower
Namespace types: FeatureImportanceTable
Parameters:
fit (FeatureImportanceTable)
method quality_row(fit, row_idx, name, val_u, val_l, thresholds, higher_is_better)
Render quality metric row with color-coded value — parametric
Namespace types: FeatureImportanceTable
Parameters:
fit (FeatureImportanceTable)
row_idx (int): row index (0-based, within quality section, 0..n_quality-1)
name (string): metric name (e.g., "WickQ", "EffQ")
val_u (float): upper model value (na if show_lower=false and single-model)
val_l (float): lower model value (ignored if show_lower=false)
thresholds (array<float>): array of 4 threshold values for color bands [excellent, good, fair, poor]
higher_is_better (bool): if true, higher values get better colors (lime/green)
method feature_row(fit, feat_idx, name, w_u, w_l, is_g6)
Render feature weight row — parametric
Namespace types: FeatureImportanceTable
Parameters:
fit (FeatureImportanceTable)
feat_idx (int): feature index (0-based, 0..n_feat-1)
name (string): feature name/abbreviation
w_u (float): upper model weight
w_l (float): lower model weight (ignored if show_lower=false)
is_g6 (bool): if true, invert color logic (G6: negative=good for upper)
method metadata_row(fit, meta_idx, label, val_u, val_l)
Render metadata row — parametric
Namespace types: FeatureImportanceTable
Parameters:
fit (FeatureImportanceTable)
meta_idx (int): metadata row index (0-based, 0..n_meta-1)
label (string): label text
val_u (string): upper model value
val_l (string): lower model value (na for single-value rows, ignored if show_lower=false)
method feature_row_single(fit, feat_idx, name, weight, is_g6)
Render single-model feature row (convenience wrapper for single-model indicators)
Namespace types: FeatureImportanceTable
Parameters:
fit (FeatureImportanceTable)
feat_idx (int): feature index
name (string): feature name
weight (float): model weight
is_g6 (bool): invert color logic
method quality_row_single(fit, row_idx, name, val, thresholds, higher_is_better)
Render single-model quality row (convenience wrapper)
Namespace types: FeatureImportanceTable
Parameters:
fit (FeatureImportanceTable)
row_idx (int)
name (string)
val (float)
thresholds (array<float>)
higher_is_better (bool)
FeatureImportanceTable
FeatureImportanceTable — renders feature weights with heatmap coloring
Fields:
tbl (series table): Pine Script table object
n_feat (series int): number of feature rows to display
n_quality (series int): number of quality metric rows before features
n_meta (series int): number of metadata rows after features
show_lower (series bool): if false, hides lower-model columns (single-model mode)
cols (series int): column count (2=single-model, 3=dual-model)
Phát hành các Ghi chú
v3Updated:
method quality_row(fit, row_idx, name, val_u, val_l, thresholds, higher_is_better, tooltip)
Render quality metric row with color-coded value — parametric
Namespace types: FeatureImportanceTable
Parameters:
fit (FeatureImportanceTable)
row_idx (int): row index (0-based, within quality section, 0..n_quality-1)
name (string): metric name (e.g., "WickQ", "EffQ")
val_u (float): upper model value (na if show_lower=false and single-model)
val_l (float): lower model value (ignored if show_lower=false)
thresholds (array<float>): array of 4 threshold values for color bands [excellent, good, fair, poor]
higher_is_better (bool): if true, higher values get better colors (lime/green)
tooltip (string): optional tooltip text for the row label cell (default "")
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.