Merge branch 'dev'

This commit is contained in:
Miha Kralj
2026-03-13 13:47:10 -07:00
404 changed files with 2754 additions and 1763 deletions
+1 -3
View File
@@ -14,8 +14,6 @@
- ACCEL measures the rate of change of velocity—the acceleration of a time series.
- No configurable parameters; computation is stateless per bar.
- Output range: Varies (see docs).
- Requires `3` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
ACCEL measures the rate of change of velocity—the acceleration of a time series. As the second derivative, it reveals momentum shifts before they manifest in price direction. Positive acceleration means velocity is increasing (trend strengthening); negative means velocity is decreasing (trend weakening). This O(1) streaming implementation uses FMA optimization and SIMD batch processing.
@@ -187,4 +185,4 @@ ACCEL is a fundamental operation. Validation confirms exact match with manual ca
- Newton, Isaac. (1687). "Philosophiæ Naturalis Principia Mathematica."
- Numerical Methods: Finite Difference Approximations.
- Murphy, John J. (1999). "Technical Analysis of the Financial Markets."
- Murphy, John J. (1999). "Technical Analysis of the Financial Markets."
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [betadist.pine](betadist.pine) |
- BETADIST computes the cumulative distribution function of the Beta distribution applied to a min-max normalized price series.
- Parameterized by `period` (default 50), `alpha` (default 2.0), `beta` (default 2.0).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Beta distribution; models bounded random variables. Used for win-rate analysis and position sizing.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
BETADIST computes the cumulative distribution function of the Beta distribution applied to a min-max normalized price series. The source price is first normalized to $[0, 1]$ over a lookback window, then passed through the regularized incomplete beta function $I_x(\alpha, \beta)$ to produce a probability-mapped oscillator. The two shape parameters $\alpha$ and $\beta$ control the nonlinear mapping: symmetric parameters ($\alpha = \beta$) produce a sigmoid-like transformation centered at 0.5, while asymmetric parameters skew the mapping to emphasize extremes in either direction.
@@ -92,4 +90,4 @@ Transcendental math blocks SIMD. Batch is a simple scalar loop. For large datase
- Abramowitz, M. & Stegun, I. (1964). *Handbook of Mathematical Functions*, Chapter 26
- Press, W. et al. (2007). *Numerical Recipes*, 3rd ed. Cambridge, §6.4 (Incomplete Beta Function)
- PineScript reference: [`betadist.pine`](betadist.pine)
- PineScript reference: [`betadist.pine`](betadist.pine)
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [binomdist.pine](binomdist.pine) |
- BINOMDIST computes the cumulative distribution function of the Binomial distribution, mapping a min-max normalized price to a success probability $...
- Parameterized by `period` (default 50), `trials` (default 20), `threshold` (default 10).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Binomial distribution; models success/failure sequences. Win streak probability in trading.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
BINOMDIST computes the cumulative distribution function of the Binomial distribution, mapping a min-max normalized price to a success probability $p$ and evaluating $P(X \leq k)$ for $X \sim \text{Binomial}(n, p)$. The normalized price position within its lookback range determines the probability of success per trial, while the trial count $n$ and threshold $k$ control the shape of the CDF response. The output is a $[0, 1]$ bounded oscillator where values near 0 indicate the price-derived probability makes $k$ or fewer successes very unlikely (bullish pressure), and values near 1 indicate $k$ successes are very likely (established range).
@@ -86,4 +84,4 @@ PMF batch can use SVML exp vectorization. CDF must remain scalar.
- Bernoulli, J. (1713). *Ars Conjectandi*
- Press, W. et al. (2007). *Numerical Recipes*, 3rd ed., §6.2 (Incomplete Beta as alternative)
- PineScript reference: [`binomdist.pine`](binomdist.pine)
- PineScript reference: [`binomdist.pine`](binomdist.pine)
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [change.pine](change.pine) |
- CHANGE calculates the percentage change between the current value and a value N periods ago.
- Parameterized by `period` (default 1).
- Output range: Varies (see docs).
- Requires `period + 1` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Simple price change (difference); foundation for momentum and rate-of-change calculations.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
CHANGE calculates the percentage change between the current value and a value N periods ago. This fundamental indicator forms the basis for momentum analysis, rate of change calculations, and relative performance comparisons.
@@ -92,4 +90,4 @@ var smaChange = new Change(new Sma(20), 5);
## References
- Murphy, J. (1999). "Technical Analysis of the Financial Markets." New York Institute of Finance.
- Pring, M. (2002). "Technical Analysis Explained." McGraw-Hill.
- Pring, M. (2002). "Technical Analysis Explained." McGraw-Hill.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [cwt.pine](cwt.pine) |
- CWT computes the magnitude of the Continuous Wavelet Transform at a specified scale using the Morlet wavelet, providing a time-frequency decomposit...
- Parameterized by `scale` (default 10.0), `omega0` (default 6.0).
- Output range: Varies (see docs).
- Requires windowSize (2K+1) bars of warmup before first valid output (IsHot = true), where K = round(3 × scale).
- **Similar:** [DWT](../dwt/Dwt.md), [FFT](../fft/Fft.md) | **Trading note:** Continuous Wavelet Transform; multi-resolution time-frequency analysis for cycle detection.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
CWT computes the magnitude of the Continuous Wavelet Transform at a specified scale using the Morlet wavelet, providing a time-frequency decomposition that measures the energy content of a specific frequency band at each point in time. Unlike Fourier analysis which loses time localization, the wavelet transform maintains both time and frequency information simultaneously. The output is a non-negative magnitude series where peaks indicate strong presence of the target frequency (determined by the scale parameter) and troughs indicate absence of that frequency component.
@@ -97,4 +95,4 @@ Strong SIMD candidate for batch: inner products are FMA-vectorizable. AVX2 proce
- Morlet, J. et al. (1982). "Wave propagation and sampling theory." *Geophysics*, 47(2): 203-236
- Torrence, C. & Compo, G.P. (1998). "A Practical Guide to Wavelet Analysis." *Bulletin of the American Meteorological Society*
- PineScript reference: [`cwt.pine`](cwt.pine)
- PineScript reference: [`cwt.pine`](cwt.pine)
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [decay.pine](decay.pine) |
- DECAY (Linear Decay) tracks the maximum of the current input and the previous output minus a fixed absolute step of `1/period`.
- Parameterized by `period` (default 5).
- Output range: Same as input — this is an overlay indicator.
- Requires `1` bar of warmup before first valid output (IsHot = true).
- **Similar:** [EDecay](../edecay/Edecay.md) | **Trading note:** Linear decay function; models signal fading over time. Used for recency-weighted calculations.
- Validated against Tulip Indicators `ti_decay` reference algorithm.
DECAY implements the Tulip Indicators `ti_decay` function. When price is above the decayed level, output snaps to price. When price falls below, the output decays linearly at a rate of `1/period` per bar, creating a ceiling that gradually descends. This produces a one-sided envelope that hugs price from above.
@@ -149,4 +147,4 @@ reaching zero after $k = v \cdot p$ bars (assuming $v > 0$).
## References
- Tulip Indicators Library: https://tulipindicators.org/decay
- Kegel, L. "Tulip Indicators" — Open-source C library of technical indicators.
- Kegel, L. "Tulip Indicators" — Open-source C library of technical indicators.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [dwt.pine](dwt.pine) |
- The Discrete Wavelet Transform decomposes a price series into multi-resolution frequency components using the a trous (with holes) stationary Haar ...
- Parameterized by `levels` (default 4), `output` (default 0).
- Output range: Varies (see docs).
- Requires `bufferSize` bars of warmup before first valid output (IsHot = true).
- **Similar:** [CWT](../cwt/Cwt.md), [FFT](../fft/Fft.md) | **Trading note:** Discrete Wavelet Transform; decomposes signal into frequency bands at different scales.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Discrete Wavelet Transform decomposes a price series into multi-resolution frequency components using the a trous (with holes) stationary Haar wavelet. Unlike decimated DWT, the stationary variant preserves time alignment at every scale, producing an approximation (trend) and detail coefficients (noise/cycles) at each decomposition level. Each level doubles the effective receptive field: level $L$ captures structure at $2^L$ bars. With 1-8 levels and $O(L)$ per-bar cost, DWT provides a complete multi-scale decomposition that cleanly separates trend from noise without the phase distortion inherent in moving-average cascades.
@@ -111,4 +109,4 @@ First decomposition level fully SIMD. Deeper levels become too small for effecti
- Daubechies, I. "Ten Lectures on Wavelets." SIAM, 1992.
- Holschneider, M. et al. "A Real-Time Algorithm for Signal Analysis with the Help of the Wavelet Transform." Wavelets: Time-Frequency Methods and Phase Space, 1989.
- Percival, D. & Walden, A. "Wavelet Methods for Time Series Analysis." Cambridge University Press, 2000.
- Gencay, R., Selcuk, F. & Whitcher, B. "An Introduction to Wavelets and Other Filtering Methods in Finance and Economics." Academic Press, 2002.
- Gencay, R., Selcuk, F. & Whitcher, B. "An Introduction to Wavelets and Other Filtering Methods in Finance and Economics." Academic Press, 2002.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [edecay.pine](edecay.pine) |
- EDECAY (Exponential Decay) tracks the maximum of the current input and the previous output multiplied by a decay factor of `(period-1)/period`.
- Parameterized by `period` (default 5).
- Output range: Same as input — this is an overlay indicator.
- Requires `1` bar of warmup before first valid output (IsHot = true).
- **Similar:** [Decay](../decay/Decay.md) | **Trading note:** Exponential decay; faster initial fading than linear. Natural half-life model for signal importance.
- Validated against Tulip Indicators `ti_edecay` reference algorithm.
EDECAY implements the exponential decaying function. When price is above the decayed level, output snaps to price. When price falls below, the output decays exponentially by multiplying by `(period-1)/period` per bar, creating a ceiling that gradually descends. Unlike linear DECAY which subtracts a fixed amount, EDECAY's multiplicative factor produces a proportional decay rate.
@@ -161,4 +159,4 @@ The output asymptotically approaches zero but never reaches it ($v > 0$).
## References
- Tulip Indicators Library: https://tulipindicators.org/edecay
- Kegel, L. "Tulip Indicators" — Open-source C library of technical indicators.
- Kegel, L. "Tulip Indicators" — Open-source C library of technical indicators.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [expdist.pine](expdist.pine) |
- The Exponential Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the exponential distribution, p...
- Parameterized by `period` (default 50), `lambda` (default 3.0).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Exponential distribution; models time between events. Used for trade arrival rate analysis.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Exponential Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the exponential distribution, producing an output in $[0, 1]$. The exponential distribution models memoryless waiting times: the probability that a normalized value falls below a threshold depends only on the rate parameter $\lambda$, not on any history. Higher $\lambda$ values compress the CDF curve toward zero, making the indicator more sensitive to small normalized deviations. With $O(N)$ normalization and $O(1)$ CDF evaluation, EXPDIST provides a nonlinear percentile ranking that emphasizes the lower end of the price range while compressing the upper end.
@@ -114,4 +112,4 @@ With SVML exp: 4 outputs per AVX2 cycle. Without SVML: scalar loop but still O(1
- Erlang, A.K. "The Theory of Probabilities and Telephone Conversations." Nyt Tidsskrift for Matematik B, 1909.
- Johnson, N.L., Kotz, S. & Balakrishnan, N. "Continuous Univariate Distributions, Vol. 1." Wiley, 1994.
- Ross, S. "Introduction to Probability Models." Academic Press, 12th edition, 2019.
- Cont, R. "Empirical Properties of Asset Returns: Stylized Facts and Statistical Issues." Quantitative Finance, 2001.
- Cont, R. "Empirical Properties of Asset Returns: Stylized Facts and Statistical Issues." Quantitative Finance, 2001.
+1 -3
View File
@@ -14,8 +14,6 @@
- The Exponential (EXP) transformer applies the natural exponential function $e^x$ to each value in a time series.
- No configurable parameters; computation is stateless per bar.
- Output range: Varies (see docs).
- Requires `0` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Exponential (EXP) transformer applies the natural exponential function $e^x$ to each value in a time series. As the inverse of the natural logarithm, it converts additive relationships back to multiplicative ones, making it essential for reconstructing price levels from log-returns and implementing models that assume log-normal distributions.
@@ -197,4 +195,4 @@ var recovered = exp.Update(logPrice); // ≈ 150.0
- Euler, L. (1748). *Introductio in analysin infinitorum*.
- Maor, E. (1994). *e: The Story of a Number*. Princeton University Press.
- Hull, J. (2018). *Options, Futures, and Other Derivatives*. Pearson. (Black-Scholes applications)
- Hull, J. (2018). *Options, Futures, and Other Derivatives*. Pearson. (Black-Scholes applications)
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [fdist.pine](fdist.pine) |
- The F-Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the F-distribution (Fisher-Snedecor distr...
- Parameterized by `d1` (default 1), `d2` (default 1), `period` (default 14).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** F-distribution; used in ANOVA and regression significance tests. Compares model variances.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The F-Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the F-distribution (Fisher-Snedecor distribution), producing an output in $[0, 1]$. The F-distribution arises as the ratio of two chi-squared random variables divided by their respective degrees of freedom, making it the natural distribution for variance ratio tests. By mapping normalized price through the regularized incomplete beta function with parameters tied to degrees of freedom $d_1$ and $d_2$, FDIST provides a probabilistic ranking that is asymmetric: the CDF shape changes qualitatively depending on whether $d_1 < d_2$, $d_1 = d_2$, or $d_1 > d_2$, giving traders control over the nonlinear response curve.
@@ -115,4 +113,4 @@ No SIMD benefit for the core evaluation. Outer loop across observations parallel
- Snedecor, G.W. "Calculation and Interpretation of Analysis of Variance and Covariance." Collegiate Press, 1934.
- Press, W.H. et al. "Numerical Recipes: The Art of Scientific Computing." 3rd edition, Cambridge University Press, 2007. Chapter 6.4 (Incomplete Beta Function).
- Lo, A. & MacKinlay, A.C. "Stock Market Prices Do Not Follow Random Walks: Evidence from a Simple Specification Test." Review of Financial Studies, 1988.
- Lentz, W.J. "Generating Bessel Functions in Mie Scattering Calculations Using Continued Fractions." Applied Optics, 1976.
- Lentz, W.J. "Generating Bessel Functions in Mie Scattering Calculations Using Continued Fractions." Applied Optics, 1976.
+2 -4
View File
@@ -13,10 +13,8 @@
| **PineScript** | [fft.pine](fft.pine) |
- The FFT indicator computes the dominant cycle period in a price series using a radix-2 Cooley-Tukey Fast Fourier Transform with a Hanning window.
- Parameterized by `windowSize` (default 64), `minPeriod` (default 4), `maxPeriod` (default 32).
- Output range: [minPeriod, maxPeriod] bars.
- Requires windowSize bars of warmup before first valid output (IsHot = true).
- True $O(N \log N)$ radix-2 FFT with bit-reversal permutation and Cooley-Tukey butterflies.
- **Similar:** [IFFT](../ifft/Ifft.md), [CWT](../cwt/Cwt.md) | **Trading note:** Fast Fourier Transform; identifies dominant frequencies/cycles in price data. Foundation of spectral analysis.
The FFT indicator computes the dominant cycle period in a price series using a true radix-2 Cooley-Tukey Fast Fourier Transform with a Hanning window. Rather than outputting frequency-domain magnitudes, it returns the estimated dominant cycle period in bars, making it directly usable as an adaptive period input for other indicators. The implementation uses an in-place iterative radix-2 FFT with bit-reversal permutation and Cooley-Tukey butterfly operations, achieving $O(N \log N)$ complexity. Parabolic interpolation on the magnitude spectrum provides sub-bin frequency resolution. With window sizes restricted to powers of two (32, 64, or 128), the indicator achieves precise cycle detection within user-specified period bounds with pre-allocated work arrays for zero-allocation streaming.
@@ -157,4 +155,4 @@ Moderate SIMD potential: butterfly FMA operations are vectorizable within each s
- Ehlers, J.F. "Rocket Science for Traders." Wiley, 2001.
- Harris, F.J. "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform." *Proc. IEEE*, 1978.
- Oppenheim, A.V. & Schafer, R.W. "Discrete-Time Signal Processing." 3rd edition, Pearson, 2010.
- PineScript reference: [`fft.pine`](fft.pine)
- PineScript reference: [`fft.pine`](fft.pine)
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [gammadist.pine](gammadist.pine) |
- The Gamma Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the gamma distribution, producing an ...
- Parameterized by `alpha` (default 2.0), `beta` (default 1.0), `period` (default 14).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Gamma distribution; models waiting times and aggregate claims. Used in risk modeling.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Gamma Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the gamma distribution, producing an output in $[0, 1]$. The gamma distribution generalizes the exponential distribution by adding a shape parameter $\alpha$ that controls whether the PDF is monotonically decreasing ($\alpha < 1$), exponential ($\alpha = 1$), or bell-shaped with a right skew ($\alpha > 1$). Combined with a rate parameter $\beta$ that scales the normalized input, GAMMADIST provides a flexible nonlinear mapping with controllable asymmetry. The CDF is computed via the regularized lower incomplete gamma function using series expansion or Lentz continued fraction, selecting the faster-converging method based on the argument relative to the shape parameter.
@@ -120,4 +118,4 @@ No practical SIMD benefit. Parallelism via PLINQ on the outer observation loop.
- Lanczos, C. "A Precision Approximation of the Gamma Function." SIAM J. Numerical Analysis B, 1964.
- Press, W.H. et al. "Numerical Recipes: The Art of Scientific Computing." 3rd edition, Cambridge University Press, 2007. Chapter 6.2 (Incomplete Gamma Function).
- Lentz, W.J. "Generating Bessel Functions in Mie Scattering Calculations Using Continued Fractions." Applied Optics, 1976.
- Johnson, N.L., Kotz, S. & Balakrishnan, N. "Continuous Univariate Distributions, Vol. 1." Wiley, 1994.
- Johnson, N.L., Kotz, S. & Balakrishnan, N. "Continuous Univariate Distributions, Vol. 1." Wiley, 1994.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [highest.pine](highest.pine) |
- HIGHEST calculates the maximum value over a rolling lookback window.
- Parameterized by `period`.
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Similar:** [Lowest](../lowest/Lowest.md), [MaxIndex](../maxindex/Maxindex.md) | **Trading note:** Rolling maximum; identifies resistance levels and breakout points.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
HIGHEST calculates the maximum value over a rolling lookback window. This O(1) amortized streaming implementation uses a monotonic deque algorithm, enabling real-time updates without re-scanning the entire window. Validated against TA-Lib MAX and Tulip max functions.
@@ -149,4 +147,4 @@ For batch processing, SIMD can parallelize comparisons within segments. However,
- Tarjan, Robert E. (1985). "Amortized Computational Complexity." SIAM Journal on Algebraic Discrete Methods.
- Lemire, Daniel. (2006). "Streaming Maximum-Minimum Filter Using No More than Three Comparisons per Element."
- TA-Lib: MAX function documentation.
- TA-Lib: MAX function documentation.
+2 -4
View File
@@ -13,10 +13,8 @@
| **PineScript** | [ifft.pine](ifft.pine) |
- The IFFT indicator reconstructs a smoothed version of the price series using a true forward FFT → spectral truncation → inverse FFT pipeline.
- Parameterized by `windowSize` (default 64), `numHarmonics` (default 5).
- Output range: Varies (overlays on price chart).
- Requires windowSize bars of warmup before first valid output (IsHot = true).
- True $O(N \log N)$ radix-2 FFT/IFFT with bit-reversal permutation and Cooley-Tukey butterflies.
- **Similar:** [FFT](../fft/Fft.md) | **Trading note:** Inverse FFT; reconstructs filtered time-domain signal from frequency domain. Used with FFT for spectral filtering.
The IFFT indicator reconstructs a smoothed version of the price series by performing a true radix-2 forward FFT, zeroing frequency bins above the specified number of harmonics (spectral truncation), then applying a true inverse FFT to reconstruct the filtered time-domain signal. The result is a spectral low-pass filter that preserves the dominant cyclical components while discarding high-frequency noise. By controlling the number of retained harmonics $H$, the user adjusts the smoothness/responsiveness trade-off: $H = 1$ yields a near-sinusoidal trend, while $H = N/2$ reproduces the original (windowed) signal. The indicator overlays on price and provides a frequency-domain alternative to conventional moving averages.
@@ -141,4 +139,4 @@ Good SIMD potential: both FFT passes are vectorizable. Expected 2× speedup over
- Ehlers, J.F. "Cycle Analytics for Traders." Wiley, 2013.
- Oppenheim, A.V. & Schafer, R.W. "Discrete-Time Signal Processing." 3rd edition, Pearson, 2010.
- Bloomfield, P. "Fourier Analysis of Time Series: An Introduction." 2nd edition, Wiley, 2000.
- PineScript reference: [`ifft.pine`](ifft.pine)
- PineScript reference: [`ifft.pine`](ifft.pine)
+1 -3
View File
@@ -14,8 +14,6 @@
- JERK measures the rate of change of acceleration—called "jerk" in physics.
- No configurable parameters; computation is stateless per bar.
- Output range: Varies (see docs).
- Requires `4` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
JERK measures the rate of change of acceleration—called "jerk" in physics. As the third derivative, it detects changes in momentum dynamics before they appear in acceleration, velocity, or price. A positive jerk means acceleration is increasing; negative means acceleration is decreasing. This O(1) streaming implementation uses dual FMA optimization and SIMD batch processing for four-point calculations.
@@ -211,4 +209,4 @@ JERK is a fundamental operation. Validation confirms exact match with manual cal
- Newton, Isaac. (1687). "Philosophiæ Naturalis Principia Mathematica."
- Numerical Methods: Finite Difference Approximations.
- Eager, David et al. (2016). "Beyond velocity and acceleration: jerk, snap and higher derivatives." European Journal of Physics.
- Eager, David et al. (2016). "Beyond velocity and acceleration: jerk, snap and higher derivatives." European Journal of Physics.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [lineartrans.pine](lineartrans.pine) |
- The Linear transformer applies an affine transformation $y = \text{slope} \cdot x + \text{intercept}$ to each value in a time series.
- Parameterized by `slope` (default 1.0), `intercept` (default 0.0).
- Output range: Varies (see docs).
- Requires `0` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Linear transformation; scales and shifts values. Used for indicator normalization and rescaling.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Linear transformer applies an affine transformation $y = \text{slope} \cdot x + \text{intercept}$ to each value in a time series. This fundamental operation enables scaling, offsetting, unit conversion, and normalization—the building blocks for preparing data for analysis or combining signals from different sources.
@@ -227,4 +225,4 @@ var offset = new Lineartrans(scale, 1.0, 10.0); // Chain: scale then add 10
- Strang, G. (2016). *Introduction to Linear Algebra*. Wellesley-Cambridge Press.
- Goldberg, D. (1991). "What Every Computer Scientist Should Know About Floating-Point Arithmetic." *ACM Computing Surveys*.
- Intel Corporation. (2023). *Intel 64 and IA-32 Architectures Optimization Reference Manual*. (FMA instruction details)
- Intel Corporation. (2023). *Intel 64 and IA-32 Architectures Optimization Reference Manual*. (FMA instruction details)
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [lognormdist.pine](lognormdist.pine) |
- The Log-Normal Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the log-normal distribution, pro...
- Parameterized by `mu` (default 0.0), `sigma` (default 1.0), `period` (default 14).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Log-normal distribution; models multiplicative processes like returns. Foundation of Black-Scholes.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Log-Normal Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the log-normal distribution, producing an output in $[0, 1]$. A random variable $X$ is log-normally distributed when $\ln(X)$ follows a normal distribution. This makes the log-normal CDF natural for financial data, where multiplicative returns (log-returns) are approximately normally distributed. The indicator min-max normalizes the source to $(0, 1]$, takes the natural logarithm, standardizes by parameters $\mu$ and $\sigma$, then evaluates the standard normal CDF. The result emphasizes values near the bottom of the recent range (where the logarithm diverges) and compresses values near the top.
@@ -118,4 +116,4 @@ Limited vectorization — erfc blocks full SIMD. With SVML log: partial vectoriz
- Aitchison, J. & Brown, J.A.C. "The Lognormal Distribution." Cambridge University Press, 1957.
- Black, F. & Scholes, M. "The Pricing of Options and Corporate Liabilities." Journal of Political Economy, 1973.
- Abramowitz, M. & Stegun, I. "Handbook of Mathematical Functions." NBS Applied Mathematics Series 55, 1964. Formula 7.1.26.
- Limpert, E., Stahel, W. & Abbt, M. "Log-normal Distributions across the Sciences: Keys and Clues." BioScience, 2001.
- Limpert, E., Stahel, W. & Abbt, M. "Log-normal Distributions across the Sciences: Keys and Clues." BioScience, 2001.
+1 -3
View File
@@ -14,8 +14,6 @@
- The LOG transformer applies the natural logarithm function $\ln(x)$ to input values.
- No configurable parameters; computation is stateless per bar.
- Output range: Varies (see docs).
- Requires `0` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The LOG transformer applies the natural logarithm function $\ln(x)$ to input values. This point-wise transformation compresses large values and expands small ones, making it essential for analyzing multiplicative processes like compounded returns.
@@ -138,4 +136,4 @@ var logTransform = new Logtrans(priceSource);
## References
- Wilmott, P. (2006). "Paul Wilmott on Quantitative Finance." Wiley.
- Hull, J. (2018). "Options, Futures, and Other Derivatives." Pearson.
- Hull, J. (2018). "Options, Futures, and Other Derivatives." Pearson.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [lowest.pine](lowest.pine) |
- LOWEST calculates the minimum value over a rolling lookback window.
- Parameterized by `period`.
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Similar:** [Highest](../highest/Highest.md), [MinIndex](../minindex/Minindex.md) | **Trading note:** Rolling minimum; identifies support levels and breakdown points.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
LOWEST calculates the minimum value over a rolling lookback window. This O(1) amortized streaming implementation uses a monotonic deque algorithm, enabling real-time updates without re-scanning the entire window. Validated against TA-Lib MIN and Tulip min functions.
@@ -149,4 +147,4 @@ For batch processing, SIMD can parallelize comparisons within segments. However,
- Tarjan, Robert E. (1985). "Amortized Computational Complexity." SIAM Journal on Algebraic Discrete Methods.
- Lemire, Daniel. (2006). "Streaming Maximum-Minimum Filter Using No More than Three Comparisons per Element."
- TA-Lib: MIN function documentation.
- TA-Lib: MIN function documentation.
+1 -3
View File
@@ -12,11 +12,9 @@
| **Warmup** | `period` bars |
- MAXINDEX finds the position (index) of the maximum value within a rolling lookback window.
- Parameterized by `period` (minimum 2).
- Streaming mode outputs bars-ago offset (0 = current bar holds the max, period-1 = oldest bar).
- Batch span mode outputs absolute array indices (TA-Lib MAXINDEX compatible).
- Tie-breaking: last occurrence wins (most recent bar, `>=` comparison).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Cross-validation: `source[Maxindex.Batch[i]] == Highest.Batch[i]` for all bars after warmup.
MAXINDEX identifies the position of the maximum value within a rolling window. While HIGHEST tells you the peak *value*, MAXINDEX tells you *where* that peak is relative to the current bar. This is essential for pattern recognition, timing analysis, and detecting how "stale" a high is.
@@ -162,4 +160,4 @@ Streaming uses a linear scan of the RingBuffer, which is O(period) per bar — a
- TA-Lib: MAXINDEX function documentation.
- Lemire, Daniel. (2006). "Streaming Maximum-Minimum Filter Using No More than Three Comparisons per Element."
- Tarjan, Robert E. (1985). "Amortized Computational Complexity." SIAM Journal on Algebraic Discrete Methods.
- Tarjan, Robert E. (1985). "Amortized Computational Complexity." SIAM Journal on Algebraic Discrete Methods.
+1 -3
View File
@@ -12,11 +12,9 @@
| **Warmup** | `period` bars |
- MININDEX finds the position (index) of the minimum value within a rolling lookback window.
- Parameterized by `period` (minimum 2).
- Streaming mode outputs bars-ago offset (0 = current bar holds the min, period-1 = oldest bar).
- Batch span mode outputs absolute array indices (TA-Lib MININDEX compatible).
- Tie-breaking: last occurrence wins (most recent bar, `<=` comparison).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Cross-validation: `source[Minindex.Batch[i]] == Lowest.Batch[i]` for all bars after warmup.
MININDEX identifies the position of the minimum value within a rolling window. While LOWEST tells you the trough *value*, MININDEX tells you *where* that trough is relative to the current bar. This is essential for support analysis, timing studies, and detecting how "stale" a low is.
@@ -162,4 +160,4 @@ Streaming uses a linear scan of the RingBuffer, which is O(period) per bar — a
- TA-Lib: MININDEX function documentation.
- Lemire, Daniel. (2006). "Streaming Maximum-Minimum Filter Using No More than Three Comparisons per Element."
- Tarjan, Robert E. (1985). "Amortized Computational Complexity." SIAM Journal on Algebraic Discrete Methods.
- Tarjan, Robert E. (1985). "Amortized Computational Complexity." SIAM Journal on Algebraic Discrete Methods.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [normalize.pine](normalize.pine) |
- The Normalize transformer applies min-max scaling to map any value series into the bounded range [0, 1] based on the observed minimum and maximum w...
- Parameterized by `period` (default 14).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Min-max normalization to [0,1]; makes indicators comparable across different scales.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Normalize transformer applies min-max scaling to map any value series into the bounded range [0, 1] based on the observed minimum and maximum within a rolling lookback window. This technique is fundamental for feature scaling, creating bounded oscillators, and comparing series with different magnitudes.
@@ -231,4 +229,4 @@ Normalize.Calculate(prices, normalized, period: 20);
- Aksoy, S., & Haralick, R. M. (2001). "Feature normalization and likelihood-based similarity measures for image retrieval." *Pattern Recognition Letters*.
- Patro, S., & Sahu, K. K. (2015). "Normalization: A preprocessing stage." *IARJSET*.
- Géron, A. (2019). *Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow*. O'Reilly Media.
- Géron, A. (2019). *Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow*. O'Reilly Media.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [normdist.pine](normdist.pine) |
- The Normal Distribution CDF transforms a z-score normalized price into the cumulative distribution function of the Gaussian distribution, producing...
- Parameterized by `mu` (default 0.0), `sigma` (default 1.0), `period` (default 14).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Normal (Gaussian) distribution; foundational for z-scores, confidence intervals, and VaR calculations.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Normal Distribution CDF transforms a z-score normalized price into the cumulative distribution function of the Gaussian distribution, producing an output in $[0, 1]$. Unlike other distribution indicators in this library that use min-max normalization, NORMDIST computes a rolling mean and standard deviation over the lookback window, converting the raw price to a z-score, then applies optional $\mu$ and $\sigma$ parameters for further shaping. The result represents the probability that a standard normal random variable would fall at or below the observed z-score. This makes NORMDIST a direct percentile ranking under the assumption of normally distributed returns, with the output naturally centered at 0.5 when the price is at its rolling mean.
@@ -137,4 +135,4 @@ The Horner polynomial evaluation in erfc() is SIMD-vectorizable. Expected 3× ba
- Abramowitz, M. & Stegun, I. "Handbook of Mathematical Functions." NBS Applied Mathematics Series 55, 1964. Formulas 7.1.25-7.1.28.
- Markowitz, H. "Portfolio Selection." Journal of Finance, 1952.
- Johnson, N.L., Kotz, S. & Balakrishnan, N. "Continuous Univariate Distributions, Vol. 1." Wiley, 1994.
- Hart, J.F. et al. "Computer Approximations." Wiley, 1968.
- Hart, J.F. et al. "Computer Approximations." Wiley, 1968.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [poissondist.pine](poissondist.pine) |
- The Poisson Distribution CDF computes the probability $P(X \le k)$ for a Poisson random variable whose rate parameter $\lambda$ is derived from the...
- Parameterized by `lambda` (default 1.0), `period` (default 14), `threshold` (default 5).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Poisson distribution; models count of rare events. Trade signal frequency analysis.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Poisson Distribution CDF computes the probability $P(X \le k)$ for a Poisson random variable whose rate parameter $\lambda$ is derived from the min-max normalized price. The Poisson distribution models the number of events in a fixed interval given a constant average rate, making it natural for count-based financial metrics (trade arrivals, tick counts, order flow). The implementation maps normalized price to $\lambda$ via a scale factor, then evaluates the CDF using the identity $P(X \le k) = 1 - P(k+1, \lambda)$ where $P(a, x)$ is the regularized lower incomplete gamma function. This reuses the same Lanczos log-gamma and series/continued-fraction infrastructure as GAMMADIST.
@@ -116,4 +114,4 @@ PMF batch: partial SIMD with SVML. CDF must be scalar. For large lambda, Normal
- Bortkiewicz, L. "Das Gesetz der kleinen Zahlen." Teubner, 1898.
- Merton, R.C. "Option Pricing When Underlying Stock Returns Are Discontinuous." Journal of Financial Economics, 1976.
- O'Hara, M. "Market Microstructure Theory." Blackwell, 1995.
- Press, W.H. et al. "Numerical Recipes: The Art of Scientific Computing." 3rd edition, Cambridge University Press, 2007. Chapter 6.2.
- Press, W.H. et al. "Numerical Recipes: The Art of Scientific Computing." 3rd edition, Cambridge University Press, 2007. Chapter 6.2.
+1 -3
View File
@@ -14,8 +14,6 @@
- The Rectified Linear Unit (ReLU) activation function applies `max(0, x)` to each value, passing positive inputs unchanged while zeroing negative ones.
- No configurable parameters; computation is stateless per bar.
- Output range: Varies (see docs).
- Requires `0` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Rectified Linear Unit (ReLU) activation function applies `max(0, x)` to each value, passing positive inputs unchanged while zeroing negative ones. Its simplicity belies its importance: ReLU enabled the training of deep neural networks by mitigating vanishing gradients, and its computational efficiency makes it the default activation for most architectures.
@@ -183,4 +181,4 @@ Relu.Calculate(source.AsSpan(), output.AsSpan());
- Nair, V. & Hinton, G. (2010). "Rectified Linear Units Improve Restricted Boltzmann Machines." *ICML*.
- Glorot, X., Bordes, A., & Bengio, Y. (2011). "Deep Sparse Rectifier Neural Networks." *AISTATS*.
- Goodfellow, I., Bengio, Y., & Courville, A. (2016). *Deep Learning*. MIT Press.
- Goodfellow, I., Bengio, Y., & Courville, A. (2016). *Deep Learning*. MIT Press.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [sigmoid.pine](sigmoid.pine) |
- The Sigmoid (Logistic) transformer maps any real-valued input to the bounded range (0, 1) using the standard logistic function.
- Parameterized by `k` (default 1.0), `x0` (default 0.0).
- Output range: Varies (see docs).
- Requires `0` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Sigmoid function; maps values to (0,1). Used for probability-like scaling of indicator outputs.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Sigmoid (Logistic) transformer maps any real-valued input to the bounded range (0, 1) using the standard logistic function. Its characteristic S-shaped curve makes it indispensable for probability estimation, neural network activations, and any scenario requiring bounded outputs from unbounded inputs.
@@ -227,4 +225,4 @@ Sigmoid.Calculate(inputs, outputs, k: 1.0, x0: 0.0);
- Verhulst, P.-F. (1838). "Notice sur la loi que la population suit dans son accroissement." *Correspondance Mathématique et Physique*.
- Rumelhart, D., Hinton, G., & Williams, R. (1986). "Learning representations by back-propagating errors." *Nature*.
- Bishop, C. (2006). *Pattern Recognition and Machine Learning*. Springer.
- Bishop, C. (2006). *Pattern Recognition and Machine Learning*. Springer.
+1 -3
View File
@@ -14,8 +14,6 @@
- SLOPE measures the instantaneous rate of change—the velocity of a time series.
- No configurable parameters; computation is stateless per bar.
- Output range: Varies (see docs).
- Requires `2` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
SLOPE measures the instantaneous rate of change—the velocity of a time series. As the first derivative, it answers the fundamental question: how fast is the value changing right now? A positive slope means ascending; negative means descending; zero means flat. This O(1) streaming implementation uses SIMD optimization for batch calculations and handles bar corrections via state rollback.
@@ -160,4 +158,4 @@ SLOPE is a fundamental operation. Validation confirms exact match with manual ca
## References
- Newton, Isaac. (1687). "Philosophiæ Naturalis Principia Mathematica."
- Numerical Methods: Finite Difference Approximations.
- Numerical Methods: Finite Difference Approximations.
+1 -3
View File
@@ -14,8 +14,6 @@
- The Square Root (SQRT) transformer applies $\sqrt{x}$ to each value in a time series.
- No configurable parameters; computation is stateless per bar.
- Output range: Varies (see docs).
- Requires `0` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Square Root (SQRT) transformer applies $\sqrt{x}$ to each value in a time series. This variance-stabilizing transformation compresses ranges where volatility scales with magnitude, making it useful for heteroscedastic data where standard deviation increases with price level.
@@ -209,4 +207,4 @@ var recovered = Sqrttrans.Calculate(squared);
- Box, G.E.P., & Cox, D.R. (1964). "An Analysis of Transformations." *Journal of the Royal Statistical Society, Series B*, 26(2), 211-252.
- Tukey, J.W. (1977). *Exploratory Data Analysis*. Addison-Wesley. (Variance-stabilizing transformations)
- IEEE 754-2019. *Standard for Floating-Point Arithmetic*. (sqrt specification)
- IEEE 754-2019. *Standard for Floating-Point Arithmetic*. (sqrt specification)
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [tdist.pine](tdist.pine) |
- The Student's t-Distribution CDF transforms a min-max normalized price into the cumulative distribution function of Student's t-distribution, produ...
- Parameterized by `nu` (default 10), `period` (default 14).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Student's t-distribution; used for hypothesis testing with small samples. Fatter tails than normal.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Student's t-Distribution CDF transforms a min-max normalized price into the cumulative distribution function of Student's t-distribution, producing an output in $[0, 1]$. The t-distribution is the normal distribution's heavier-tailed cousin: as degrees of freedom $\nu$ increase, it converges to the Gaussian; at low $\nu$ it accommodates extreme values that the normal distribution would assign negligible probability. The implementation normalizes price to $[0, 1]$, maps to a t-statistic via linear scaling to $[-3, +3]$, then evaluates the CDF through the regularized incomplete beta function. This makes TDIST a robust percentile ranking that is less sensitive to outliers than NORMDIST.
@@ -129,4 +127,4 @@ Dominated by sequential CF solver. Outer loop PLINQ for bulk p-value computation
- Mandelbrot, B. "The Variation of Certain Speculative Prices." Journal of Business, 1963.
- Fama, E.F. "The Behavior of Stock-Market Prices." Journal of Business, 1965.
- Bollerslev, T. "Generalized Autoregressive Conditional Heteroskedasticity." Journal of Econometrics, 1986.
- Press, W.H. et al. "Numerical Recipes: The Art of Scientific Computing." 3rd edition, Cambridge University Press, 2007. Chapter 6.4.
- Press, W.H. et al. "Numerical Recipes: The Art of Scientific Computing." 3rd edition, Cambridge University Press, 2007. Chapter 6.4.
+2 -4
View File
@@ -13,9 +13,7 @@
| **PineScript** | [weibulldist.pine](weibulldist.pine) |
- The Weibull Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the Weibull distribution, producing...
- Parameterized by `k` (default 1.5), `lambda` (default 1.0), `period` (default 14).
- Output range: Varies (see docs).
- Requires `period` bars of warmup before first valid output (IsHot = true).
- **Trading note:** Weibull distribution; flexible lifetime/reliability model. Used for drawdown duration analysis.
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
The Weibull Distribution CDF transforms a min-max normalized price into the cumulative distribution function of the Weibull distribution, producing an output in $[0, 1]$. The Weibull distribution is a flexible two-parameter family that subsumes the exponential distribution ($k = 1$) and approximates the normal distribution ($k \approx 3.6$) as special cases. Its closed-form CDF requires only `pow` and `exp`, making it the computationally cheapest distribution indicator after EXPDIST. The shape parameter $k$ controls the CDF curvature: $k < 1$ produces a concave curve (rapid initial rise), $k = 1$ gives the exponential, $k = 2$ produces the Rayleigh distribution, and $k > 3$ creates an S-shaped curve approaching Gaussian behavior.
@@ -130,4 +128,4 @@ With SVML: nearly full vectorization. Without SVML: scalar loop but trivially pa
- Frechet, M. "Sur la loi de probabilite de l'ecart maximum." Ann. Soc. Polon. Math., 1927.
- Rinne, H. "The Weibull Distribution: A Handbook." CRC Press, 2009.
- Abernethy, R.B. "The New Weibull Handbook." 5th edition, 2006.
- Johnson, N.L., Kotz, S. & Balakrishnan, N. "Continuous Univariate Distributions, Vol. 1." Wiley, 1994.
- Johnson, N.L., Kotz, S. & Balakrishnan, N. "Continuous Univariate Distributions, Vol. 1." Wiley, 1994.