PINE LIBRARY
已更新 OscLib

Library "OscLib"
OscLib — Oscillator primitives and normalization utilities.
Provides centered/clamped normalization for bounded and unbounded oscillators,
multi-oscillator dispatcher, and pivot-based divergence detection.
Architecture: L0 (no library dependencies, uses ta.* primitives only)
f_center_bounded(raw, midpoint)
Centered normalization for bounded [0,100] oscillators (RSI, MFI, Stoch, WPR)
Parameters:
raw (float): Raw oscillator value
midpoint (float): Center point (typically 50.0 for RSI/MFI/Stoch)
Returns: Centered value in [-1, 1] range
f_clamp_normalize(raw, threshold)
Clamped normalization for unbounded oscillators (CCI, MACD Hist, ATR)
Parameters:
raw (float): Raw oscillator value
threshold (float): Scaling threshold (e.g., 200 for CCI, 2*ATR for MACD)
Returns: Clamped value in [-1, 1] range
f_compute_osc(kind, src, len)
Multi-oscillator dispatcher
Parameters:
kind (string): Oscillator type: "RSI", "CCI", "MFI", "STOCH", "WPR"
src (float): Source series (typically close or hlc3)
len (simple int): Oscillator period/length
Returns: Raw oscillator value
f_divergence_pivot(osc, price, lb_left, lb_right)
Pivot-based divergence detection (matches REOS production pattern)
Parameters:
osc (float): Oscillator series
price (float): Price series (typically close)
lb_left (int): Left lookback for pivot detection
lb_right (int): Right lookback for pivot detection
Returns: [bearish_divergence, bullish_divergence]
bearish_div: price makes higher high, oscillator doesn't
bullish_div: price makes lower low, oscillator doesn't
OscLib — Oscillator primitives and normalization utilities.
Provides centered/clamped normalization for bounded and unbounded oscillators,
multi-oscillator dispatcher, and pivot-based divergence detection.
Architecture: L0 (no library dependencies, uses ta.* primitives only)
f_center_bounded(raw, midpoint)
Centered normalization for bounded [0,100] oscillators (RSI, MFI, Stoch, WPR)
Parameters:
raw (float): Raw oscillator value
midpoint (float): Center point (typically 50.0 for RSI/MFI/Stoch)
Returns: Centered value in [-1, 1] range
f_clamp_normalize(raw, threshold)
Clamped normalization for unbounded oscillators (CCI, MACD Hist, ATR)
Parameters:
raw (float): Raw oscillator value
threshold (float): Scaling threshold (e.g., 200 for CCI, 2*ATR for MACD)
Returns: Clamped value in [-1, 1] range
f_compute_osc(kind, src, len)
Multi-oscillator dispatcher
Parameters:
kind (string): Oscillator type: "RSI", "CCI", "MFI", "STOCH", "WPR"
src (float): Source series (typically close or hlc3)
len (simple int): Oscillator period/length
Returns: Raw oscillator value
f_divergence_pivot(osc, price, lb_left, lb_right)
Pivot-based divergence detection (matches REOS production pattern)
Parameters:
osc (float): Oscillator series
price (float): Price series (typically close)
lb_left (int): Left lookback for pivot detection
lb_right (int): Right lookback for pivot detection
Returns: [bearish_divergence, bullish_divergence]
bearish_div: price makes higher high, oscillator doesn't
bullish_div: price makes lower low, oscillator doesn't
發行說明
v2Added:
f_default_vis_config()
Get default visual configuration
Returns: VisConfig with sensible defaults
OscSpec
Oscillator specification (kind + behavior descriptor)
Fields:
kind (series string): Oscillator type: "RSI", "MFI", "CCI", "STOCH", "WPR", "OBV", "CVD", "Close"
source (series string): Price source: "close", "hlc3", "hl2", "ohlc4"
soft_clip (series bool): Use tanh soft-clip (true) or hard clamp (false)
debug_code (series int): Integer debug code for logging/introspection
OscReading
Oscillator reading (single bar)
Fields:
raw_value (series float): Raw oscillator value before normalization
normalized_value (series float): Z-score normalized value (soft-clipped or hard-clamped to ±6)
bar_index (series int): Bar index when reading was captured
VisConfig
Visual configuration (separate from OscSpec for serialization purity)
Fields:
line_color (series color): Plot line color
transparency (series int): Color transparency (0-100)
line_width (series int): Plot line width
display_name (series string): Human-readable name for legend
Updated:
f_compute_osc(spec, period, zscore_len, src, vol)
Compute oscillator reading from specification
Parameters:
spec (OscSpec): OscSpec defining oscillator parameters
period (simple int): Oscillator period (simple int required for ta.* functions)
zscore_len (simple int): Z-score normalization window (simple int required for ta.sma/ta.stdev)
src (float): Price source series (overrides spec.source if provided)
vol (float): Volume series (required for MFI, CVD)
Returns: OscReading with raw and normalized values
Removed:
f_center_bounded(raw, midpoint)
Centered normalization for bounded [0,100] oscillators (RSI, MFI, Stoch, WPR)
f_clamp_normalize(raw, threshold)
Clamped normalization for unbounded oscillators (CCI, MACD Hist, ATR)
f_divergence_pivot(osc, price, lb_left, lb_right)
Pivot-based divergence detection (matches REOS production pattern)
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。