PINE LIBRARY
OscLibrary

Library "OscLibrary"
Non‑native oscillators & math for Pine v6: Ehlers Super Smoother & Roofing, Hilbert/homodyne period,
DSP biquads (LP/HP/BP/Notch), Goertzel power, Haar detail (wavelet‑style), robust z/Fisher, FRAMA,
Laguerre filter + Laguerre RSI, Autocorrelation Periodogram dominant period, DPO, WaveTrend‑style.
clamp(x, lo, hi)
Clamp to [lo, hi]
Parameters:
x (float)
lo (float)
hi (float)
tanh(x)
Parameters:
x (float)
f_atan2_custom(y, x)
Parameters:
y (float)
x (float)
wrap_pi(ang)
Wrap angle to (-pi, pi]
Parameters:
ang (float)
scale_minmax(x, len)
Window min‑max scale to [0, 1]
Parameters:
x (float)
len (simple int)
zscore_robust(x, len)
Robust z‑score using rolling median & MAD
z = (x - median) / (1.4826 * MAD)
Parameters:
x (float)
len (simple int)
fisher_rank(x, len)
Fisher transform of rolling percent‑rank (no simplifications)
Parameters:
x (float)
len (simple int)
ift_rsi(x, rsiLen, smoothLen)
Classic IFT of RSI
Parameters:
x (float)
rsiLen (simple int)
smoothLen (simple int)
biquad_lp(x, f0_cpb, Q)
2‑pole low‑pass
Parameters:
x (float)
f0_cpb (float)
Q (float)
biquad_hp(x, f0_cpb, Q)
2‑pole high‑pass
Parameters:
x (float)
f0_cpb (float)
Q (float)
biquad_bp(x, f0_cpb, Q)
2‑pole band‑pass (constant skirt gain)
Parameters:
x (float)
f0_cpb (float)
Q (float)
biquad_notch(x, f0_cpb, Q)
2‑pole notch
Parameters:
x (float)
f0_cpb (float)
Q (float)
ssf(x, period)
Ehlers Super Smoother (2‑pole low‑lag LP)
Parameters:
x (float)
period (simple int)
highpass_ehlers(x, cutoffPeriod)
Ehlers high‑pass (first stage of Roofing)
Parameters:
x (float)
cutoffPeriod (simple int)
roofing(x, hpCutoff, lpPeriod)
Roofing filter: HP (long‑cycle reject) → Super Smoother
Parameters:
x (float)
hpCutoff (simple int)
lpPeriod (simple int)
hilbert_quadrature(src)
Short Hilbert quadrature on a smoothed series
Parameters:
src (float)
homodyne_period(src, floorP, ceilP)
Homodyne instantaneous period (bars) with smoothing
Parameters:
src (float)
floorP (simple int)
ceilP (simple int)
sine_leadsine(src)
Sine & lead‑sine oscillator from HT phase
Parameters:
src (float)
goertzel_power(x, f0_cpb, r)
Goertzel single‑bin spectral power (forgetting r∈(0,1))
Parameters:
x (float)
f0_cpb (float)
r (float)
frama_alpha(x, length, fast, slow)
FRAMA alpha via fractal dimension (Ehlers)
Parameters:
x (float)
length (simple int)
fast (simple int)
slow (simple int)
frama(x, length, fast, slow)
FRAMA smoother (EMA with alpha from FD)
Parameters:
x (float)
length (simple int)
fast (simple int)
slow (simple int)
laguerre(x, gamma)
4‑element Laguerre filter (gamma in [0,1))
Parameters:
x (float)
gamma (float)
laguerre_rsi(x, gamma)
Laguerre RSI (bounded 0..1)
Parameters:
x (float)
gamma (float)
acf_dominant_period(x, minP, maxP, corrLen)
Dominant period from normalized autocorrelation peaks
Uses Pearson correlation as normalized ACF proxy over 'corrLen' bars.
minP/maxP bound the search range. corrLen should be >= maxP*2.
Parameters:
x (float)
minP (simple int)
maxP (simple int)
corrLen (simple int)
dpo(x, length)
Detrended Price Oscillator (centered SMA lag)
Parameters:
x (float)
length (simple int)
wavetrend(h, l, c, chLen, avgLen)
WaveTrend‑style oscillator (inputs explicit)
Parameters:
h (float)
l (float)
c (float)
chLen (simple int)
avgLen (simple int)
rescale(x, fromLo, fromHi, toLo, toHi, clip)
Rescale x from [fromLo, fromHi] to [toLo, toHi]. Handles reversed domains; optional clipping.
Parameters:
x (float)
fromLo (float)
fromHi (float)
toLo (float)
toHi (float)
clip (simple bool)
zscore_std(x, len)
Classic rolling z-score using SMA/STD (sample stdev). Guard zero-variance.
Parameters:
x (float)
len (simple int)
ema_alpha(x, alpha)
EMA with dynamic alpha ∈ [0,1]. No simplifications; stable init.
Parameters:
x (float)
alpha (float)
zlema(x, length)
Zero-Lag EMA (ZLEMA). Uses lag = round((L-1)/2) and exact 2*x - x[lag] prefilter.
Parameters:
x (float)
length (simple int)
hullma(x, length)
Hull Moving Average (HMA) with round() for half and sqrt windows per standard definition.
Parameters:
x (float)
length (simple int)
pct_change(x, len)
Relative change over len bars. Uses exact previous value (sign-preserving); guards zero.
Parameters:
x (float)
len (simple int)
normalize_by_atr(delta, atrLen)
Normalize a delta by ATR(len) → "ATR units" (volatility-normalized). Guards zero ATR.
Parameters:
delta (float)
atrLen (simple int)
smoothstep(x, edge0, edge1)
Smoothstep gate: x∈[edge0,edge1] → [0,1] with C1 continuity; robust to equal edges.
Parameters:
x (float)
edge0 (float)
edge1 (float)
biquad_lp_period(x, period_bars, Q)
Parameters:
x (float)
period_bars (float)
Q (float)
biquad_hp_period(x, period_bars, Q)
Parameters:
x (float)
period_bars (float)
Q (float)
biquad_bp_period(x, centerPeriod_bars, Q)
Parameters:
x (float)
centerPeriod_bars (float)
Q (float)
biquad_notch_period(x, centerPeriod_bars, Q)
Parameters:
x (float)
centerPeriod_bars (float)
Q (float)
biquad_bp_between(x, periodLow_bars, periodHigh_bars)
Band-pass by specifying low/high periods (pass between 1/pHigh and 1/pLow).
Computes center f0 = sqrt(fLo*fHi) and Q = f0 / BW (constant-skirt RBJ form).
Parameters:
x (float)
periodLow_bars (float)
periodHigh_bars (float)
angle_diff(a, b)
Parameters:
a (float)
b (float)
rad2deg(r)
Parameters:
r (float)
deg2rad(d)
Parameters:
d (float)
Non‑native oscillators & math for Pine v6: Ehlers Super Smoother & Roofing, Hilbert/homodyne period,
DSP biquads (LP/HP/BP/Notch), Goertzel power, Haar detail (wavelet‑style), robust z/Fisher, FRAMA,
Laguerre filter + Laguerre RSI, Autocorrelation Periodogram dominant period, DPO, WaveTrend‑style.
clamp(x, lo, hi)
Clamp to [lo, hi]
Parameters:
x (float)
lo (float)
hi (float)
tanh(x)
Parameters:
x (float)
f_atan2_custom(y, x)
Parameters:
y (float)
x (float)
wrap_pi(ang)
Wrap angle to (-pi, pi]
Parameters:
ang (float)
scale_minmax(x, len)
Window min‑max scale to [0, 1]
Parameters:
x (float)
len (simple int)
zscore_robust(x, len)
Robust z‑score using rolling median & MAD
z = (x - median) / (1.4826 * MAD)
Parameters:
x (float)
len (simple int)
fisher_rank(x, len)
Fisher transform of rolling percent‑rank (no simplifications)
Parameters:
x (float)
len (simple int)
ift_rsi(x, rsiLen, smoothLen)
Classic IFT of RSI
Parameters:
x (float)
rsiLen (simple int)
smoothLen (simple int)
biquad_lp(x, f0_cpb, Q)
2‑pole low‑pass
Parameters:
x (float)
f0_cpb (float)
Q (float)
biquad_hp(x, f0_cpb, Q)
2‑pole high‑pass
Parameters:
x (float)
f0_cpb (float)
Q (float)
biquad_bp(x, f0_cpb, Q)
2‑pole band‑pass (constant skirt gain)
Parameters:
x (float)
f0_cpb (float)
Q (float)
biquad_notch(x, f0_cpb, Q)
2‑pole notch
Parameters:
x (float)
f0_cpb (float)
Q (float)
ssf(x, period)
Ehlers Super Smoother (2‑pole low‑lag LP)
Parameters:
x (float)
period (simple int)
highpass_ehlers(x, cutoffPeriod)
Ehlers high‑pass (first stage of Roofing)
Parameters:
x (float)
cutoffPeriod (simple int)
roofing(x, hpCutoff, lpPeriod)
Roofing filter: HP (long‑cycle reject) → Super Smoother
Parameters:
x (float)
hpCutoff (simple int)
lpPeriod (simple int)
hilbert_quadrature(src)
Short Hilbert quadrature on a smoothed series
Parameters:
src (float)
homodyne_period(src, floorP, ceilP)
Homodyne instantaneous period (bars) with smoothing
Parameters:
src (float)
floorP (simple int)
ceilP (simple int)
sine_leadsine(src)
Sine & lead‑sine oscillator from HT phase
Parameters:
src (float)
goertzel_power(x, f0_cpb, r)
Goertzel single‑bin spectral power (forgetting r∈(0,1))
Parameters:
x (float)
f0_cpb (float)
r (float)
frama_alpha(x, length, fast, slow)
FRAMA alpha via fractal dimension (Ehlers)
Parameters:
x (float)
length (simple int)
fast (simple int)
slow (simple int)
frama(x, length, fast, slow)
FRAMA smoother (EMA with alpha from FD)
Parameters:
x (float)
length (simple int)
fast (simple int)
slow (simple int)
laguerre(x, gamma)
4‑element Laguerre filter (gamma in [0,1))
Parameters:
x (float)
gamma (float)
laguerre_rsi(x, gamma)
Laguerre RSI (bounded 0..1)
Parameters:
x (float)
gamma (float)
acf_dominant_period(x, minP, maxP, corrLen)
Dominant period from normalized autocorrelation peaks
Uses Pearson correlation as normalized ACF proxy over 'corrLen' bars.
minP/maxP bound the search range. corrLen should be >= maxP*2.
Parameters:
x (float)
minP (simple int)
maxP (simple int)
corrLen (simple int)
dpo(x, length)
Detrended Price Oscillator (centered SMA lag)
Parameters:
x (float)
length (simple int)
wavetrend(h, l, c, chLen, avgLen)
WaveTrend‑style oscillator (inputs explicit)
Parameters:
h (float)
l (float)
c (float)
chLen (simple int)
avgLen (simple int)
rescale(x, fromLo, fromHi, toLo, toHi, clip)
Rescale x from [fromLo, fromHi] to [toLo, toHi]. Handles reversed domains; optional clipping.
Parameters:
x (float)
fromLo (float)
fromHi (float)
toLo (float)
toHi (float)
clip (simple bool)
zscore_std(x, len)
Classic rolling z-score using SMA/STD (sample stdev). Guard zero-variance.
Parameters:
x (float)
len (simple int)
ema_alpha(x, alpha)
EMA with dynamic alpha ∈ [0,1]. No simplifications; stable init.
Parameters:
x (float)
alpha (float)
zlema(x, length)
Zero-Lag EMA (ZLEMA). Uses lag = round((L-1)/2) and exact 2*x - x[lag] prefilter.
Parameters:
x (float)
length (simple int)
hullma(x, length)
Hull Moving Average (HMA) with round() for half and sqrt windows per standard definition.
Parameters:
x (float)
length (simple int)
pct_change(x, len)
Relative change over len bars. Uses exact previous value (sign-preserving); guards zero.
Parameters:
x (float)
len (simple int)
normalize_by_atr(delta, atrLen)
Normalize a delta by ATR(len) → "ATR units" (volatility-normalized). Guards zero ATR.
Parameters:
delta (float)
atrLen (simple int)
smoothstep(x, edge0, edge1)
Smoothstep gate: x∈[edge0,edge1] → [0,1] with C1 continuity; robust to equal edges.
Parameters:
x (float)
edge0 (float)
edge1 (float)
biquad_lp_period(x, period_bars, Q)
Parameters:
x (float)
period_bars (float)
Q (float)
biquad_hp_period(x, period_bars, Q)
Parameters:
x (float)
period_bars (float)
Q (float)
biquad_bp_period(x, centerPeriod_bars, Q)
Parameters:
x (float)
centerPeriod_bars (float)
Q (float)
biquad_notch_period(x, centerPeriod_bars, Q)
Parameters:
x (float)
centerPeriod_bars (float)
Q (float)
biquad_bp_between(x, periodLow_bars, periodHigh_bars)
Band-pass by specifying low/high periods (pass between 1/pHigh and 1/pLow).
Computes center f0 = sqrt(fLo*fHi) and Q = f0 / BW (constant-skirt RBJ form).
Parameters:
x (float)
periodLow_bars (float)
periodHigh_bars (float)
angle_diff(a, b)
Parameters:
a (float)
b (float)
rad2deg(r)
Parameters:
r (float)
deg2rad(d)
Parameters:
d (float)
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
파인 라이브러리
진정한 트레이딩뷰 정신에 따라 작성자는 이 파인 코드를 오픈 소스 라이브러리로 공개하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 건배! 이 라이브러리는 개인적으로 또는 다른 오픈 소스 출판물에서 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰의 적용을 받습니다.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.