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)
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.