mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-15 00:58:04 +00:00
Refactor documentation links in numerics, oscillators, reversals, and statistics modules to use relative paths; update Bias class to handle division by zero more robustly; remove obsolete CUMMEAN Pine script; enhance trend indicators documentation; add Visual Studio Code workspace configuration.
This commit is contained in:
+30
-31
@@ -6,34 +6,33 @@ Statistical tools applied to price and returns. These indicators quantify relati
|
||||
|
||||
| Indicator | Full Name | Description |
|
||||
| :--- | :--- | :--- |
|
||||
| [ACF](/lib/statistics/acf/Acf.md) | Autocorrelation Function | Correlation of time series with lagged copy. For ARMA model identification. |
|
||||
| [BETA](/lib/statistics/beta/Beta.md) | Beta Coefficient | Asset volatility relative to market. β=1 means market-matched risk. |
|
||||
| [BIAS](/lib/statistics/bias/Bias.md) | Bias | Percentage deviation from moving average. Measures overextension. |
|
||||
| [CMA](/lib/statistics/cma/Cma.md) | Cumulative Moving Average | Running average of all values. Welford's algorithm. No window. |
|
||||
| [COINTEGRATION](/lib/statistics/cointegration/Cointegration.md) | Cointegration | Tests if series share long-term equilibrium. Pairs trading foundation. |
|
||||
| [CORRELATION](/lib/statistics/correlation/Correlation.md) | Correlation | Linear relationship between two variables. Range: -1 to +1. |
|
||||
| [COVARIANCE](/lib/statistics/covariance/Covariance.md) | Covariance | Joint variability of two random variables. Building block for β. |
|
||||
| [CUMMEAN](/lib/statistics/cummean/Cummean.md) | Cumulative Mean | Cumulative mean from series start. Ignores NaN values. |
|
||||
| [ENTROPY](/lib/statistics/entropy/Entropy.md) | Shannon Entropy | Measures uncertainty/randomness. Higher entropy = less predictable. |
|
||||
| [GEOMEAN](/lib/statistics/geomean/Geomean.md) | Geometric Mean | nth root of product. Use for growth rates and ratios. |
|
||||
| [GRANGER](/lib/statistics/granger/Granger.md) | Granger Causality | Tests if one series helps predict another. Not true causality. |
|
||||
| [HARMEAN](/lib/statistics/harmean/Harmean.md) | Harmonic Mean | Reciprocal of arithmetic mean of reciprocals. For rates/ratios. |
|
||||
| [HURST](/lib/statistics/hurst/Hurst.md) | Hurst Exponent | Long-term memory. H>0.5: trending. H<0.5: mean-reverting. |
|
||||
| [IQR](/lib/statistics/iqr/Iqr.md) | Interquartile Range | P75 - P25. Robust dispersion measure. |
|
||||
| [JB](/lib/statistics/jb/Jb.md) | Jarque-Bera Test | Normality test using skewness and kurtosis. |
|
||||
| [KENDALL](/lib/statistics/kendall/Kendall.md) | Kendall Rank Correlation | Ordinal association. Robust to outliers. |
|
||||
| [KURTOSIS](/lib/statistics/kurtosis/Kurtosis.md) | Kurtosis | Tail heaviness. High kurtosis = fat tails = more extreme events. |
|
||||
| [LINREG](/lib/statistics/linreg/LinReg.md) | Linear Regression | Least squares fit. Outputs slope, intercept, R². |
|
||||
| [MEDIAN](/lib/statistics/median/Median.md) | Median | Middle value in sorted window. Robust to outliers. |
|
||||
| [MODE](/lib/statistics/mode/Mode.md) | Mode | Most frequent value. Use for categorical or discrete data. |
|
||||
| [PACF](/lib/statistics/pacf/Pacf.md) | Partial Autocorrelation Function | Direct correlation at lag k after removing intermediate effects. For AR model identification. |
|
||||
| [PERCENTILE](/lib/statistics/percentile/Percentile.md) | Percentile | Value below which given percentage of observations fall. |
|
||||
| [QUANTILE](/lib/statistics/quantile/Quantile.md) | Quantile | Divides distribution into equal probability intervals. |
|
||||
| [SKEW](/lib/statistics/skew/Skew.md) | Skewness | Distribution asymmetry. Positive: right tail. Negative: left tail. |
|
||||
| [SPEARMAN](/lib/statistics/spearman/Spearman.md) | Spearman Rank Correlation | Pearson on ranks. Measures monotonic relationship. |
|
||||
| [STDDEV](/lib/statistics/stddev/StdDev.md) | Standard Deviation | Square root of variance. Same units as data. |
|
||||
| [SUM](/lib/statistics/sum/Sum.md) | Rolling Sum | Kahan-Babuška summation. Numerically stable. |
|
||||
| [THEIL](/lib/statistics/theil/Theil.md) | Theil Index | Inequality measure. Decomposable into within/between group. |
|
||||
| [VARIANCE](/lib/statistics/variance/Variance.md) | Variance | Average squared deviation from mean. Units are squared. |
|
||||
| [ZSCORE](/lib/statistics/zscore/Zscore.md) | Z-Score | Standard deviations from mean. Normalizes different scales. |
|
||||
| [ZTEST](/lib/statistics/ztest/Ztest.md) | Z-Test | Hypothesis test comparing sample mean to population mean. |
|
||||
| [ACF](acf/Acf.md) | Autocorrelation Function | Correlation of time series with lagged copy. For ARMA model identification. |
|
||||
| [BETA](beta/Beta.md) | Beta Coefficient | Asset volatility relative to market. β=1 means market-matched risk. |
|
||||
| [BIAS](bias/Bias.md) | Bias | Percentage deviation from moving average. Measures overextension. |
|
||||
| [CMA](cma/Cma.md) | Cumulative Moving Average | Running average of all values. Welford's algorithm. No window. |
|
||||
| [COINTEGRATION](cointegration/Cointegration.md) | Cointegration | Tests if series share long-term equilibrium. Pairs trading foundation. |
|
||||
| [CORRELATION](correlation/Correlation.md) | Correlation | Linear relationship between two variables. Range: -1 to +1. |
|
||||
| [COVARIANCE](covariance/Covariance.md) | Covariance | Joint variability of two random variables. Building block for β. |
|
||||
| [ENTROPY](entropy/Entropy.md) | Shannon Entropy | Measures uncertainty/randomness. Higher entropy = less predictable. |
|
||||
| [GEOMEAN](geomean/Geomean.md) | Geometric Mean | nth root of product. Use for growth rates and ratios. |
|
||||
| [GRANGER](granger/Granger.md) | Granger Causality | Tests if one series helps predict another. Not true causality. |
|
||||
| [HARMEAN](harmean/Harmean.md) | Harmonic Mean | Reciprocal of arithmetic mean of reciprocals. For rates/ratios. |
|
||||
| [HURST](hurst/Hurst.md) | Hurst Exponent | Long-term memory. H>0.5: trending. H<0.5: mean-reverting. |
|
||||
| [IQR](iqr/Iqr.md) | Interquartile Range | P75 - P25. Robust dispersion measure. |
|
||||
| [JB](jb/Jb.md) | Jarque-Bera Test | Normality test using skewness and kurtosis. |
|
||||
| [KENDALL](kendall/Kendall.md) | Kendall Rank Correlation | Ordinal association. Robust to outliers. |
|
||||
| [KURTOSIS](kurtosis/Kurtosis.md) | Kurtosis | Tail heaviness. High kurtosis = fat tails = more extreme events. |
|
||||
| [LINREG](linreg/LinReg.md) | Linear Regression | Least squares fit. Outputs slope, intercept, R². |
|
||||
| [MEDIAN](median/Median.md) | Median | Middle value in sorted window. Robust to outliers. |
|
||||
| [MODE](mode/Mode.md) | Mode | Most frequent value. Use for categorical or discrete data. |
|
||||
| [PACF](pacf/Pacf.md) | Partial Autocorrelation Function | Direct correlation at lag k after removing intermediate effects. For AR model identification. |
|
||||
| [PERCENTILE](percentile/Percentile.md) | Percentile | Value below which given percentage of observations fall. |
|
||||
| [QUANTILE](quantile/Quantile.md) | Quantile | Divides distribution into equal probability intervals. |
|
||||
| [SKEW](skew/Skew.md) | Skewness | Distribution asymmetry. Positive: right tail. Negative: left tail. |
|
||||
| [SPEARMAN](spearman/Spearman.md) | Spearman Rank Correlation | Pearson on ranks. Measures monotonic relationship. |
|
||||
| [STDDEV](stddev/StdDev.md) | Standard Deviation | Square root of variance. Same units as data. |
|
||||
| [SUM](sum/Sum.md) | Rolling Sum | Kahan-Babuška summation. Numerically stable. |
|
||||
| [THEIL](theil/Theil.md) | Theil Index | Inequality measure. Decomposable into within/between group. |
|
||||
| [VARIANCE](variance/Variance.md) | Variance | Average squared deviation from mean. Units are squared. |
|
||||
| [ZSCORE](zscore/Zscore.md) | Z-Score | Standard deviations from mean. Normalizes different scales. |
|
||||
| [ZTEST](ztest/Ztest.md) | Z-Test | Hypothesis test comparing sample mean to population mean. |
|
||||
|
||||
@@ -43,6 +43,7 @@ public sealed class Bias : AbstractBase
|
||||
private State _p_state;
|
||||
|
||||
private const int ResyncInterval = 1000;
|
||||
private const double Epsilon = 1e-10;
|
||||
|
||||
/// <summary>
|
||||
/// Creates Bias with specified period.
|
||||
@@ -138,7 +139,7 @@ public sealed class Bias : AbstractBase
|
||||
|
||||
// Calculate final Bias
|
||||
double sma = _state.Sum / _buffer.Count;
|
||||
double bias = sma != 0 ? (_state.LastInput - sma) / sma : 0;
|
||||
double bias = Math.Abs(sma) > Epsilon ? (_state.LastInput - sma) / sma : 0;
|
||||
Last = new TValue(DateTime.MinValue, bias);
|
||||
_p_state = _state;
|
||||
}
|
||||
@@ -202,7 +203,7 @@ public sealed class Bias : AbstractBase
|
||||
|
||||
// Calculate Bias: (Price - SMA) / SMA
|
||||
double sma = _state.Sum / _buffer.Count;
|
||||
double bias = sma != 0 ? (_state.LastInput - sma) / sma : 0;
|
||||
double bias = Math.Abs(sma) > Epsilon ? (_state.LastInput - sma) / sma : 0;
|
||||
|
||||
Last = new TValue(input.Time, bias);
|
||||
PubEvent(Last, isNew);
|
||||
@@ -327,7 +328,7 @@ public sealed class Bias : AbstractBase
|
||||
|
||||
double n = i + 1;
|
||||
double sma = sum / n;
|
||||
output[i] = sma != 0 ? (val - sma) / sma : 0;
|
||||
output[i] = Math.Abs(sma) > Epsilon ? (val - sma) / sma : 0;
|
||||
}
|
||||
|
||||
// Main phase with sliding window
|
||||
@@ -354,7 +355,7 @@ public sealed class Bias : AbstractBase
|
||||
}
|
||||
|
||||
double sma = sum / period;
|
||||
output[i] = sma != 0 ? (val - sma) / sma : 0;
|
||||
output[i] = Math.Abs(sma) > Epsilon ? (val - sma) / sma : 0;
|
||||
|
||||
// Periodic resync for long sequences
|
||||
tickCount++;
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// The MIT License (MIT)
|
||||
// © mihakralj
|
||||
//@version=6
|
||||
indicator("Cumulative Mean (CUMMEAN)", "CUMMEAN", overlay=false, precision=8)
|
||||
|
||||
//@function Calculates the cumulative arithmetic mean (average) of a series from the start of the data.
|
||||
//@doc https://github.com/mihakralj/pinescript/blob/main/indicators/statistics/cummean.md
|
||||
//@param src series float Input data series.
|
||||
//@returns series float The cumulative mean of the series, or na if all data so far is na.
|
||||
cummean(series float src) =>
|
||||
var float cumulative_sum = 0.0
|
||||
var int valid_data_count = 0
|
||||
if not na(src)
|
||||
cumulative_sum += src
|
||||
valid_data_count += 1
|
||||
valid_data_count > 0 ? cumulative_sum / valid_data_count : na
|
||||
|
||||
// ---------- Main loop ----------
|
||||
|
||||
// Inputs
|
||||
i_source = input.source(close, "Source")
|
||||
|
||||
// Calculation
|
||||
cummean_value = cummean(i_source)
|
||||
|
||||
// Plot
|
||||
plot(cummean_value, "CumMean", color=color.new(color.blue, 0, color=color.yellow, linewidth=2), linewidth=2)
|
||||
Reference in New Issue
Block a user