Methodology — 13 methods · 40 sources
The statistics behind the scripts
Each indicator is assembled from a small number of well-documented estimators. This page states each one in its bar-by-bar form, names the known failure modes and links the references the research was built from. Notation: x[1] is the previous bar, N a lookback window, rt = ln(Ct / Ct−1). The first two methods are open to everyone; the rest are for members.
01Method
Ornstein–Uhlenbeck via AR(1)
A discrete-time Ornstein–Uhlenbeck process sampled at fixed intervals is exactly an AR(1). Estimating the lag-one coefficient b over a rolling window therefore yields the mean-reversion speed θ = −ln b, the half-life ln 2 / θ, the long-run mean μ and the stationary variance σ²e / (1 − b²). The z-score of the current observation should use that stationary standard deviation, not a rolling standard deviation of price.
The engine uses the known-mean estimator (μ = window mean, b = lag-1 autocovariance / lag-1 variance), which avoids the intercept-driven blow-up of a/(1−b) when b approaches one.
- AR(1)
xt = a + b·xt−1 + et- OU map
θ = −ln b, μ = a/(1−b), HL = ln 2/θ, σeq2 = σe2/(1−b2)- Expected path
E[xt+h] = μ + (xt − μ)·bh
Pitfalls
- θ is biased upward in finite samples; below ~250 observations μ and σ are unreliable and θ needs far more.
- Raw price is nearly a random walk (b ≈ 1); fit spreads or detrended series.
- Jumps and microstructure noise inflate θ and σ.
02Method
Dickey–Fuller unit-root test
Regress Δx on xt−1 with a constant. The coefficient γ equals b − 1 from the AR(1) fit, so the t-statistic of γ is a unit-root test that shares the OU regression. Without lag augmentation this is the plain DF test; the pack uses no lags to keep it a single OLS.
- Regression
Δxt = α + γ·xt−1 + ut, tDF = γ̂ / se(γ̂)- Std error
se(γ̂) = √( su2 / Σ(xt−1 − x̄t−1)2 )- Critical values
1%: −3.43, 5%: −2.86, 10%: −2.57 (constant, no trend, large n)
Pitfalls
- Critical values are asymptotic; rolling windows of 100–300 bars have slightly more negative true thresholds.