PINE LIBRARY
Atualizado

CyberVisLib

133
# 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)
Notas de Lançamento
v2

Added:
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)
Notas de Lançamento
v3

Updated:
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 "")

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.