feat(dynamics): add PlusDI, MinusDI, PlusDM, MinusDM indicators

Complete thin Dx-composition wrapper indicators with full test coverage:

- PlusDi/MinusDi: Directional Indicator wrappers (DiPlus/DiMinus from Dx)
- PlusDm/MinusDm: Directional Movement wrappers (DmPlus/DmMinus from Dx)
- Individual validation tests per indicator directory (TALib, Skender, bounds)
- Combined unit tests (DiDm.Tests.cs) and validation tests (DiDm.Validation.Tests.cs)
- Quantower wrappers + tests for all 4 indicators
- PineScript v6 implementations with compensated RMA
- Normalized .md documentation for all indicators and categories
- 182 tests passing, 0 failures
This commit is contained in:
Miha Kralj
2026-03-11 20:21:52 -07:00
parent 56b86bebfb
commit 33d20f2a18
437 changed files with 4589 additions and 2792 deletions
-2
View File
@@ -1,7 +1,5 @@
# Statistics
> "All models are wrong, but some are useful." — George Box
Statistical tools applied to price and returns. These indicators quantify relationships, measure dispersion, test hypotheses. Unlike momentum or trend indicators, statistics describe the data itself.
| Indicator | Full Name | Description |
+2 -2
View File
@@ -1,5 +1,7 @@
# ACF: Autocorrelation Function
> *The past doesn't predict the future, but it whispers patterns to those who listen.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against mathematical properties and theoretical AR-process expectations.
> "The past doesn't predict the future, but it whispers patterns to those who listen."
The Autocorrelation Function (ACF) measures the correlation of a time series with a lagged copy of itself. It is fundamental for identifying repeating patterns, seasonal effects, and determining the order of time series models like ARMA/ARIMA.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# Beta: Beta Coefficient
> *Volatility is not risk. It's the price of admission.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period + 1` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Volatility is not risk. It's the price of admission."
Beta measures the volatility of an asset in relation to the overall market. It's the slope of the regression line between the asset's returns and the market's returns. A beta of 1.0 means the asset moves in lockstep with the market. A beta of 2.0 means the asset is twice as volatile as the market.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# CMA: Cumulative Moving Average
> *The running average that never forgets. Every single tick you've ever fed it? Still in there, affecting the result. It's like the elephant of technical indicators.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `1` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The running average that never forgets. Every single tick you've ever fed it? Still in there, affecting the result. It's like the elephant of technical indicators."
The Cumulative Moving Average (CMA) calculates the arithmetic mean of ALL data points seen so far, not just a fixed window. Unlike SMA or EMA which use a sliding window, CMA treats every historical value with equal weight. As the sample size grows, each new value has diminishing impact on the average.
## Historical Context
@@ -1,5 +1,7 @@
# Cointegration: Engle-Granger Two-Step Cointegration Test
> *Correlation tells you they move together. Cointegration tells you they're bound together. Two stocks can be uncorrelated yet cointegrated, or perfectly correlated yet destined to drift apart forever. The difference between 'similar direction' and 'shared destiny' is the difference between a tourist attraction and a gravitational orbit.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period + 1` bars of warmup before first valid output (IsHot = true).
- Validated against TradingView PineScript reference and statistical property tests.
> "Correlation tells you they move together. Cointegration tells you they're bound together. Two stocks can be uncorrelated yet cointegrated, or perfectly correlated yet destined to drift apart forever. The difference between 'similar direction' and 'shared destiny' is the difference between a tourist attraction and a gravitational orbit."
The Cointegration indicator measures the long-run equilibrium relationship between two price series using the Engle-Granger two-step method with an Augmented Dickey-Fuller (ADF) test. Unlike correlation, which measures short-term co-movement, cointegration tests whether two non-stationary series share a common stochastic trend—meaning they may diverge temporarily but are statistically bound to revert to their equilibrium relationship.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# CORR: Pearson Correlation Coefficient
> *Correlation is not causation, but it sure is a hint. The market doesn't care why two instruments move together—only that they do, and whether that relationship will persist long enough for you to profit from it.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TradingView reference behavior and mathematical invariants.
> "Correlation is not causation, but it sure is a hint. The market doesn't care why two instruments move together—only that they do, and whether that relationship will persist long enough for you to profit from it."
The Pearson Correlation Coefficient measures the linear relationship between two variables, returning a value from -1 (perfect negative correlation) to +1 (perfect positive correlation). Zero indicates no linear relationship. This implementation uses running sums for O(1) streaming updates, making it suitable for real-time analysis of price relationships.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# Covariance: Covariance
> *Correlation is just covariance normalized by standard deviation. But sometimes you want the raw, unadulterated relationship.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Correlation is just covariance normalized by standard deviation. But sometimes you want the raw, unadulterated relationship."
Covariance measures the joint variability of two random variables. It indicates the direction of the linear relationship between variables.
## Architecture & Physics
+2 -2
View File
@@ -1,5 +1,7 @@
# ENTROPY: Shannon Entropy
> *Information is the resolution of uncertainty.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Information is the resolution of uncertainty." — Claude Shannon
Shannon Entropy measures the unpredictability or randomness of a time series over a sliding window. A low entropy value indicates the series is highly predictable (clustered values), while a high entropy value indicates the data is spread uniformly across its range — maximum randomness.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# GEOMEAN: Geometric Mean
> *The geometric mean is never greater than the arithmetic mean.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The geometric mean is never greater than the arithmetic mean." - Mathematical inequality since antiquity
The Geometric Mean computes the nth root of the product of n positive values over a sliding window. Unlike the arithmetic mean, it captures multiplicative relationships and is the correct average for growth rates, ratios, and log-normally distributed data. For financial time series, this means it properly accounts for compounding.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# GRANGER: Granger Causality F-Statistic
> *Correlation is not causation, but Granger causality is not causation either. It is prediction.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period + 1` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Correlation is not causation, but Granger causality is not causation either. It is prediction." -- Clive Granger
## Introduction
The Granger Causality test asks a precise, falsifiable question: does knowing the history of series X improve your ability to predict series Y, beyond what Y's own history already provides? The answer arrives as an F-statistic from comparing two OLS regression models. Higher F means X contains predictive information about Y that Y itself does not. This implementation uses lag-1, runs in O(1) streaming mode via running sums, and handles bar corrections for live trading.
+2 -2
View File
@@ -1,5 +1,7 @@
# HARMEAN: Harmonic Mean
> *The harmonic mean is never greater than the geometric mean, which is never greater than the arithmetic mean.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The harmonic mean is never greater than the geometric mean, which is never greater than the arithmetic mean." - The Mean Inequality, a mathematical fact older than calculus
The Harmonic Mean computes the reciprocal of the arithmetic mean of reciprocals over a sliding window. It is the correct average for quantities defined in terms of rates or ratios (speed, P/E ratios, yield). For financial time series, the harmonic mean gives the largest discount to outliers, making it the most conservative of the three Pythagorean means.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# HURST: Hurst Exponent
> *The past is not dead. In fact, it's not even past.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period + 1` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The past is not dead. In fact, it's not even past." — William Faulkner, and also every mean-reverting time series that refuses to forget.
## Introduction
The Hurst Exponent ($H$) quantifies long-range dependence in a time series through Rescaled Range (R/S) analysis. Where autocorrelation decays and dies, the Hurst exponent measures the memory that persists across scales. $H > 0.5$ signals persistence (trending behavior), $H < 0.5$ signals anti-persistence (mean-reversion), and $H = 0.5$ represents the memoryless random walk that efficient market theorists insist you should believe in.
+2 -2
View File
@@ -1,5 +1,7 @@
# IQR: Interquartile Range
> *The median is the most important statistic, and the interquartile range is the second most important.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The median is the most important statistic, and the interquartile range is the second most important." — John Tukey
## Introduction
The Interquartile Range measures the spread of the middle 50% of a sorted dataset within a rolling window. By subtracting the 25th percentile (Q1) from the 75th percentile (Q3), IQR provides a robust dispersion metric that ignores outliers in both tails. Unlike standard deviation, which squares deviations and amplifies extremes, IQR tells you how wide the "typical" price band actually is.
+2 -2
View File
@@ -1,5 +1,7 @@
# JB: Jarque-Bera Test
> *The assumption of normality is the most dangerous assumption in all of statistics.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The assumption of normality is the most dangerous assumption in all of statistics." — George Box (paraphrased)
The Jarque-Bera test quantifies departure from normality by combining skewness and excess kurtosis into a single chi-squared statistic. A rolling JB value near zero means the window looks Gaussian. Values exceeding 5.991 (5% significance) reject normality. Financial returns almost always fail this test, which is precisely why the test matters.
## Historical Context
+1 -1
View File
@@ -1,6 +1,6 @@
# KENDALL: Kendall Tau-a Rank Correlation Coefficient
> "The rank is the message." -- adapted from Marshall McLuhan
> *The rank is the message.*
<!-- QUICK REFERENCE CARD (scan in 5 seconds) -->
+2 -2
View File
@@ -1,5 +1,7 @@
# KURTOSIS: Excess Kurtosis
> *Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car." The fourth moment measures how far your returns deviate from that comforting fiction.
## Introduction
Kurtosis measures the **tailedness** of a probability distribution. Specifically, this implementation calculates *excess kurtosis*, which subtracts 3 from the raw kurtosis so that a normal distribution has excess kurtosis of zero. A positive value (leptokurtic) indicates fatter tails than normal, meaning more frequent extreme events. A negative value (platykurtic) indicates thinner tails, fewer surprises. Financial returns consistently exhibit positive excess kurtosis, which is why "once in a century" events happen every decade.
+2 -2
View File
@@ -1,5 +1,7 @@
# LinReg: Linear Regression Curve
> *The trend is your friend, until it bends.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The trend is your friend, until it bends."
The Linear Regression Curve plots the end point of the linear regression line for each bar. It fits a straight line $y = mx + b$ to the data points using the least squares method, providing a smoothed representation of the price trend that is more responsive than a Simple Moving Average (SMA).
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# MeanDev: Mean Deviation (Average Absolute Deviation)
> *Not all dispersion is created equal — some prefer robustness over elegance.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Not all dispersion is created equal — some prefer robustness over elegance."
Mean Deviation (also known as Mean Absolute Deviation or Average Absolute Deviation) measures the average of the absolute deviations from the mean. Unlike Standard Deviation, it does not square the deviations, making it more robust to outliers and more intuitive to interpret.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# MEDIAN: Rolling Median
> *The average is easily influenced by outliers; the median stands its ground.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The average is easily influenced by outliers; the median stands its ground."
The Rolling Median is a robust statistic that represents the middle value of a dataset within a moving window. Unlike the Simple Moving Average (SMA), which can be skewed by extreme values, the Median provides a more stable measure of central tendency, making it particularly useful for filtering noise in volatile markets.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# MODE: Statistical Mode (Most Frequent Value)
> *The mode is the value that appears most frequently in a data set — the only measure of central tendency that tells you what's actually popular, not what's average.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The mode is the value that appears most frequently in a data set — the only measure of central tendency that tells you what's actually popular, not what's average."
## Introduction
The **Mode** is a rolling statistical indicator that identifies the most frequently occurring value within
+2 -2
View File
@@ -1,5 +1,7 @@
# PACF: Partial Autocorrelation Function
> *Strip away the intermediaries, and you'll see the true direct relationship.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against mathematical properties and Durbin-Levinson recursion expectations.
> "Strip away the intermediaries, and you'll see the true direct relationship."
The Partial Autocorrelation Function (PACF) measures the correlation between a time series and its lagged values, after removing the effects of all intermediate lags. While ACF shows total correlation at each lag, PACF isolates the direct correlation, making it essential for AR model identification.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# PERCENTILE: Rolling Percentile
> *There are three kinds of lies: lies, damned lies, and statistics.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "There are three kinds of lies: lies, damned lies, and statistics." — Mark Twain.
> But percentiles, at least, tell you exactly where you stand.
## Introduction
+2
View File
@@ -1,5 +1,7 @@
# POLYFIT: Polynomial Fitting
> *Polynomial fitting bends a curve through price data, capturing nonlinear trends that a straight line cannot.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
+2 -2
View File
@@ -1,5 +1,7 @@
# QUANTILE: Rolling Quantile
> *The quantile function is the inverse of the distribution function.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The quantile function is the inverse of the distribution function." — Every probability textbook ever written, and yet somehow it still surprises people.
## Introduction
The Rolling Quantile computes the value below which a given fraction of observations fall within a sliding window. It is mathematically identical to Percentile but uses the statistician's convention of q ∈ [0, 1] instead of the analyst's p ∈ [0, 100]. When q=0.5, it returns the median; q=0 gives the minimum; q=1 gives the maximum. The linear interpolation method matches Excel's PERCENTILE.INC and PineScript's `ta.percentile_linear_interpolation` conventions (Hyndman-Fan Method 7).
+2 -2
View File
@@ -1,5 +1,7 @@
# SKEW: Skewness
> *In the land of the blind, the one-eyed man is king. In the land of the normal distribution, the skewed man is profitable.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "In the land of the blind, the one-eyed man is king. In the land of the normal distribution, the skewed man is profitable."
Skewness measures the asymmetry of the probability distribution of a real-valued random variable about its mean. It tells you where the "tail" of the distribution is.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# SPEARMAN: Spearman Rank Correlation Coefficient
> *The person who asks whether rank correlation exists is not asking a wholly foolish question.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The person who asks whether rank correlation exists is not asking a wholly foolish question." — Maurice Kendall (1970)
Spearman's ρ (rho) measures the strength and direction of monotonic association between two variables. Unlike Pearson's correlation, which measures linear relationship, Spearman captures any monotonic relationship. A portfolio of stocks whose returns move monotonically together has different risk than one whose components merely share a linear trend. Spearman detects both.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# STDDEV: Standard Deviation
> *Volatility is not risk, but it's the only thing we can measure.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Volatility is not risk, but it's the only thing we can measure."
Standard Deviation measures the amount of variation or dispersion of a set of values. A low standard deviation indicates that the values tend to be close to the mean (also called the expected value) of the set, while a high standard deviation indicates that the values are spread out over a wider range.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# Stderr: Standard Error of Regression
> *How confident are you in your line of best fit?*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first stable output (`IsHot = true`).
- Validated against an internal brute-force OLS reference implementation.
> "How confident are you in your line of best fit?"
Standard Error of Regression (also called the Standard Error of the Estimate) measures the average distance that the observed values fall from the regression line. It quantifies the typical size of the residuals, providing a direct measure of how well a linear regression model fits the data.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# Sum: Summation with Kahan-Babuška Algorithm
> *The naive approach to summation assumes all digits matter equally. They don't. When you add 1e-10 to 1e10, that small value vanishes into the rounding noise. Kahan-Babuška tracks what got lost and adds it back later. It's bookkeeping for bits that would otherwise slip through the cracks.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The naive approach to summation assumes all digits matter equally. They don't. When you add 1e-10 to 1e10, that small value vanishes into the rounding noise. Kahan-Babuška tracks what got lost and adds it back later. It's bookkeeping for bits that would otherwise slip through the cracks."
The Sum indicator calculates a rolling window summation using the Kahan-Babuška algorithm (also known as "improved Kahan" or "second-order compensated summation") for maximum numerical precision. This approach captures rounding errors that even classic Kahan summation misses, making it suitable for numerical libraries, statistics, and trading applications where precision matters.
## Historical Context
+2 -2
View File
@@ -1,5 +1,7 @@
# THEIL: Theil's T Index
> *The only useful measure of inequality is one that tells you how much redistribution would make everyone equally well off.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "The only useful measure of inequality is one that tells you how much redistribution would make everyone equally well off." — Henri Theil
## Introduction
The Theil T Index is an information-theoretic measure of inequality (or concentration) within a distribution of positive values. Originally developed for income inequality analysis, it quantifies how far a set of values deviates from perfect equality. In financial contexts, it measures the concentration of returns or price magnitudes within a sliding window, producing values ranging from 0 (perfect equality, all values identical) upward with no fixed upper bound. The Theil T Index belongs to the family of generalized entropy indices and is notable for its decomposability property: total inequality can be additively decomposed into between-group and within-group components.
+2
View File
@@ -1,5 +1,7 @@
# TRIM: Trimmed Mean Moving Average
> *Trimmed mean drops the extreme tails before averaging — robust estimation that refuses to let outliers hijack the center.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
+2 -2
View File
@@ -1,5 +1,7 @@
# Variance (VAR)
> *Volatility is the price of admission for high returns.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
> "Volatility is the price of admission for high returns."
Variance measures how far a set of numbers is spread out from their average value. In finance, it is a key measure of volatility and risk.
## Historical Context
+2
View File
@@ -1,5 +1,7 @@
# WAVG: Weighted Average
> *Weighted average assigns importance by position, giving recent or central observations a louder voice in the mean.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
+2
View File
@@ -1,5 +1,7 @@
# WINS: Winsorized Mean Moving Average
> *Winsorization clamps outliers to the nearest percentile fence, preserving sample size while taming extreme values.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
+2 -2
View File
@@ -1,5 +1,7 @@
# ZSCORE: Z-Score (Population Standard Score, also known as STANDARDIZE)
> *How far from normal is this?*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against manual computation, PineScript parity, and statistical invariants.
> "How far from normal is this?" — Every risk manager, every day.
## Introduction
The Z-Score measures how many population standard deviations a value lies from the rolling mean over a lookback window. ZSCORE is the canonical implementation for z-score standardization in QuanTAlib (the former Standardize indicator, which used sample standard deviation with N-1, has been consolidated into this indicator). ZSCORE uses population standard deviation, matching the PineScript `ta.zscore` convention. Output is unbounded, typically ranging from -3 to +3 for normally distributed data. A z-score of 0 means the value equals the window mean; ±2 flags statistical outliers at the 95% level.
+2 -2
View File
@@ -1,5 +1,7 @@
# ZTEST: One-Sample t-Test Statistic
> *The purpose of hypothesis testing is not to prove what we believe, but to measure what we observe.*
| Property | Value |
| ---------------- | -------------------------------- |
| **Category** | Statistic |
@@ -16,8 +18,6 @@
- Requires `period` bars of warmup before first valid output (IsHot = true).
- Validated against manual computation, PineScript parity, and testable statistical properties.
> "The purpose of hypothesis testing is not to prove what we believe, but to measure what we observe." — Adapted from R.A. Fisher
## Introduction
ZTEST computes the **one-sample t-statistic**, measuring how many standard errors the rolling sample mean deviates from a hypothesized population mean $\mu_0$. Despite the PineScript naming convention ("ZTEST"), this indicator computes a proper t-statistic using Bessel-corrected sample standard deviation with $N-1$ degrees of freedom. Values beyond $\pm 2.04$ (for $n=30$) indicate the sample mean differs from $\mu_0$ at the 95% confidence level; values beyond $\pm 2.75$ indicate 99% significance.