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
Release Note
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)
ไลบรารีไพน์
ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนได้เผยแพร่ Pine code นี้เป็นโอเพนซอร์สไลบรารีเพื่อให้ Pine โปรแกรมเมอร์คนอื่นในชุมชนของเราสามารถนำไปใช้ซ้ำได้ ต้องขอบคุณผู้เขียน! คุณสามารถใช้ไลบรารีนี้ในแบบส่วนตัวหรือในการเผยแพร่แบบโอเพนซอร์สอื่น ๆ แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
ไลบรารีไพน์
ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนได้เผยแพร่ Pine code นี้เป็นโอเพนซอร์สไลบรารีเพื่อให้ Pine โปรแกรมเมอร์คนอื่นในชุมชนของเราสามารถนำไปใช้ซ้ำได้ ต้องขอบคุณผู้เขียน! คุณสามารถใช้ไลบรารีนี้ในแบบส่วนตัวหรือในการเผยแพร่แบบโอเพนซอร์สอื่น ๆ แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน