docs: update category index files and fix indicator implementations (#58)

This commit is contained in:
Miha Kralj
2026-01-19 18:25:48 -08:00
committed by GitHub
parent e966000d48
commit b2c1787782
29 changed files with 566 additions and 1667 deletions
+178 -149
View File
@@ -24,292 +24,321 @@
| Indicator | Full Name | Category | | Indicator | Full Name | Category |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| [ABBER](lib/channels/abber/abber.md) | Aberration Bands | Channels | | [ABBER](lib/channels/abber/Abber.md) | Aberration Bands | Channels |
| AC | Acceleration Oscillator | Momentum | | AC | Acceleration Oscillator | Oscillators |
| [ACCBANDS](lib/channels/accbands/accbands.md) | Acceleration Bands | Channels | | [ACCBANDS](lib/channels/accbands/Accbands.md) | Acceleration Bands | Channels |
| ACCEL | Momentum change; 2nd derivative | Numerics | | [ACCEL](lib/numerics/accel/Accel.md) | Acceleration | Numerics |
| ACF | Autocorrelation Function | Statistics |
| [ADL](lib/volume/adl/Adl.md) | Accumulation/Distribution Line | Volume | | [ADL](lib/volume/adl/Adl.md) | Accumulation/Distribution Line | Volume |
| [ADOSC](lib/volume/adosc/Adosc.md) | Chaikin A/D Oscillator | Volume | | [ADOSC](lib/volume/adosc/Adosc.md) | Chaikin A/D Oscillator | Volume |
| [ADR](lib/volatility/adr/Adr.md) | Average Daily Range | Volatility | | [ADR](lib/volatility/adr/Adr.md) | Average Daily Range | Volatility |
| [ADX](lib/dynamics/adx/Adx.md) | Average Directional Index | Dynamics | | [ADX](lib/dynamics/adx/Adx.md) | Average Directional Index | Dynamics |
| [ADXR](lib/dynamics/adxr/Adxr.md) | Average Directional Movement Rating | Dynamics | | [ADXR](lib/dynamics/adxr/Adxr.md) | Average Directional Movement Rating | Dynamics |
| [AFIRMA](lib/forecasts/afirma/Afirma.md) | Adaptive FIR Moving Average | Forecasts | | [AFIRMA](lib/forecasts/afirma/Afirma.md) | Adaptive FIR Moving Average | Forecasts |
| ALLIGATOR | Williams Alligator | Trends (IIR) | | ALLIGATOR | Williams Alligator | Dynamics |
| [ALMA](lib/trends_FIR/alma/Alma.md) | Arnaud Legoux MA | Trends (FIR) | | [ALMA](lib/trends_FIR/alma/Alma.md) | Arnaud Legoux MA | Trends (FIR) |
| [AMAT](lib/dynamics/amat/Amat.md) | Archer Moving Averages Trends | Dynamics | | [AMAT](lib/dynamics/amat/Amat.md) | Archer Moving Averages Trends | Dynamics |
| [AO](lib/oscillators/ao/Ao.md) | Awesome Oscillator | Oscillators | | [AO](lib/oscillators/ao/Ao.md) | Awesome Oscillator | Oscillators |
| AOBV | Archer On-Balance Volume | Volume | | [AOBV](lib/volume/aobv/Aobv.md) | Archer On-Balance Volume | Volume |
| APCHANNEL | Andrews' Pitchfork | Channels | | [APCHANNEL](lib/channels/apchannel/Apchannel.md) | Andrews' Pitchfork | Channels |
| [APO](lib/oscillators/apo/Apo.md) | Absolute Price Oscillator | Oscillators | | APO | Absolute Price Oscillator | Momentum |
| [APZ](lib/channels/apz/apz.md) | Adaptive Price Zone | Channels | | [APZ](lib/channels/apz/Apz.md) | Adaptive Price Zone | Channels |
| [AROON](lib/dynamics/aroon/Aroon.md) | Aroon | Dynamics | | [AROON](lib/dynamics/aroon/Aroon.md) | Aroon | Dynamics |
| [AROONOSC](lib/dynamics/aroonosc/AroonOsc.md) | Aroon Oscillator | Dynamics | | [AROONOSC](lib/dynamics/aroonosc/Aroonosc.md) | Aroon Oscillator | Dynamics |
| ATAN2 | Two-Argument Arctangent | Numerics |
| [ATR](lib/volatility/atr/Atr.md) | Average True Range | Volatility | | [ATR](lib/volatility/atr/Atr.md) | Average True Range | Volatility |
| ATRBANDS | ATR Bands | Channels | | [ATRBANDS](lib/channels/atrbands/Atrbands.md) | ATR Bands | Channels |
| [ATRN](lib/volatility/atrn/Atrn.md) | Average True Range Normalized [0,1] | Volatility | | [ATRN](lib/volatility/atrn/Atrn.md) | ATR Normalized | Volatility |
| [ATRP](lib/volatility/atrp/Atrp.md) | Average True Range Percent | Volatility | | [ATRP](lib/volatility/atrp/Atrp.md) | ATR Percent | Volatility |
| BBI | Bulls Bears Index | Oscillators |
| BBANDS | Bollinger Bands | Channels | | BBANDS | Bollinger Bands | Channels |
| BBB | Bollinger %B | Momentum | | BBB | Bollinger %B | Oscillators |
| BBS | Bollinger Band Squeeze | Momentum | | BBS | Bollinger Band Squeeze | Oscillators |
| BBW | Bollinger Band Width | Volatility | | BBW | Bollinger Band Width | Volatility |
| BBWN | Bollinger Band Width Normalized | Volatility | | BBWN | BB Width Normalized | Volatility |
| BBWP | Bollinger Band Width Percentile | Volatility | | BBWP | BB Width Percentile | Volatility |
| [BESSEL](lib/filters/bessel/Bessel.md) | Bessel Filter | Filters | | [BESSEL](lib/filters/bessel/Bessel.md) | Bessel Filter | Filters |
| BETA | Beta Coefficient | Statistics | | [BETA](lib/statistics/beta/Beta.md) | Beta Coefficient | Statistics |
| BETADIST | Beta Distribution | Numerics |
| BIAS | Bias | Statistics | | BIAS | Bias | Statistics |
| [BILATERAL](lib/filters/bilateral/Bilateral.md) | Bilateral Filter | Filters | | [BILATERAL](lib/filters/bilateral/Bilateral.md) | Bilateral Filter | Filters |
| [BLMA](lib/trends_FIR/blma/Blma.md) | Blackman Window MA | Trends (FIR) | | BINOMDIST | Binomial Distribution | Numerics |
| BOP | Balance of Power | Momentum | | [BLMA](lib/trends_FIR/blma/Blma.md) | Blackman MA | Trends (FIR) |
| BPF | Ehlers Bandpass Filter | Filters | | [BOP](lib/momentum/bop/Bop.md) | Balance of Power | Momentum |
| [BPF](lib/filters/bpf/Bpf.md) | BandPass Filter | Filters |
| BRAR | BRAR | Oscillators |
| [BUTTER](lib/filters/butter/Butter.md) | Butterworth Filter | Filters | | [BUTTER](lib/filters/butter/Butter.md) | Butterworth Filter | Filters |
| BWMA | Bessel-Weighted MA | Trends (FIR) | | [BWMA](lib/trends_FIR/bwma/Bwma.md) | Bessel-Weighted MA | Trends (FIR) |
| CCI | Commodity Channel Index | Momentum | | CCI | Commodity Channel Index | Momentum |
| CCV | Close-to-Close Volatility | Volatility | | CCV | Close-to-Close Volatility | Volatility |
| [CFB](lib/momentum/cfb/Cfb.md) | Jurik Composite Fractal Behavior | Cycles | | [CFB](lib/momentum/cfb/Cfb.md) | Composite Fractal Behavior | Momentum |
| CFO | Chande Forecast Oscillator | Forecasts | | CFO | Chande Forecast Oscillator | Oscillators |
| CG | Ehlers Center of Gravity | Cycles | | CG | Center of Gravity | Cycles |
| CHANGE | Percentage Change | Numerics | | CHANDELIER | Chandelier Exit | Reversals |
| [CHEBY1](lib/filters/cheby1/Cheby1.md) | Chebyshev Type I Filter | Filters | | [CHANGE](lib/numerics/change/Change.md) | Percentage Change | Numerics |
| CHEBY2 | Chebyshev Type II Filter | Filters | | [CHEBY1](lib/filters/cheby1/Cheby1.md) | Chebyshev Type I | Filters |
| [CHEBY2](lib/filters/cheby2/Cheby2.md) | Chebyshev Type II | Filters |
| CHOP | Choppiness Index | Dynamics | | CHOP | Choppiness Index | Dynamics |
| CKSTOP | Chande Kroll Stop | Reversals |
| [CMA](lib/statistics/cma/Cma.md) | Cumulative Moving Average | Statistics |
| CMF | Chaikin Money Flow | Volume | | CMF | Chaikin Money Flow | Volume |
| CMO | Chande Momentum Oscillator | Oscillators | | CMO | Chande Momentum Oscillator | Momentum |
| COINTEGRATION | Cointegration | Statistics | | COINTEGRATION | Cointegration | Statistics |
| [CONV](lib/trends_FIR/conv/Conv.md) | Convolution MA with any kernel | Trends (FIR) | | [CONV](lib/trends_FIR/conv/Conv.md) | Convolution MA | Trends (FIR) |
| CORRELATION | Correlation (Pearson's) | Statistics | | COPPOCK | Coppock Curve | Oscillators |
| COVARIANCE | Covariance | Statistics | | CORRELATION | Correlation | Statistics |
| CUMMEAN | Cumulative Mean (Average) | Statistics | | [COVARIANCE](lib/statistics/covariance/Covariance.md) | Covariance | Statistics |
| CRSI | Connors RSI | Oscillators |
| CTI | Correlation Trend Indicator | Oscillators |
| CUMMEAN | Cumulative Mean | Statistics |
| CV | Conditional Volatility | Volatility | | CV | Conditional Volatility | Volatility |
| CVI | Chaikin's Volatility | Volatility | | CVI | Chaikin Volatility | Volatility |
| CWT | Continuous Wavelet Transform | Numerics |
| DCHANNEL | Donchian Channels | Channels | | DCHANNEL | Donchian Channels | Channels |
| DECAYCHANNEL | Decay Min-Max Channel | Channels | | DECAYCHANNEL | Decay Min-Max Channel | Channels |
| [DEMA](lib/trends_IIR/dema/Dema.md) | Double Exponential MA | Trends (IIR) | | [DEMA](lib/trends_IIR/dema/Dema.md) | Double Exponential MA | Trends (IIR) |
| DIRTY | Dirty Data Detection | Errors |
| [DMX](lib/dynamics/dmx/Dmx.md) | Jurik Directional Movement Index | Dynamics | | [DMX](lib/dynamics/dmx/Dmx.md) | Jurik Directional Movement Index | Dynamics |
| DOSC | Derivative Oscillator | Oscillators |
| DPO | Detrended Price Oscillator | Oscillators | | DPO | Detrended Price Oscillator | Oscillators |
| DSMA | Deviation-Scaled MA | Trends (IIR) | | [DSMA](lib/trends_IIR/dsma/Dsma.md) | Deviation-Scaled MA | Trends (IIR) |
| DSP | Detrended Synthetic Price | Cycles | | DSP | Detrended Synthetic Price | Cycles |
| [DWMA](lib/trends_FIR/dwma/Dwma.md) | Double Weighted MA | Trends (FIR) | | [DWMA](lib/trends_FIR/dwma/Dwma.md) | Double Weighted MA | Trends (FIR) |
| DWT | Discrete Wavelet Transform | Numerics |
| DX | Directional Movement Index | Dynamics | | DX | Directional Movement Index | Dynamics |
| EACP | Ehlers Autocorrelation Periodogram | Cycles | | EACP | Autocorrelation Periodogram | Cycles |
| EBSW | Ehlers Even Better Sinewave | Cycles | | EBSW | Even Better Sinewave | Cycles |
| EFI | Elder's Force Index | Volume | | EFI | Elder's Force Index | Volume |
| ELLIPTIC | Elliptic (Cauer) Filter | Filters | | [ELLIPTIC](lib/filters/elliptic/Elliptic.md) | Elliptic Filter | Filters |
| [EMA](lib/trends_IIR/ema/Ema.md) | Exponential MA | Trends (IIR) | | [EMA](lib/trends_IIR/ema/Ema.md) | Exponential MA | Trends (IIR) |
| ENTROPY | Normalized Shannon Entropy | Statistics | | ENTROPY | Shannon Entropy | Statistics |
| EOME | Ease of Movement | Volume | | EOM | Ease of Movement | Volume |
| EPMA | Endpoint MA | Trends (FIR) | | ER | Efficiency Ratio | Oscillators |
| EWMA | Exponential Weighted MA Volatility | Volatility | | ERI | Elder Ray Index | Oscillators |
| EXP | Exponential Transformation | Numerics | | EWMA | EWMA Volatility | Volatility |
| EXPDIST | Exponential Distribution | Numerics |
| [EXPTRANS](lib/numerics/exptrans/Exptrans.md) | Exponential Transform | Numerics |
| FCB | Fractal Chaos Bands | Channels | | FCB | Fractal Chaos Bands | Channels |
| FISHER | Ehlers Fisher Transform | Numerics | | FDIST | F-Distribution | Numerics |
| FFT | Fast Fourier Transform | Numerics |
| FISHER | Fisher Transform | Oscillators |
| FOSC | Forecast Oscillator | Oscillators |
| FRACTALS | Williams Fractals | Reversals | | FRACTALS | Williams Fractals | Reversals |
| [FRAMA](lib/trends_IIR/frama/Frama.md) | Ehlers Fractal Adaptive MA | Trends (IIR) | | [FRAMA](lib/trends_IIR/frama/Frama.md) | Fractal Adaptive MA | Trends (IIR) |
| GAUSS | Gaussian Filter | Filters | | GAMMADIST | Gamma Distribution | Numerics |
| [GAUSS](lib/filters/gauss/Gauss.md) | Gaussian Filter | Filters |
| GEOMEAN | Geometric Mean | Statistics | | GEOMEAN | Geometric Mean | Statistics |
| GKV | Garman-Klass Volatility | Volatility | | GKV | Garman-Klass Volatility | Volatility |
| GRANGER | Granger Causality Test | Statistics | | GRANGER | Granger Causality | Statistics |
| GWMA | Gaussian-Weighted MA | Trends (FIR) | | [GWMA](lib/trends_FIR/gwma/Gwma.md) | Gaussian Weighted MA | Trends (FIR) |
| HAMMA | Hamming Window MA | Trends (FIR) | | [HAMMA](lib/trends_FIR/hamma/Hamma.md) | Hamming MA | Trends (FIR) |
| HANMA | Hanning Window MA | Trends (FIR) | | [HANN](lib/filters/hann/Hann.md) | Hann Filter | Filters |
| HANN | Hann FIR Filter | Filters | | [HANMA](lib/trends_FIR/hanma/Hanma.md) | Hanning MA | Trends (FIR) |
| HARMEAN | Harmonic Mean | Statistics | | HARMEAN | Harmonic Mean | Statistics |
| [HEMA](lib/trends_IIR/hema/Hema.md) | Hull Exponential MA | Trends (IIR) | | [HEMA](lib/trends_IIR/hema/Hema.md) | Hull Exponential MA | Trends (IIR) |
| HIGHEST | Highest value | Numerics | | [HIGHEST](lib/numerics/highest/Highest.md) | Rolling Maximum | Numerics |
| HL2 | (High + Low) / 2 | Numerics |
| HLC3 | (High + Low + Close) / 3 | Numerics |
| HLCC4 | (High + Low + Close + Close) / 4 | Numerics |
| HLV | High-Low Volatility | Volatility | | HLV | High-Low Volatility | Volatility |
| [HMA](lib/trends_FIR/hma/Hma.md) | Hull MA | Trends (FIR) | | [HMA](lib/trends_FIR/hma/Hma.md) | Hull MA | Trends (FIR) |
| HOMOD | Homodyne Discriminator Dominant Cycle | Cycles | | HOMOD | Homodyne Discriminator | Cycles |
| HP | Hodrick-Prescott Filter | Filters | | [HP](lib/filters/hp/Hp.md) | Hodrick-Prescott | Filters |
| HPF | Ehlers Highpass Filter | Filters | | [HPF](lib/filters/hpf/Hpf.md) | High Pass Filter | Filters |
| [HTIT](lib/trends_IIR/htit/Htit.md) | Ehlers Hilbert Transform Instantaneous Trend | Trends (IIR) | | [HTIT](lib/trends_IIR/htit/Htit.md) | Hilbert Transform Instantaneous Trend | Trends (IIR) |
| HT_DCPERIOD | Ehlers Hilbert Transform Dominant Cycle Period | Cycles | | HT_DCPERIOD | HT Dominant Cycle Period | Cycles |
| HT_DCPHASE | Ehlers Hilbert Transform Dominant Cycle Phase | Cycles | | HT_DCPHASE | HT Dominant Cycle Phase | Cycles |
| HT_PHASOR | Ehlers Hilbert Transform Phasor Components | Cycles | | HT_PHASOR | HT Phasor Components | Cycles |
| HT_SINE | Ehlers Hilbert Transform SineWave | Cycles | | HT_SINE | HT SineWave | Cycles |
| HT_TRENDMODE | Ehlers Hilbert Transform Trend Mode | Dynamics | | HT_TRENDMODE | HT Trend vs Cycle | Dynamics |
| [HUBER](lib/errors/huber/Huber.md) | Huber Loss | Errors | | [HUBER](lib/errors/huber/Huber.md) | Huber Loss | Errors |
| HURST | Hurst | Statistics | | HURST | Hurst Exponent | Statistics |
| HV | Historical Volatility | Volatility | | HV | Historical Volatility | Volatility |
| HWMA | Holt Weighted MA | Trends (IIR) | | [HWMA](lib/trends_FIR/hwma/Hwma.md) | Holt-Winters MA | Trends (FIR) |
| ICHIMOKU | Ichimoku Cloud | Trends (IIR) | | ICHIMOKU | Ichimoku Cloud | Dynamics |
| IFFT | Inverse Fast Fourier Transform | Numerics |
| III | Intraday Intensity Index | Volume | | III | Intraday Intensity Index | Volume |
| IMI | Intraday Momentum Index | Momentum | | IMI | Intraday Momentum Index | Dynamics |
| INERTIA | Inertia | Momentum | | IMPULSE | Elder Impulse System | Dynamics |
| INERTIA | Inertia | Oscillators |
| IQR | Interquartile Range | Statistics | | IQR | Interquartile Range | Statistics |
| JB | Jarque-Bera Test | Statistics | | JB | Jarque-Bera Test | Statistics |
| JBANDS | Jurik Volatility Bands | Channels | | JBANDS | Jurik Volatility Bands | Channels |
| [JERK](lib/numerics/jerk/Jerk.md) | Jerk | Numerics |
| [JMA](lib/trends_IIR/jma/Jma.md) | Jurik MA | Trends (IIR) | | [JMA](lib/trends_IIR/jma/Jma.md) | Jurik MA | Trends (IIR) |
| JERK | Rate of acceleration; 3rd derivative | Numerics |
| JVOLTY | Jurik Volatility | Volatility | | JVOLTY | Jurik Volatility | Volatility |
| JVOLTYN | Jurik Volatility Normalized [0,1] | Volatility | | JVOLTYN | Jurik Volatility Normalized | Volatility |
| [KALMAN](lib/filters/kalman/Kalman.md) | Kalman Filter | Filters |
| [KAMA](lib/trends_IIR/kama/Kama.md) | Kaufman Adaptive MA | Trends (IIR) | | [KAMA](lib/trends_IIR/kama/Kama.md) | Kaufman Adaptive MA | Trends (IIR) |
| KCHANNEL | Keltner Channel | Channels | | KCHANNEL | Keltner Channel | Channels |
| KDJ | KDJ Indicator | Momentum | | KDJ | KDJ Indicator | Oscillators |
| KENDALL | Kendall Rank Correlation | Statistics | | KENDALL | Kendall Rank Correlation | Statistics |
| KF | Kalman Filter | Filters | | KRI | Kairi Relative Index | Oscillators |
| KST | KST Oscillator | Oscillators |
| KURTOSIS | Kurtosis | Statistics | | KURTOSIS | Kurtosis | Statistics |
| KVO | Klinger Volume Oscillator | Volume | | KVO | Klinger Volume Oscillator | Volume |
| LINEAR | Linear Transformation | Numerics | | [LINEARTRANS](lib/numerics/lineartrans/Lineartrans.md) | Linear Transform | Numerics |
| [LOGCOSH](lib/errors/logcosh/LogCosh.md) | Log-Cosh Loss | Errors | | [LINREG](lib/statistics/linreg/LinReg.md) | Linear Regression | Statistics |
| LINREG | Linear Regression Curve | Statistics | | [LOESS](lib/filters/loess/Loess.md) | LOESS Smoothing | Filters |
| LOESS | LOESS/LOWESS Smoothing | Filters | | [LOGCOSH](lib/errors/logcosh/Logcosh.md) | Log-Cosh Loss | Errors |
| LOG | Logarithmic Transformation | Numerics | | LOGNORMDIST | Log-normal Distribution | Numerics |
| LOWEST | Lowest value | Numerics | | [LOGTRANS](lib/numerics/logtrans/Logtrans.md) | Logarithmic Transform | Numerics |
| [LSMA](lib/trends_FIR/lsma/Lsma.md) | Least Squares Moving Average | Trends (FIR) | | [LOWEST](lib/numerics/lowest/Lowest.md) | Rolling Minimum | Numerics |
| LTMA | Linear Trend MA | Trends (FIR) | | [LSMA](lib/trends_FIR/lsma/Lsma.md) | Least Squares MA | Trends (FIR) |
| LTMA | Linear Trend MA | Trends (IIR) |
| LUNAR | Lunar Phase | Cycles | | LUNAR | Lunar Phase | Cycles |
| [MAAPE](lib/errors/mape/Maape.md) | Mean Arctangent Absolute Percentage Error | Errors | | [MAAPE](lib/errors/maape/Maape.md) | Mean Arctangent APE | Errors |
| MACD | Moving Average Convergence Divergence | Oscillators | | [MACD](lib/momentum/macd/Macd.md) | Moving Average Convergence Divergence | Momentum |
| [MAE](lib/errors/mae/Mae.md) | Mean Absolute Error | Errors | | [MAE](lib/errors/mae/Mae.md) | Mean Absolute Error | Errors |
| MAENV | Moving Average Envelope | Channels | | MAENV | Moving Average Envelope | Channels |
| [MAMA](lib/trends_IIR/mama/Mama.md) | Ehlers MESA Adaptive MA | Trends (IIR) | | [MAMA](lib/trends_IIR/mama/Mama.md) | MESA Adaptive MA | Trends (IIR) |
| [MAPD](lib/errors/mapd/Mapd.md) | Mean Absolute Percentage Deviation | Errors | | [MAPD](lib/errors/mapd/Mapd.md) | Mean Absolute % Deviation | Errors |
| [MAPE](lib/errors/mape/Mape.md) | Mean Absolute Percentage Error | Errors | | [MAPE](lib/errors/mape/Mape.md) | Mean Absolute % Error | Errors |
| [MASE](lib/errors/mase/Mase.md) | Mean Absolute Scaled Error | Errors | | [MASE](lib/errors/mase/Mase.md) | Mean Absolute Scaled Error | Errors |
| MASS | Mass Index | Volatility | | MASSI | Mass Index | Volatility |
| [MDAE](lib/errors/mdae/Mdae.md) | Median Absolute Error | Errors | | [MDAE](lib/errors/mdae/Mdae.md) | Median Absolute Error | Errors |
| [MDAPE](lib/errors/mdape/Mdape.md) | Median Absolute Percentage Error | Errors | | [MDAPE](lib/errors/mdape/Mdape.md) | Median Absolute % Error | Errors |
| [ME](lib/errors/me/Me.md) | Mean Error | Errors | | [ME](lib/errors/me/Me.md) | Mean Error | Errors |
| [MEDIAN](lib/statistics/median/Median.md) | Median (Statistical) | Statistics | | [MEDIAN](lib/statistics/median/Median.md) | Median | Statistics |
| MFI | Money Flow Index | Volume | | MFI | Money Flow Index | Volume |
| [MGDI](lib/trends_IIR/mgdi/Mgdi.md) | McGinley Dynamic Indicator | Trends (IIR) | | [MGDI](lib/trends_IIR/mgdi/Mgdi.md) | McGinley Dynamic Indicator | Trends (IIR) |
| MIDPOINT | (Highest + Lowest) / 2 | Numerics | | [MIDPOINT](lib/numerics/midpoint/Midpoint.md) | Midrange | Numerics |
| MLP | Multilayer Perceptron | Forecasts |
| [MMA](lib/trends_IIR/mma/Mma.md) | Modified MA | Trends (IIR) | | [MMA](lib/trends_IIR/mma/Mma.md) | Modified MA | Trends (IIR) |
| MMCHANNEL | Min-Max Channel | Channels | | MMCHANNEL | Min-Max Channel | Channels |
| MODE | Mode (Most Frequent) | Statistics | | MODE | Mode | Statistics |
| MOM | Momentum | Momentum | | MOM | Momentum | Momentum |
| MOON | Moon Phase | Cycles |
| [MPE](lib/errors/mpe/Mpe.md) | Mean Percentage Error | Errors | | [MPE](lib/errors/mpe/Mpe.md) | Mean Percentage Error | Errors |
| [MRAE](lib/errors/mrae/Mrae.md) | Mean Relative Absolute Error | Errors | | [MRAE](lib/errors/mrae/Mrae.md) | Mean Relative Absolute Error | Errors |
| [MSE](lib/errors/mse/Mse.md) | Mean Squared Error | Errors | | [MSE](lib/errors/mse/Mse.md) | Mean Squared Error | Errors |
| [MSLE](lib/errors/msle/Msle.md) | Mean Squared Logarithmic Error | Errors | | [MSLE](lib/errors/msle/Msle.md) | Mean Squared Log Error | Errors |
| NATR | Normalized Average True Range | Volatility | | NATR | Normalized ATR | Volatility |
| NORMALIZE | Min-Max Scaling (Normalization) | Numerics | | NORMDIST | Normal Distribution | Numerics |
| NOTCH | Notch Filter | Filters | | [NORMALIZE](lib/numerics/normalize/Normalize.md) | Min-Max Normalization | Numerics |
| [NOTCH](lib/filters/notch/Notch.md) | Notch Filter | Filters |
| NVI | Negative Volume Index | Volume | | NVI | Negative Volume Index | Volume |
| OBV | On Balance Volume | Volume | | OBV | On Balance Volume | Volume |
| OC2 | (Open + Close) / 2 | Numerics | | PACF | Partial Autocorrelation | Statistics |
| OHL3 | (Open + High + Low) / 3 | Numerics |
| OHLC4 | (Open + High + Low + Close) / 4 | Numerics |
| PCHANNEL | Price Channel | Channels | | PCHANNEL | Price Channel | Channels |
| PERCENTILE | Percentile | Statistics | | PERCENTILE | Percentile | Statistics |
| PGO | Pretty Good Oscillator | Oscillators | | PGO | Pretty Good Oscillator | Oscillators |
| PHASOR | Ehlers Phasor Analysis | Cycles | | PHASOR | Phasor Analysis | Cycles |
| PIVOT | Pivot Points (Classic) | Reversals | | PIVOT | Pivot Points (Classic) | Reversals |
| PIVOTCAM | Camarilla Pivot Points | Reversals | | PIVOTCAM | Camarilla Pivot Points | Reversals |
| PIVOTDEM | DeMark Pivot Points | Reversals | | PIVOTDEM | DeMark Pivot Points | Reversals |
| PIVOTEXT | Extended Traditional Pivots | Reversals | | PIVOTEXT | Extended Traditional Pivots | Reversals |
| PIVOTFIB | Fibonacci Pivot Points | Reversals | | PIVOTFIB | Fibonacci Pivot Points | Reversals |
| PIVOTWOOD | Woodie's Pivot Points | Reversals | | PIVOTWOOD | Woodie's Pivot Points | Reversals |
| PMO | Price Momentum Oscillator | Oscillators | | PMO | Price Momentum Oscillator | Momentum |
| PPO | Percentage Price Oscillator | Oscillators | | POISSONDIST | Poisson Distribution | Numerics |
| POLYFIT | Polynomial Fitting | Statistics |
| PPO | Percentage Price Oscillator | Momentum |
| PRS | Price Relative Strength | Momentum | | PRS | Price Relative Strength | Momentum |
| PSAR | Parabolic Stop And Reverse | Trends (IIR) | | PSAR | Parabolic Stop And Reverse | Reversals |
| PSL | Psychological Line | Oscillators |
| [PSEUDOHUBER](lib/errors/pseudohuber/Pseudohuber.md) | Pseudo-Huber Loss | Errors |
| PV | Parkinson Volatility | Volatility | | PV | Parkinson Volatility | Volatility |
| PVD | Price Volume Divergence | Volume | | PVD | Price Volume Divergence | Volume |
| PVI | Positive Volume Index | Volume | | PVI | Positive Volume Index | Volume |
| PVO | Percentage Volume Oscillator | Oscillators | | PVO | Percentage Volume Oscillator | Volume |
| PVR | Price Volume Rank | Volume | | PVR | Price Volume Rank | Volume |
| [PSEUDOHUBER](lib/errors/pseudohuber/PseudoHuber.md) | Pseudo-Huber Loss | Errors |
| PVT | Price Volume Trend | Volume | | PVT | Price Volume Trend | Volume |
| [PWMA](lib/trends_FIR/pwma/Pwma.md) | Pascal Weighted MA | Trends (FIR) | | [PWMA](lib/trends_FIR/pwma/Pwma.md) | Pascal Weighted MA | Trends (FIR) |
| [QEMA](lib/trends_IIR/qema/Qema.md) | Quadruple Exponential MA | Trends (IIR) | | [QEMA](lib/trends_IIR/qema/Qema.md) | Quad Exponential MA | Trends (IIR) |
| QSTICK | Qstick Indicator | Momentum | | QQE | Quantitative Qualitative Estimation | Oscillators |
| QSTICK | Qstick | Dynamics |
| QUANTILE | Quantile | Statistics | | QUANTILE | Quantile | Statistics |
| [QUANTILELOSS](lib/errors/quantile/QuantileLoss.md) | Quantile Loss | Errors | | [QUANTILELOSS](lib/errors/quantile/Quantile.md) | Quantile Loss | Errors |
| [RAE](lib/errors/rae/Rae.md) | Relative Absolute Error | Errors | | [RAE](lib/errors/rae/Rae.md) | Relative Absolute Error | Errors |
| REGCHANNEL | Regression Channels | Channels | | REGCHANNEL | Regression Channels | Channels |
| RELU | Rectified Linear Unit | Numerics | | [RELU](lib/numerics/relu/Relu.md) | Rectified Linear Unit | Numerics |
| [REMA](lib/trends_IIR/rema/Rema.md) | Regularized Exponential MA | Trends (IIR) | | [REMA](lib/trends_IIR/rema/Rema.md) | Regularized Exponential MA | Trends (IIR) |
| [RGMA](lib/trends_IIR/rgma/Rgma.md) | Recursive Gaussian MA | Trends (IIR) | | [RGMA](lib/trends_IIR/rgma/Rgma.md) | Recursive Gaussian MA | Trends (IIR) |
| [RMA](lib/trends_IIR/rma/Rma.md) | wildeR MA (SMMA, MMA) | Trends (IIR) | | [RMA](lib/trends_IIR/rma/Rma.md) | wildeR MA | Trends (IIR) |
| [RMSE](lib/errors/rmse/Rmse.md) | Root Mean Squared Error | Errors | | [RMSE](lib/errors/rmse/Rmse.md) | Root Mean Squared Error | Errors |
| [RMSLE](lib/errors/rmsle/Rmsle.md) | Root Mean Squared Logarithmic Error | Errors | | [RMSLE](lib/errors/rmsle/Rmsle.md) | Root Mean Squared Log Error | Errors |
| [ROC](lib/momentum/roc/Roc.md) | Rate of Change | Momentum | | [ROC](lib/momentum/roc/Roc.md) | Rate of Change | Momentum |
| ROCP | Rate of Change Percentage | Momentum | | ROCP | Rate of Change Percentage | Momentum |
| ROCR | Rate of Change Ratio | Momentum | | ROCR | Rate of Change Ratio | Momentum |
| [RSE](lib/errors/rse/Rse.md) | Relative Squared Error | Errors | | [RSE](lib/errors/rse/Rse.md) | Relative Squared Error | Errors |
| RSI | Relative Strength Index | Oscillators | | [RSI](lib/momentum/rsi/Rsi.md) | Relative Strength Index | Momentum |
| [RSQUARED](lib/errors/rsquared/Rsquared.md) | Coefficient of Determination (R²) | Errors | | [RSQUARED](lib/errors/rsquared/Rsquared.md) | R² (Coefficient of Determination) | Errors |
| RSV | Rogers-Satchell Volatility | Volatility | | RSV | Rogers-Satchell Volatility | Volatility |
| [RSX](lib/momentum/rsx/Rsx.md) | Jurik Relative Strength Quality Index | Oscillators | | [RSX](lib/momentum/rsx/Rsx.md) | Relative Strength Quality Index | Momentum |
| RV | Realized Volatility | Volatility | | RV | Realized Volatility | Volatility |
| RVI | Relative Volatility Index | Volatility | | RVI | Relative Volatility Index | Volatility |
| RVGI | Relative Vigor Index | Oscillators |
| SDCHANNEL | Standard Deviation Channel | Channels | | SDCHANNEL | Standard Deviation Channel | Channels |
| SGF | Savitzky-Golay Filter | Filters | | [SGF](lib/filters/sgf/Sgf.md) | Savitzky-Golay Filter | Filters |
| [SGMA](lib/trends_FIR/sgma/Sgma.md) | Savitzky-Golay MA | Trends (FIR) | | [SGMA](lib/trends_FIR/sgma/Sgma.md) | Savitzky-Golay MA | Trends (FIR) |
| SIGMOID | Logistic Function | Numerics | | [SIGMOID](lib/numerics/sigmoid/Sigmoid.md) | Logistic Function | Numerics |
| SINE | Ehlers Sine Wave | Cycles | | SINE | Sine Wave | Cycles |
| SINEMA | Sine-weighted MA | Trends (FIR) | | [SINEMA](lib/trends_FIR/sinema/Sinema.md) | Sine-Weighted MA | Trends (FIR) |
| SKEW | Skewness | Statistics | | [SKEW](lib/statistics/skew/Skew.md) | Skewness | Statistics |
| SLOPE | Rate of change; 1st derivative | Numerics | | [SLOPE](lib/numerics/slope/Slope.md) | Rate of Change | Numerics |
| [SMA](lib/trends_FIR/sma/Sma.md) | Simple MA | Trends (FIR) | | [SMA](lib/trends_FIR/sma/Sma.md) | Simple MA | Trends (FIR) |
| [SMAPE](lib/errors/smape/Smape.md) | Symmetric Mean Absolute Percentage Error | Errors | | [SMAPE](lib/errors/smape/Smape.md) | Symmetric MAPE | Errors |
| SMI | Stochastic Momentum Index | Oscillators | | SMI | Stochastic Momentum Index | Oscillators |
| SOLAR | Solar Activity Cycle | Cycles | | SOLAR | Solar Activity Cycle | Cycles |
| SPEARMAN | Spearman Rank Correlation | Statistics | | SPEARMAN | Spearman Rank Correlation | Statistics |
| SQRT | Square Root Transformation | Numerics | | SQUEEZE | Squeeze | Oscillators |
| [SSF](lib/filters/ssf/Ssf.md) | Ehlers Super Smooth Filter | Filters | | [SQRTTRANS](lib/numerics/sqrttrans/Sqrttrans.md) | Square Root Transform | Numerics |
| SSFDSP | Ehlers SSF-Based Detrended Synthetic Price | Cycles | | [SSF](lib/filters/ssf/Ssf.md) | Super Smoother | Filters |
| STANDARDIZE | Standardization (Z-score) | Numerics | | SSFDSP | SSF Detrended Synthetic Price | Cycles |
| STARC | Starc Bands | Channels | | STANDARDIZE | Z-Score Normalization | Numerics |
| STARCHANNEL | Stoller Average Range Channel | Channels | | STARCHANNEL | Stoller Average Range Channel | Channels |
| STBANDS | Super Trend Bands | Channels | | STBANDS | Super Trend Bands | Channels |
| STC | Schaff Trend Cycle | Oscillators | | STC | Schaff Trend Cycle | Cycles |
| STDDEV | Standard Deviation | Statistics | | [STDDEV](lib/statistics/stddev/StdDev.md) | Standard Deviation | Statistics |
| STOCH | Stochastic Oscillator | Oscillators | | STOCH | Stochastic Oscillator | Oscillators |
| STOCHF | Stochastic Fast | Oscillators | | STOCHF | Stochastic Fast | Oscillators |
| STOCHRSI | Stochastic RSI | Oscillators | | STOCHRSI | Stochastic RSI | Oscillators |
| [SUPER](lib/dynamics/super/Super.md) | SuperTrend | Dynamics | | [SUM](lib/statistics/sum/Sum.md) | Rolling Sum | Statistics |
| SUPER | SuperTrend | Dynamics |
| SWINGS | Swing High/Low Detection | Reversals | | SWINGS | Swing High/Low Detection | Reversals |
| [T3](lib/trends_IIR/t3/T3.md) | Tillson T3 MA | Trends (IIR) | | [T3](lib/trends_IIR/t3/T3.md) | Tillson T3 MA | Trends (IIR) |
| TANH | Hyperbolic Tangent | Numerics | | TDIST | Student's t-Distribution | Numerics |
| TD_SEQ | TD Sequential | Oscillators |
| [TEMA](lib/trends_IIR/tema/Tema.md) | Triple Exponential MA | Trends (IIR) | | [TEMA](lib/trends_IIR/tema/Tema.md) | Triple Exponential MA | Trends (IIR) |
| THEIL | Theil Index | Statistics | | THEIL | Theil Index | Statistics |
| [THEILU](lib/errors/theilu/TheilU.md) | Theil's U Statistic | Errors | | [THEILU](lib/errors/theilu/Theilu.md) | Theil's U Statistic | Errors |
| TR | True Range | Volatility | | TR | True Range | Volatility |
| [TRIMA](lib/trends_FIR/trima/Trima.md) | Triangular MA | Trends (FIR) | | [TRIMA](lib/trends_FIR/trima/Trima.md) | Triangular MA | Trends (FIR) |
| TRIX | Triple Exponential Average | Oscillators | | TRIX | Triple Exponential Average | Oscillators |
| TSF | Time Series Forecast | Forecasts | | TSF | Time Series Forecast | Statistics |
| TSI | True Strength Index | Oscillators | | TSI | True Strength Index | Momentum |
| TTM | TTM Trend | Trends (FIR) | | TTM | TTM Trend | Dynamics |
| [TUKEY](lib/errors/tukey/TukeyBiweight.md) | Tukey Biweight Loss | Errors | | [TUKEY](lib/errors/tukey/Tukey.md) | Tukey Biweight Loss | Errors |
| TVI | Trade Volume Index | Volume | | TVI | Trade Volume Index | Volume |
| TWAP | Time Weighted Average Price | Volume | | TWAP | Time Weighted Average Price | Volume |
| UBANDS | Ultimate Bands | Channels | | UBANDS | Ultimate Bands | Channels |
| UCHANNEL | Ultimate Channel | Channels | | UCHANNEL | Ultimate Channel | Channels |
| UI | Ulcer Index | Volatility | | UI | Ulcer Index | Volatility |
| [ULTOSC](lib/oscillators/ultosc/Ultosc.md) | Ultimate Oscillator | Oscillators | | [ULTOSC](lib/oscillators/ultosc/Ultosc.md) | Ultimate Oscillator | Oscillators |
| [USF](lib/filters/usf/Usf.md) | Ehlers Ultrasmooth Filter | Filters | | [USF](lib/filters/usf/Usf.md) | Ultra Smoother | Filters |
| VA | Volume Accumulation | Volume | | VA | Volume Accumulation | Volume |
| VAMA | Volatility Adjusted Moving Average | Trends (IIR) | | [VAMA](lib/trends_IIR/vama/Vama.md) | Volatility Adjusted MA | Trends (IIR) |
| VARIANCE | Variance | Statistics | | [VARIANCE](lib/statistics/variance/Variance.md) | Variance | Statistics |
| [VEL](lib/momentum/vel/Vel.md) | Jurik Velocity | Momentum | | [VEL](lib/momentum/vel/Vel.md) | Jurik Velocity | Momentum |
| VF | Volume Force | Volume | | VF | Volume Force | Volume |
| [VIDYA](lib/trends_IIR/vidya/Vidya.md) | Variable Index Dynamic Average | Trends (IIR) | | [VIDYA](lib/trends_IIR/vidya/Vidya.md) | Variable Index Dynamic Average | Trends (IIR) |
| VO | Volume Oscillator | Oscillators | | VO | Volume Oscillator | Volume |
| VORTEX | Vortex Indicator | Dynamics | | VORTEX | Vortex Indicator | Dynamics |
| VOV | Volatility of Volatility | Volatility | | VOV | Volatility of Volatility | Volatility |
| VR | Volatility Ratio | Volatility | | VR | Volatility Ratio | Volatility |
| VROC | Volume Rate of Change | Volume | | VROC | Volume Rate of Change | Volume |
| VWAD | Volume Weighted Accumulation/Distribution | Volume | | VWAD | Volume Weighted A/D | Volume |
| VWAP | Volume Weighted Average Price | Volume | | VWAP | Volume Weighted Average Price | Volume |
| VWAPBANDS | VWAP Bands | Channels | | VWAPBANDS | VWAP Bands | Channels |
| VWAPSD | VWAP with Standard Deviation Bands | Channels | | VWAPSD | VWAP Standard Deviation Bands | Channels |
| VWMA | Volume Weighted MA | Trends (FIR) | | VWMA | Volume Weighted MA | Volume |
| WAD | Williams Accumulation/Distribution | Volume | | WAD | Williams A/D | Volume |
| WIENER | Wiener Filter | Filters | | WAVG | Weighted Average | Statistics |
| WEIBULLDIST | Weibull Distribution | Numerics |
| [WIENER](lib/filters/wiener/Wiener.md) | Wiener Filter | Filters |
| WILLR | Williams %R | Oscillators | | WILLR | Williams %R | Oscillators |
| [WMA](lib/trends_FIR/wma/Wma.md) | Weighted MA | Trends (FIR) | | [WMA](lib/trends_FIR/wma/Wma.md) | Weighted MA | Trends (FIR) |
| [WMAPE](lib/errors/wmape/Wmape.md) | Weighted Mean Absolute Percentage Error | Errors | | [WMAPE](lib/errors/wmape/Wmape.md) | Weighted MAPE | Errors |
| [WRMSE](lib/errors/wrmse/Wrmse.md) | Weighted RMSE | Errors |
| YZV | Yang-Zhang Volatility | Volatility | | YZV | Yang-Zhang Volatility | Volatility |
| [YZVAMA](lib/trends_IIR/yzvama/Yzvama.md) | Yang-Zhang Volatility Adjusted MA | Trends (IIR) | | [YZVAMA](lib/trends_IIR/yzvama/Yzvama.md) | Yang-Zhang Volatility Adjusted MA | Trends (IIR) |
| ZLDEMA | Zero-Lag Double Exponential MA | Trends (IIR) | | ZLDEMA | Zero-Lag Double Exponential MA | Trends (IIR) |
| ZLEMA | Zero-Lag Exponential MA | Trends (IIR) | | [ZLEMA](lib/trends_IIR/zlema/Zlema.md) | Zero-Lag Exponential MA | Trends (IIR) |
| ZLTEMA | Zero-Lag Triple Exponential MA | Trends (IIR) | | ZLTEMA | Zero-Lag Triple Exponential MA | Trends (IIR) |
| ZSCORE | Z-score standardization | Statistics | | ZSCORE | Z-Score | Statistics |
| ZTEST | Z-Test | Statistics | | ZTEST | Z-Test | Statistics |
+25 -48
View File
@@ -1,55 +1,32 @@
# Channels # Channels
> "In trending markets, ride the channel. In ranging markets, fade the edges."  Unknown > "In trending markets, ride the channel. In ranging markets, fade the edges." Unknown
Channels define dynamic support and resistance. Upper band shows where price tends to find resistance; lower band shows support. Width measures volatility; price position within channel measures momentum and mean-reversion potential. Channels define dynamic support and resistance. Upper band shows where price tends to find resistance; lower band shows support. Width measures volatility; price position within channel measures momentum and mean-reversion potential.
## Indicator Status ## Indicators
| Indicator | Full Name | Status | Description | | Indicator | Full Name | Description |
| :--- | :--- | :---: | :--- |
| [ABBER](lib/channels/abber/abber.md) | Aberration Bands |  | Absolute deviation-based volatility bands. More robust than standard deviation. |
| [ACCBANDS](lib/channels/accbands/accbands.md) | Acceleration Bands |  | Volatility-based adaptive channel by Price Headley. Width adapts to momentum. |
| APCHANNEL | Andrews' Pitchfork | =Ë | Three-line channel based on pivot points. Projects trend support/resistance. |
| [APZ](lib/channels/apz/apz.md) | Adaptive Price Zone |  | Double-smoothed EMA volatility channel by Lee Leibfarth. Adapts to recent volatility. |
| ATRBANDS | ATR Bands | =Ë | ATR-based volatility bands around moving average. |
| BBANDS | Bollinger Bands | =Ë | Standard deviation bands around SMA. Classic volatility channel. |
| DCHANNEL | Donchian Channels | =Ë | Highest high and lowest low over N periods. Turtle trading foundation. |
| DECAYCHANNEL | Decay Min-Max Channel | =Ë | Exponentially decaying min-max channel. More responsive than Donchian. |
| FCB | Fractal Chaos Bands | =Ë | Tracks fractal highs and lows. Identifies chaos-based support/resistance. |
| JBANDS | Jurik Volatility Bands | =Ë | JMA-based volatility bands. Low lag with controlled overshoot. |
| KCHANNEL | Keltner Channel | =Ë | EMA with ATR bands. Smoother than Bollinger. |
| MAENV | Moving Average Envelope | =Ë | Fixed percentage bands around moving average. Simple but effective. |
| MMCHANNEL | Min-Max Channel | =Ë | Rolling minimum and maximum over lookback period. |
| PCHANNEL | Price Channel | =Ë | Highest high and lowest low. Similar to Donchian. |
| REGCHANNEL | Regression Channels | =Ë | Linear regression line with standard deviation bands. |
| SDCHANNEL | Standard Deviation Channel | =Ë | Moving average with standard deviation bands. |
| STARCHANNEL | Stoller Average Range Channel | =Ë | ATR-based channel around moving average. Similar to Keltner. |
| STBANDS | Super Trend Bands | =Ë | ATR-based trend-following bands. Flips direction on breakout. |
| UBANDS | Ultimate Bands | =Ë | Composite volatility bands using multiple measures. |
| UCHANNEL | Ultimate Channel | =Ë | Adaptive channel using multiple volatility inputs. |
| VWAPBANDS | VWAP Bands | =Ë | Volatility bands around VWAP. Institutional trading reference. |
| VWAPSD | VWAP Standard Deviation Bands | =Ë | Standard deviation bands around VWAP. |
**Status Key:**  Implemented | =Ë Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Volatility breakouts | ACCBANDS, BBANDS | Width expansion signals regime change. | | [ABBER](lib/channels/abber/Abber.md) | Aberration Bands | Absolute deviation-based volatility bands. More robust than standard deviation. |
| Mean reversion | APZ, BBANDS | Band touches indicate overextension. | | [ACCBANDS](lib/channels/accbands/Accbands.md) | Acceleration Bands | Volatility-based adaptive channel by Price Headley. Width adapts to momentum. |
| Trend riding | DCHANNEL, KCHANNEL | Clear trend direction with dynamic support/resistance. | | [APCHANNEL](lib/channels/apchannel/Apchannel.md) | Andrews' Pitchfork | Three-line channel based on pivot points. Projects trend support/resistance. |
| Robust to outliers | ABBER | Absolute deviation less sensitive than standard deviation. | | [APZ](lib/channels/apz/Apz.md) | Adaptive Price Zone | Double-smoothed EMA volatility channel by Lee Leibfarth. Adapts to recent volatility. |
| Low-lag bands | JBANDS, APZ | JMA/double-smoothed EMA cores reduce lag. | | [ATRBANDS](lib/channels/atrbands/Atrbands.md) | ATR Bands | ATR-based volatility bands around moving average. |
| Institutional reference | VWAPBANDS | VWAP is common institutional benchmark. | | BBANDS | Bollinger Bands | Standard deviation bands around SMA. Classic volatility channel. |
| DCHANNEL | Donchian Channels | Highest high and lowest low over N periods. Turtle trading foundation. |
## Channel Types | ECAYCHANNEL | Decay Min-Max Channel | Exponentially decaying min-max channel. More responsive than Donchian. |
| FCB | Fractal Chaos Bands | Tracks fractal highs and lows. Identifies chaos-based support/resistance. |
| Type | Examples | Volatility Measure | Best For | | JBANDS | Jurik Volatility Bands | JMA-based volatility bands. Low lag with controlled overshoot. |
| :--- | :--- | :--- | :--- | | KCHANNEL | Keltner Channel | EMA with ATR bands. Smoother than Bollinger. |
| Standard Deviation | BBANDS, SDCHANNEL | Ã of returns | Normal distributions | | MAENV | Moving Average Envelope | Fixed percentage bands around moving average. Simple but effective. |
| Absolute Deviation | ABBER | Mean absolute deviation | Fat-tailed distributions | | MMCHANNEL | Min-Max Channel | Rolling minimum and maximum over lookback period. |
| ATR-based | KCHANNEL, STARCHANNEL | Average True Range | Trend-following | | PCHANNEL | Price Channel | Highest high and lowest low. Similar to Donchian. |
| Price Range | DCHANNEL, PCHANNEL | High-low range | Breakout systems | | REGCHANNEL | Regression Channels | Linear regression line with standard deviation bands. |
| Adaptive | APZ, ACCBANDS | Dynamic volatility | Regime changes | | SDCHANNEL | Standard Deviation Channel | Moving average with standard deviation bands. |
| STARCHANNEL | Stoller Average Range Channel | ATR-based channel around moving average. Similar to Keltner. |
| STBANDS | Super Trend Bands | ATR-based trend-following bands. Flips direction on breakout. |
| UBANDS | Ultimate Bands | Composite volatility bands using multiple measures. |
| UCHANNEL | Ultimate Channel | Adaptive channel using multiple volatility inputs. |
| VWAPBANDS | VWAP Bands | Volatility bands around VWAP. Institutional trading reference. |
| VWAPSD | VWAP Standard Deviation Bands | Standard deviation bands around VWAP. |
+18 -54
View File
@@ -1,61 +1,25 @@
# Cycles # Cycles
> "The market is a discounting mechanism that anticipates cycles before they complete."  Unknown > "The market is a discounting mechanism that anticipates cycles before they complete." Unknown
Cycle analysis identifies repeating patterns in price data. John Ehlers pioneered digital signal processing techniques for financial cycles, using Hilbert transforms and autocorrelation to detect dominant periods. Cycles exist but are non-stationary: period and amplitude shift over time. Cycle analysis identifies repeating patterns in price data. John Ehlers pioneered digital signal processing techniques for financial cycles, using Hilbert transforms and autocorrelation to detect dominant periods. Cycles exist but are non-stationary: period and amplitude shift over time.
## Indicator Status ## Indicators
| Indicator | Full Name | Status | Description | | Indicator | Full Name | Description |
| :--- | :--- | :---: | :--- |
| CFB | Composite Fractal Behavior | =Ë | Jurik's fractal-based cycle detection. Adapts to changing volatility. |
| CG | Center of Gravity | =Ë | Ehlers. Weighted sum position. Minimal lag cycle indicator. |
| DSP | Detrended Synthetic Price | =Ë | Removes trend to reveal underlying cycles. |
| EACP | Autocorrelation Periodogram | =Ë | Ehlers. Spectral analysis via autocorrelation. Detects dominant period. |
| EBSW | Even Better Sinewave | =Ë | Ehlers. Improved sinewave extraction. Reduces false signals. |
| SSFDSP | SSF Detrended Synthetic Price | =Ë | Super Smoother Filter based DSP. Cleaner cycle extraction. |
| HOMOD | Homodyne Discriminator | =Ë | Dominant cycle detection via homodyne technique. |
| HT_DCPERIOD | HT Dominant Cycle Period | =Ë | Ehlers Hilbert Transform. Measures current cycle length. |
| HT_DCPHASE | HT Dominant Cycle Phase | =Ë | Ehlers Hilbert Transform. Measures current position in cycle. |
| HT_PHASOR | HT Phasor Components | =Ë | Ehlers. In-phase and quadrature components. |
| HT_SINE | HT SineWave | =Ë | Ehlers. Sine and lead sine for cycle timing. |
| LUNAR | Lunar Phase | =Ë | 29.5-day lunar cycle. Studied for market correlations. |
| PHASOR | Phasor Analysis | =Ë | Ehlers. Phase angle from Hilbert Transform. |
| SINE | Sine Wave | =Ë | Ehlers. Basic sinewave indicator for cycle mode. |
| SOLAR | Solar Activity Cycle | =Ë | ~11-year sunspot cycle. Long-term research indicator. |
| [STC](lib/cycles/stc/Stc.md) | Schaff Trend Cycle |  | MACD + double Stochastic smoothing. Fast cycle oscillator (0-100). |
**Status Key:**  Implemented | =Ë Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Dominant cycle detection | EACP, HT_DCPERIOD | Spectral analysis identifies strongest periodic component. | | CG | Center of Gravity | Ehlers. Weighted sum position. Minimal lag cycle indicator. |
| Cycle timing | HT_SINE, EBSW | Sine/lead-sine crossovers signal cycle turns. | | DSP | Detrended Synthetic Price | Removes trend to reveal underlying cycles. |
| Trend + cycle hybrid | STC | Combines MACD trend with Stochastic cycle. Fast signals. | | EACP | Autocorrelation Periodogram | Ehlers. Spectral analysis via autocorrelation. Detects dominant period. |
| Minimal lag | CG | Center of Gravity has theoretical zero lag at cycle frequency. | | EBSW | Even Better Sinewave | Ehlers. Improved sinewave extraction. Reduces false signals. |
| Phase analysis | HT_PHASOR, PHASOR | Track position within current cycle. | | HOMOD | Homodyne Discriminator | Dominant cycle detection via homodyne technique. |
| HT_DCPERIOD | HT Dominant Cycle Period | Ehlers Hilbert Transform. Measures current cycle length. |
## Ehlers Cycle Framework | HT_DCPHASE | HT Dominant Cycle Phase | Ehlers Hilbert Transform. Measures current position in cycle. |
| HT_PHASOR | HT Phasor Components | Ehlers. In-phase and quadrature components. |
John Ehlers developed most modern cycle indicators using DSP principles: | HT_SINE | HT SineWave | Ehlers. Sine and lead sine for cycle timing. |
| LUNAR | Lunar Phase | 29.5-day lunar cycle. Studied for market correlations. |
| Component | Purpose | Implementation | | PHASOR | Phasor Analysis | Ehlers. Phase angle from Hilbert Transform. |
| :--- | :--- | :--- | | SINE | Sine Wave | Ehlers. Basic sinewave indicator for cycle mode. |
| Hilbert Transform | Extracts instantaneous phase | 90° phase shift via FIR filter | | SOLAR | Solar Activity Cycle | ~11-year sunspot cycle. Long-term research indicator. |
| Super Smoother | Pre-filter noise | 2-pole Butterworth variant | | SSFDSP | SSF Detrended Synthetic Price | Super Smoother Filter based DSP. Cleaner cycle extraction. |
| Homodyne | Period detection | Multiplies signal by delayed version | | STC | Schaff Trend Cycle | MACD + double Stochastic smoothing. Fast cycle oscillator (0-100). |
| Autocorrelation | Spectral density | Correlates signal with lagged self |
Key insight: Financial cycles are non-stationary. Fixed-period indicators fail. Adaptive techniques (EACP, HT_DCPERIOD) measure the current dominant period and adjust accordingly.
## Cycle vs Trend
| Market Condition | Use Cycles | Use Trends |
| :--- | :--- | :--- |
| Ranging/choppy |  Cycles excel | L Whipsaws |
| Strong trend | L False signals |  Trend-following works |
| Transition periods |   Regime detection |   Lag at turns |
Combine cycle indicators with trend filters. Trade cycles only when trend strength is low.
+20 -55
View File
@@ -1,62 +1,27 @@
# Dynamics # Dynamics
> "The trend is your friend, but only if you know its strength."  Unknown > "The trend is your friend, but only if you know its strength." Unknown
Dynamics indicators measure trend strength, speed, and direction. Unlike momentum indicators that measure rate of change, dynamics indicators answer: "Is there a trend, and how strong is it?" Critical for filtering signals and avoiding whipsaws in ranging markets. Dynamics indicators measure trend strength, speed, and direction. Unlike momentum indicators that measure rate of change, dynamics indicators answer: "Is there a trend, and how strong is it?" Critical for filtering signals and avoiding whipsaws in ranging markets.
## Indicator Status ## Indicators
| Indicator | Full Name | Status | Description | | Indicator | Full Name | Description |
| :--- | :--- | :---: | :--- |
| [ADX](lib/dynamics/adx/Adx.md) | Average Directional Index |  | Trend strength 0-100. Direction-agnostic. <20 weak, >40 strong. |
| [ADXR](lib/dynamics/adxr/Adxr.md) | Average Directional Movement Rating |  | Smoothed ADX. Average of current and N-period ago ADX. |
| ALLIGATOR | Williams Alligator | =Ë | Three SMAs (Jaw, Teeth, Lips). Spread indicates trend strength. |
| [AMAT](lib/dynamics/amat/Amat.md) | Archer Moving Averages Trends |  | Multiple EMA alignment. Requires fast/slow EMA plus directional confirmation. |
| [AROON](lib/dynamics/aroon/Aroon.md) | Aroon |  | Time since high/low. Aroon Up/Down measure recency of extremes. |
| [AROONOSC](lib/dynamics/aroonosc/AroonOsc.md) | Aroon Oscillator |  | Aroon Up minus Aroon Down. Single line: +100 to -100. |
| CHOP | Choppiness Index | =Ë | Trendiness measure. High values = choppy. Low = trending. |
| [DMX](lib/dynamics/dmx/Dmx.md) | Jurik DMX |  | Smoothed bipolar DMI using Jurik smoothing. Low noise. |
| DX | Directional Movement Index | =Ë | Raw directional strength. Unsmoothed ADX component. |
| HT_TRENDMODE | HT Trend vs Cycle | =Ë | Ehlers Hilbert Transform. Binary trend/cycle mode detection. |
| ICHIMOKU | Ichimoku Cloud | =Ë | Five-line system. Cloud defines support/resistance zones. |
| IMI | Intraday Momentum Index | =Ë | RSI variant using open-close range. Intraday overbought/oversold. |
| QSTICK | Qstick | =Ë | MA of (Close - Open). Positive = buying pressure. |
| [SUPER](lib/dynamics/super/Super.md) | SuperTrend |  | ATR-based trailing stop. Flips on breakout. Color-coded direction. |
| TTM | TTM Trend | =Ë | Fast 6-period EMA. Color-coded trend from John Carter. |
| VORTEX | Vortex Indicator | =Ë | VI+ and VI- measure positive/negative trend movement. |
**Status Key:**  Implemented | =Ë Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Trend strength filter | ADX | Industry standard. <20 avoid trend trades; >40 strong trend. | | [ADX](lib/dynamics/adx/Adx.md) | Average Directional Index | Trend strength 0-100. Direction-agnostic. <20 weak, >40 strong. |
| Trend direction + strength | AROON, AROONOSC | Measures how recently price made new highs vs lows. | | [ADXR](lib/dynamics/adxr/Adxr.md) | Average Directional Movement Rating | Smoothed ADX. Average of current and N-period ago ADX. |
| Trend following stops | SUPER | ATR-based dynamic support/resistance. Clear entry/exit. | | ALLIGATOR | Williams Alligator | Three SMAs (Jaw, Teeth, Lips). Spread indicates trend strength. |
| Low-noise direction | DMX | Jurik smoothing reduces whipsaws vs standard DMI. | | [AMAT](lib/dynamics/amat/Amat.md) | Archer Moving Averages Trends | Multiple EMA alignment. Requires fast/slow EMA plus directional confirmation. |
| Trend confirmation | AMAT | Multiple timeframe EMA alignment required for signal. | | [AROON](lib/dynamics/aroon/Aroon.md) | Aroon | Time since high/low. Aroon Up/Down measure recency of extremes. |
| Choppy market detection | CHOP, ADX | CHOP high or ADX low means avoid trend strategies. | | [AROONOSC](lib/dynamics/aroonosc/Aroonosc.md) | Aroon Oscillator | Aroon Up minus Aroon Down. Single line: +100 to -100. |
| CHOP | Choppiness Index | Trendiness measure. High values = choppy. Low = trending. |
## ADX Interpretation | [DMX](lib/dynamics/dmx/Dmx.md) | Jurik DMX | Smoothed bipolar DMI using Jurik smoothing. Low noise. |
| DX | Directional Movement Index | Raw directional strength. Unsmoothed ADX component. |
| ADX Value | Trend Strength | Recommended Action | | HT_TRENDMODE | HT Trend vs Cycle | Ehlers Hilbert Transform. Binary trend/cycle mode detection. |
| :---: | :--- | :--- | | ICHIMOKU | Ichimoku Cloud | Five-line system. Cloud defines support/resistance zones. |
| 0-20 | Absent or weak | Avoid trend-following. Use mean reversion. | | IMI | Intraday Momentum Index | RSI variant using open-close range. Intraday overbought/oversold. |
| 20-25 | Emerging | Early trend possible. Confirm with direction. | | QSTICK | Qstick | MA of (Close - Open). Positive = buying pressure. |
| 25-40 | Strong | Trend-following strategies work well. | | SUPER | SuperTrend | ATR-based trailing stop. Flips on breakout. Color-coded direction. |
| 40-50 | Very strong | Trend mature. Watch for exhaustion. | | TTM | TTM Trend | Fast 6-period EMA. Color-coded trend from John Carter. |
| 50+ | Extreme | Unsustainable. Reversal risk increases. | | VORTEX | Vortex Indicator | VI+ and VI- measure positive/negative trend movement. |
| IMPULSE | Elder Impulse System | Combines EMA and MACD histogram; color-coded system (green=bullish, red=bearish, blue=neutral) |
ADX tells strength, not direction. Use +DI/-DI or other direction indicators alongside.
## Dynamics vs Momentum
| Aspect | Dynamics | Momentum |
| :--- | :--- | :--- |
| Measures | Trend existence/strength | Rate of price change |
| Direction | Often direction-agnostic | Usually directional |
| Best for | Filtering | Timing |
| Examples | ADX, CHOP, AROON | RSI, MACD, ROC |
Use dynamics to filter when to trade. Use momentum to time entries/exits.
+30 -82
View File
@@ -1,88 +1,36 @@
# Errors # Errors
> "All models are wrong. Error metrics tell you how wrong." Adapted from George Box > "All models are wrong. Error metrics tell you how wrong." Adapted from George Box
Error metrics and loss functions for model/strategy evaluation. All error indicators accept two input series (actual and predicted values) and compute rolling error metrics over a configurable period. Error metrics and loss functions for model/strategy evaluation. All error indicators accept two input series (actual and predicted values) and compute rolling error metrics over a configurable period.
## Two-Input Pattern ## Indicators
All error indicators in this category follow a consistent dual-input API: | Indicator | Full Name | Description |
| :--- | :--- | :--- |
```csharp | [HUBER](lib/errors/huber/Huber.md) | Huber Loss | Combines MSE and MAE. Configurable outlier threshold δ. |
// Streaming mode | [LOGCOSH](lib/errors/logcosh/Logcosh.md) | Log-Cosh Loss | Smooth approximation to MAE. Twice-differentiable. |
var mae = new Mae(period: 14); | [MAE](lib/errors/mae/Mae.md) | Mean Absolute Error | Average of absolute differences. Robust baseline. |
var result = mae.Update(actualValue, predictedValue); | [MAAPE](lib/errors/maape/Maape.md) | Mean Arctangent APE | Bounded percentage error using arctangent. Range: 0 to π/2. |
| [MAPD](lib/errors/mapd/Mapd.md) | Mean Absolute % Deviation | Percentage error relative to mean of actual and predicted. |
// Batch mode | [MAPE](lib/errors/mape/Mape.md) | Mean Absolute % Error | Percentage error relative to actual. Unbounded when actual≈0. |
var maeSeries = Mae.Calculate(actualSeries, predictedSeries, period: 14); | [MASE](lib/errors/mase/Mase.md) | Mean Absolute Scaled Error | Scale-free. Uses naive forecast as baseline. |
| [MDAE](lib/errors/mdae/Mdae.md) | Median Absolute Error | Median of absolute differences. Outlier-robust. O(n log n). |
// Span mode (zero-allocation) | [MDAPE](lib/errors/mdape/Mdape.md) | Median Absolute % Error | Median percentage error. Outlier-robust. O(n log n). |
Mae.Batch(actualSpan, predictedSpan, outputSpan, period: 14); | [ME](lib/errors/me/Me.md) | Mean Error | Signed average. Detects systematic bias. |
``` | [MPE](lib/errors/mpe/Mpe.md) | Mean Percentage Error | Signed percentage. Shows directional bias. |
| [MRAE](lib/errors/mrae/Mrae.md) | Mean Relative Absolute Error | Error relative to naive forecast. |
## Indicator Status | [MSE](lib/errors/mse/Mse.md) | Mean Squared Error | Squared differences. Penalizes large errors heavily. |
| [MSLE](lib/errors/msle/Msle.md) | Mean Squared Log Error | MSE on log-transformed values. For multiplicative errors. |
| Indicator | Full Name | Status | Description | | [PSEUDOHUBER](lib/errors/pseudohuber/Pseudohuber.md) | Pseudo-Huber Loss | Smooth Huber approximation. Fully differentiable. |
| :--- | :--- | :---: | :--- | | [QUANTILE](lib/errors/quantile/Quantile.md) | Quantile Loss | Asymmetric loss for quantile regression. Pinball loss. |
| [HUBER](lib/errors/huber/Huber.md) | Huber Loss | ✅ | Combines MSE and MAE. Configurable outlier threshold δ. | | [RAE](lib/errors/rae/Rae.md) | Relative Absolute Error | Absolute error relative to mean predictor. |
| [LOGCOSH](lib/errors/logcosh/LogCosh.md) | Log-Cosh Loss | ✅ | Smooth approximation to MAE. Twice-differentiable. | | [RMSE](lib/errors/rmse/Rmse.md) | Root Mean Squared Error | √MSE. Same units as input. Penalizes outliers. |
| [MAE](lib/errors/mae/Mae.md) | Mean Absolute Error | ✅ | Average of absolute differences. Robust baseline. | | [RMSLE](lib/errors/rmsle/Rmsle.md) | Root Mean Squared Log Error | √MSLE. For multiplicative error structures. |
| [MAAPE](lib/errors/maape/Maape.md) | Mean Arctangent APE | ✅ | Bounded percentage error using arctangent. Range: 0 to π/2. | | [RSE](lib/errors/rse/Rse.md) | Relative Squared Error | Squared error relative to mean predictor. |
| [MAPD](lib/errors/mapd/Mapd.md) | Mean Absolute % Deviation | ✅ | Percentage error relative to mean of actual and predicted. | | [RSQUARED](lib/errors/rsquared/Rsquared.md) | R² (Coefficient of Determination) | Variance explained. 1 = perfect. Can be negative. |
| [MAPE](lib/errors/mape/Mape.md) | Mean Absolute % Error | ✅ | Percentage error relative to actual. Unbounded when actual≈0. | | [SMAPE](lib/errors/smape/Smape.md) | Symmetric MAPE | Bounded 0-200%. Symmetric around zero. |
| [MASE](lib/errors/mase/Mase.md) | Mean Absolute Scaled Error | ✅ | Scale-free. Uses naive forecast as baseline. | | [THEILU](lib/errors/theilu/Theilu.md) | Theil's U Statistic | Forecast vs naive. <1 beats naive. >1 worse than naive. |
| [MDAE](lib/errors/mdae/Mdae.md) | Median Absolute Error | ✅ | Median of absolute differences. Outlier-robust. O(n log n). | | [TUKEY](lib/errors/tukey/Tukey.md) | Tukey Biweight Loss | Hard-rejects outliers beyond threshold. Redescending. |
| [MDAPE](lib/errors/mdape/Mdape.md) | Median Absolute % Error | ✅ | Median percentage error. Outlier-robust. O(n log n). | | [WMAPE](lib/errors/wmape/Wmape.md) | Weighted MAPE | Volume-weighted percentage error. For heterogeneous data. |
| [ME](lib/errors/me/Me.md) | Mean Error | ✅ | Signed average. Detects systematic bias. | | [WRMSE](lib/errors/wrmse/Wrmse.md) | Weighted RMSE | Weighted root mean squared error. Custom observation weighting. |
| [MPE](lib/errors/mpe/Mpe.md) | Mean Percentage Error | ✅ | Signed percentage. Shows directional bias. |
| [MRAE](lib/errors/mrae/Mrae.md) | Mean Relative Absolute Error | ✅ | Error relative to naive forecast. |
| [MSE](lib/errors/mse/Mse.md) | Mean Squared Error | ✅ | Squared differences. Penalizes large errors heavily. |
| [MSLE](lib/errors/msle/Msle.md) | Mean Squared Log Error | ✅ | MSE on log-transformed values. For multiplicative errors. |
| [PSEUDOHUBER](lib/errors/pseudohuber/PseudoHuber.md) | Pseudo-Huber Loss | ✅ | Smooth Huber approximation. Fully differentiable. |
| [QUANTILE](lib/errors/quantile/QuantileLoss.md) | Quantile Loss | ✅ | Asymmetric loss for quantile regression. Pinball loss. |
| [RAE](lib/errors/rae/Rae.md) | Relative Absolute Error | ✅ | Absolute error relative to mean predictor. |
| [RMSE](lib/errors/rmse/Rmse.md) | Root Mean Squared Error | ✅ | √MSE. Same units as input. Penalizes outliers. |
| [RMSLE](lib/errors/rmsle/Rmsle.md) | Root Mean Squared Log Error | ✅ | √MSLE. For multiplicative error structures. |
| [RSE](lib/errors/rse/Rse.md) | Relative Squared Error | ✅ | Squared error relative to mean predictor. |
| [RSQUARED](lib/errors/rsquared/Rsquared.md) | R² (Coefficient of Determination) | ✅ | Variance explained. 1 = perfect. Can be negative. |
| [SMAPE](lib/errors/smape/Smape.md) | Symmetric MAPE | ✅ | Bounded 0-200%. Symmetric around zero. |
| [THEILU](lib/errors/theilu/TheilU.md) | Theil's U Statistic | ✅ | Forecast vs naive. <1 beats naive. >1 worse than naive. |
| [TUKEY](lib/errors/tukey/TukeyBiweight.md) | Tukey Biweight Loss | ✅ | Hard-rejects outliers beyond threshold. Redescending. |
| [WMAPE](lib/errors/wmape/Wmape.md) | Weighted MAPE | ✅ | Volume-weighted percentage error. For heterogeneous data. |
| [WRMSE](lib/errors/wrmse/Wrmse.md) | Weighted RMSE | ✅ | Weighted root mean squared error. Custom observation weighting. |
**Status Key:** ✅ Implemented | 📋 Planned
## Choosing an Error Metric
### By Use Case
| Use Case | Recommended Metrics |
| :--- | :--- |
| General accuracy | MAE, RMSE |
| Outlier-robust | MAE, Huber, MASE, MDAE, Tukey |
| Percentage interpretation | MAPE, SMAPE, MAPD, MAAPE |
| Bias detection | ME, MPE |
| Scale-free comparison | MASE, RAE, RSE, MRAE, TheilU |
| Model quality score | R², RSE |
| Log-scale data | MSLE, RMSLE |
| Gradient optimization | LogCosh, PseudoHuber |
| Quantile forecasting | Quantile Loss |
| Volume-weighted | WMAPE |
### By Properties
| Metric | Scale | Outlier Sensitivity | Complexity |
| :--- | :--- | :--- | :--- |
| MAE | Original units | Low | O(1) |
| MSE | Squared units | High | O(1) |
| RMSE | Original units | High | O(1) |
| MAPE | Percentage | Medium | O(1) |
| SMAPE | 0-200% | Medium | O(1) |
| Huber | Original units | Low (configurable) | O(1) |
| R² | 0-1 (for good models) | High | O(1) |
| MDAE | Original units | Very Low | O(n log n) |
| MDAPE | Percentage | Very Low | O(n log n) |
| LogCosh | Original units | Low | O(1) |
| PseudoHuber | Original units | Low | O(1) |
| Tukey | Original units | Very Low | O(1) |
+21 -60
View File
@@ -1,67 +1,28 @@
# Filters # Filters
> "All moving averages are low-pass filters. The question is which trade-offs you accept."  John Ehlers > "All moving averages are low-pass filters. The question is which trade-offs you accept." John Ehlers
Signal processing filters adapted for financial time series. These are not indicators in the traditional sense: they are building blocks. Low-pass removes noise. High-pass isolates cycles. Band-pass extracts specific frequencies. Each filter type trades off smoothness, lag, and overshoot differently. Signal processing filters adapted for financial time series. These are not indicators in the traditional sense: they are building blocks. Low-pass removes noise. High-pass isolates cycles. Band-pass extracts specific frequencies. Each filter type trades off smoothness, lag, and overshoot differently.
## Indicator Status ## Indicators
| Indicator | Full Name | Status | Description | | Indicator | Full Name | Description |
| :--- | :--- | :---: | :--- |
| [Bessel](lib/filters/bessel/Bessel.md) | Bessel Filter |  | Maximally flat group delay. Best phase response. Minimal overshoot. |
| [Bilateral](lib/filters/bilateral/Bilateral.md) | Bilateral Filter |  | Edge-preserving smoothing. Adapts to local gradients. |
| [BPF](lib/filters/bpf/Bpf.md) | BandPass Filter |  | 2nd-order IIR. Cascade of HP + LP. Extracts specific frequency band. |
| [Butter](lib/filters/butter/Butter.md) | Butterworth Filter |  | Maximally flat frequency response. Classic IIR filter. |
| Cheby1 | Chebyshev Type I | =Ë | Steeper roll-off with passband ripple. Sharper cutoff than Butterworth. |
| Cheby2 | Chebyshev Type II | =Ë | Equiripple stopband, monotonic passband. Better stopband rejection. |
| [Elliptic](lib/filters/elliptic/Elliptic.md) | Elliptic Filter |  | Equiripple both bands. Sharpest transition for given order. |
| [Gauss](lib/filters/gauss/Gauss.md) | Gaussian Filter |  | Bell-curve weighted smoothing. No overshoot. |
| [Hann](lib/filters/hann/Hann.md) | Hann Filter |  | Hann window smoothing. Good spectral leakage control. |
| [Hp](lib/filters/hp/Hp.md) | Hodrick-Prescott |  | Causal trend/cycle decomposition. Regularization parameter » controls smoothness. |
| [Hpf](lib/filters/hpf/Hpf.md) | High Pass Filter |  | Attenuates below cutoff. Isolates fast components. |
| [Kalman](lib/filters/kalman/Kalman.md) | Kalman Filter |  | Recursive state estimation. Optimal under Gaussian assumptions. |
| [Loess](lib/filters/loess/Loess.md) | LOESS Smoothing |  | Local polynomial regression. Robust to outliers. |
| [Notch](lib/filters/notch/Notch.md) | Notch Filter |  | Band-stop. Removes specific frequency (e.g., 60 Hz noise). |
| [SGF](lib/filters/sgf/Sgf.md) | Savitzky-Golay |  | Polynomial smoothing. Preserves higher moments (derivatives). |
| [SSF](lib/filters/ssf/Ssf.md) | Super Smoother |  | Ehlers. 2-pole Butterworth variant. Standard cycle pre-filter. |
| [USF](lib/filters/usf/Usf.md) | Ultra Smoother |  | Ehlers. 3-pole variant. More smoothing than SSF. |
| Wiener | Wiener Filter | =Ë | Optimal linear filter. Minimizes MSE given signal/noise spectra. |
**Status Key:**  Implemented | =Ë Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| General smoothing | Butter, SSF | Good balance of smoothing and lag. | | [BESSEL](lib/filters/bessel/Bessel.md) | Bessel Filter | Maximally flat group delay. Best phase response. Minimal overshoot. |
| Minimal overshoot | Bessel, Gauss | Bessel: best phase. Gauss: no overshoot by design. | | [BILATERAL](lib/filters/bilateral/Bilateral.md) | Bilateral Filter | Edge-preserving smoothing. Adapts to local gradients. |
| Sharp cutoff | Elliptic, Cheby1 | Elliptic: sharpest. Cheby1: simpler. | | [BPF](lib/filters/bpf/Bpf.md) | BandPass Filter | 2nd-order IIR. Cascade of HP + LP. Extracts specific frequency band. |
| Cycle extraction | BPF, Hp | BPF for specific band. Hp for trend/cycle split. | | [BUTTER](lib/filters/butter/Butter.md) | Butterworth Filter | Maximally flat frequency response. Classic IIR filter. |
| Noise spike removal | Notch | Surgical removal of specific frequency. | | [CHEBY1](lib/filters/cheby1/Cheby1.md) | Chebyshev Type I | Steeper roll-off with passband ripple. Sharper cutoff than Butterworth. |
| Outlier robustness | Bilateral, Loess | Adapt to local structure. Ignore outliers. | | [CHEBY2](lib/filters/cheby2/Cheby2.md) | Chebyshev Type II | Equiripple stopband, monotonic passband. Better stopband rejection. |
| Derivative preservation | SGF | Polynomial fit preserves shape. | | [ELLIPTIC](lib/filters/elliptic/Elliptic.md) | Elliptic Filter | Equiripple both bands. Sharpest transition for given order. |
| Adaptive estimation | Kalman | Updates estimate as new data arrives. Optimal under model. | | [GAUSS](lib/filters/gauss/Gauss.md) | Gaussian Filter | Bell-curve weighted smoothing. No overshoot. |
| [HANN](lib/filters/hann/Hann.md) | Hann Filter | Hann window smoothing. Good spectral leakage control. |
## Filter Characteristics | [HP](lib/filters/hp/Hp.md) | Hodrick-Prescott | Causal trend/cycle decomposition. Regularization parameter λ controls smoothness. |
| [HPF](lib/filters/hpf/Hpf.md) | High Pass Filter | Attenuates below cutoff. Isolates fast components. |
| Filter | Type | Order | Overshoot | Lag | Sharpness | | [KALMAN](lib/filters/kalman/Kalman.md) | Kalman Filter | Recursive state estimation. Optimal under Gaussian assumptions. |
| :--- | :--- | :---: | :---: | :---: | :---: | | [LOESS](lib/filters/loess/Loess.md) | LOESS Smoothing | Local polynomial regression. Robust to outliers. |
| Butter | IIR LP | 2 | Low | Medium | Medium | | [NOTCH](lib/filters/notch/Notch.md) | Notch Filter | Band-stop. Removes specific frequency (e.g., 60 Hz noise). |
| Bessel | IIR LP | 2 | Minimal | Higher | Low | | [SGF](lib/filters/sgf/Sgf.md) | Savitzky-Golay | Polynomial smoothing. Preserves higher moments (derivatives). |
| Cheby1 | IIR LP | 2 | Higher | Lower | High | | [SSF](lib/filters/ssf/Ssf.md) | Super Smoother | Ehlers. 2-pole Butterworth variant. Standard cycle pre-filter. |
| Elliptic | IIR LP | 2 | Higher | Lowest | Highest | | [USF](lib/filters/usf/Usf.md) | Ultra Smoother | Ehlers. 3-pole variant. More smoothing than SSF. |
| SSF | IIR LP | 2 | Low | Low | Medium | | [WIENER](lib/filters/wiener/Wiener.md) | Wiener Filter | Optimal linear filter. Minimizes MSE given signal/noise spectra. |
| USF | IIR LP | 3 | Lower | Medium | Medium |
| Gauss | FIR LP | N | None | Higher | Low |
| SGF | FIR LP | N | Low | Medium | Low |
Higher order = more smoothing but more lag. IIR filters have minimal coefficients but can overshoot. FIR filters are always stable with linear phase but need more coefficients.
## Filter Design Principles
| Principle | Trade-off | QuanTAlib Approach |
| :--- | :--- | :--- |
| Smoothness vs lag | More smoothing = more lag | Parameterized period/cutoff |
| Sharpness vs ripple | Sharper cutoff = more ripple | Choose filter type for application |
| Stability | IIR can be unstable | All implementations verified stable |
| Causality | Real-time requires causal filters | All filters are causal (no lookahead) |
+2 -5
View File
@@ -113,10 +113,7 @@ public class SgfValidationTests : IDisposable
if (wSum <= double.Epsilon) if (wSum <= double.Epsilon)
{ {
int availablePoints = Math.Min(i + 1, adjPeriod); int availablePoints = Math.Min(i + 1, adjPeriod);
if (availablePoints < adjPeriod) result[i] = availablePoints < adjPeriod ? source[i] : double.NaN;
result[i] = source[i];
else
result[i] = double.NaN;
} }
} }
@@ -202,4 +199,4 @@ public class SgfValidationTests : IDisposable
} }
_output.WriteLine("Span mode successfully validated against reference implementation"); _output.WriteLine("Span mode successfully validated against reference implementation");
} }
} }
+2 -5
View File
@@ -248,11 +248,8 @@ public sealed class Sgf : AbstractBase
} }
else else
{ {
// If wSum is zero/negative/small // If wSum is zero/negative/small - pass through for partial window, else NaN
if (count < adjPeriod) output[i] = count < adjPeriod ? source[i] : double.NaN;
output[i] = source[i]; // Pass through for partial window
else
output[i] = double.NaN;
} }
} }
} }
+5 -29
View File
@@ -1,36 +1,12 @@
# Forecasts # Forecasts
> "Prediction is very difficult, especially about the future."  Niels Bohr > "Prediction is very difficult, especially about the future." Niels Bohr
Forecasting and predictive models. Unlike reactive indicators that smooth past data, forecasts attempt to project future values. Extrapolation is inherently uncertain. Use with appropriate skepticism and position sizing. Forecasting and predictive models. Unlike reactive indicators that smooth past data, forecasts attempt to project future values. Extrapolation is inherently uncertain. Use with appropriate skepticism and position sizing.
## Indicator Status ## Indicators
| Indicator | Full Name | Status | Description | | Indicator | Full Name | Description |
| :--- | :--- | :---: | :--- |
| [AFIRMA](lib/forecasts/afirma/Afirma.md) | Adaptive FIR Moving Average |  | Windowed sinc coefficients. Optimal frequency response. Can extrapolate. |
| CFO | Chande Forecast Oscillator | =Ë | Percentage difference between price and linear regression forecast. |
| MLP | Multilayer Perceptron | =Ë | Neural network regressor. Nonlinear pattern learning. |
| TSF | Time Series Forecast | =Ë | Linear regression projected forward. Standard extrapolation. |
**Status Key:**  Implemented | =Ë Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Smooth extrapolation | AFIRMA | FIR with extrapolation coefficients. Configurable lookahead. | | [AFIRMA](lib/forecasts/afirma/Afirma.md) | Adaptive FIR Moving Average | Windowed sinc coefficients. Optimal frequency response. Can extrapolate. |
| Linear trend projection | TSF | Simple, interpretable. Works when trend is linear. | | MLP | Multilayer Perceptron | Neural network regressor. Nonlinear pattern learning. |
| Forecast deviation | CFO | Shows when price diverges from linear forecast. |
| Nonlinear patterns | MLP | Neural network learns complex relationships. Requires training. |
## Forecasting Principles
| Aspect | Reality | Implication |
| :--- | :--- | :--- |
| Extrapolation risk | Markets are non-stationary | Short horizons more reliable |
| Model uncertainty | All models are wrong | Use ensemble or confidence intervals |
| Regime changes | Past patterns may not repeat | Monitor forecast errors |
| Overfitting | Complex models fit noise | Prefer simple models when possible |
Forecasting is not prediction. It is disciplined extrapolation of patterns that may or may not persist.
+3 -13
View File
@@ -319,18 +319,8 @@ public sealed class Afirma : AbstractBase
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
double val; // Use fitted value (intercept + slope * i) for i < n, otherwise use original from buffer
if (i < n) double val = i < n ? intercept + slope * i : _buffer[count - 1 - i];
{
// Use fitted value: intercept + slope * i
val = intercept + slope * i;
}
else
{
// Use original value from buffer
// At lag i
val = _buffer[count - 1 - i];
}
lsSum += val; lsSum += val;
lsCount++; lsCount++;
} }
@@ -577,4 +567,4 @@ public sealed class Afirma : AbstractBase
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
} }
-461
View File
@@ -1,461 +0,0 @@
// The MIT License (MIT)
// © mihakralj
//@version=6
indicator("Multilayer Perceptron Predictor", "MLP", overlay=true)
var int offset = 5
var int numInputs = 6
var array<int> nodesPerLayer = array.from(8, 4, 1)
var float learning_rate = 0.0025
var float learning_rate_decay = 0.000015
var float max_gradient = 5.0
var float error_k = 0.7
var int algoType = 4
var bool tanh = true
type matrices
matrix<float> l0 = na
matrix<float> l1 = na
matrix<float> l2 = na
matrix<float> l3 = na
matrix<float> l4 = na
matrix<float> l5 = na
matrix<float> l6 = na
matrix<float> l7 = na
matrix<float> l8 = na
matrix<float> l9 = na
var matrices w = na
var matrices b = na
// ---------- Main loop ----------
//@function Compresses an unbounded value to the range [-1, 1] using tanh or scaled sigmoid
//@param x The input value (can be any real number)
//@param useTanh Whether to use tanh (true) or scaled sigmoid (false)
//@returns A compressed value in range [-1, 1]
compressToRange(float x, bool useTanh = true) =>
if x >= 20.0
1.0
else if x <= -20.0
-1.0
else
if useTanh
ex = math.exp(x)
emx = math.exp(-x)
(ex - emx) / (ex + emx)
else
sigmoid = 1.0 / (1.0 + math.exp(-x))
2.0 * sigmoid - 1.0
//@function Calculates and normalizes input features in one step
//@param off Offset value
//@returns Array of normalized feature values
calculateInputs(int off) =>
norm_arr = array.new_float(0)
float f0 = ta.hma(close[off],20) / ta.sma(ta.hma(close[off],20), 100) - 1
array.push(norm_arr, compressToRange(f0, tanh))
if numInputs > 1
float f1 = ta.rsi(close[off], 14) / 100
array.push(norm_arr, compressToRange(f1, tanh))
if numInputs > 2
float f2 = ta.atr(14)[off] / ta.sma(ta.atr(14), 14)[off]
array.push(norm_arr, compressToRange(f2, tanh))
if numInputs > 3
float f3 = close[off] / ta.sma(close, 20)[off]
array.push(norm_arr, compressToRange(f3, tanh))
if numInputs > 4
float f4 = ta.mom(close[off], 10) / close[off]
array.push(norm_arr, compressToRange(f4, tanh))
if numInputs > 5
float f5 = ta.ema(close[off], 5) / ta.ema(close[off], 20) - 1
array.push(norm_arr, compressToRange(f5, tanh))
if numInputs > 6
float f6 = ta.bbw(close[off], 20, 2) / 2
array.push(norm_arr, compressToRange(f6, tanh))
norm_arr
//@function Converts price format to return format
//@param reference_price The reference price to compare against
//@param new_price The current price value
//@param algo_type Algorithm type: 1=absolute change, 2=return ratio, 3=percentage change, 4=log return
//@returns The price return format
transform(float reference_price, float new_price, int algo_type) =>
if na(new_price) or na(reference_price) or na(algo_type)
na
else if reference_price <= 0 and (algo_type > 1)
na
else if algo_type == 1
new_price - reference_price
else if algo_type == 2
new_price / reference_price
else if algo_type == 3
(new_price - reference_price) / reference_price
else if algo_type == 4
ratio = new_price / reference_price
ratio <= 0 ? na : math.log(ratio)
else
na
//@function Converts return format back to price format
//@param reference_price The reference price value
//@param price_return The return value
//@param algo_type Algorithm type: 1=absolute change, 2=return ratio, 3=percentage change, 4=log return
//@returns The absolute price format
detransform(float reference_price, float price_return, int algo_type) =>
if na(reference_price) or na(price_return) or na(algo_type)
na
else if reference_price <= 0 and (algo_type > 1)
na
else if algo_type == 1
reference_price + price_return
else if algo_type == 2
limited_return = math.max(0.01, math.min(10.0, price_return))
reference_price * limited_return
else if algo_type == 3
reference_price * (1 + price_return)
else if algo_type == 4
limited_return = math.max(-5.0, math.min(5.0, price_return))
reference_price * math.exp(limited_return)
else
na
//@function Expands a value from the range [-1, 1] back to its original unbounded range
//@param y The compressed value in range [-1, 1]
//@param useTanh Whether y was produced by tanh (true) or scaled sigmoid (false)
//@returns The original unbounded value
expandFromRange(float y, bool useTanh = true) =>
y_safe = math.max(-0.9999, math.min(0.9999, y))
if useTanh
0.5 * math.log((1.0 + y_safe) / (1.0 - y_safe))
else
sigmoid_y = (y_safe + 1.0) / 2.0
math.log(sigmoid_y / (1.0 - sigmoid_y))
//@function Calculates Huber loss value that is less sensitive to outliers than MSE squared error
//@param predicted The model's predicted value
//@param actual The true target value
//@param delta The threshold where loss function changes from quadratic to linear (default: 0.7)
//@returns Loss value combining benefits of MSE and MAE
huberLoss(float predicted, float actual, float delta = 0.7) =>
float error = math.abs(predicted - actual)
if error <= delta
0.5 * error * error
else
delta * (error - 0.5 * delta)
//@function Calculates gradient of Huber loss for backpropagation
//@param predicted The model's predicted value
//@param actual The true target value
//@param delta The threshold where gradient changes from linear to constant (default: 0.7)
//@returns Gradient value for updating weights, clipped for stability
huberLossGradient(float predicted, float actual, float delta = 0.7) =>
float error = predicted - actual
float absError = math.abs(error)
if absError <= delta
error
else
delta * math.sign(error)
//@function Initializes neural network layer weights using Xavier/Glorot initialization
//@param inputSize Number of neurons in the input layer
//@param outputSize Number of neurons in the output layer
//@param seed Random seed
//@returns Array containing [weight_matrix, bias_matrix] with weights scaled to maintain variance
xavierInitLayer(int inputSize, int outputSize, int seed) =>
w_matrix = matrix.new<float>(inputSize, outputSize)
b_matrix = matrix.new<float>(1, outputSize)
limit = math.sqrt(1.0 / (inputSize + outputSize))
for idx = 0 to (inputSize * outputSize) - 1
r = int(idx / outputSize)
c = idx % outputSize
scale = c == outputSize - 1 ? 0.1 : 1.0
value = scale * limit * math.sin((r + 1) * 13.37 + (c + 1) * 42.42 + seed)
matrix.set(w_matrix, r, c, value)
for c = 0 to outputSize - 1
bias_value = c == outputSize - 1 ? 0.01 : (limit * math.sin((c + 1) * 42.42 + seed))
matrix.set(b_matrix, 0, c, bias_value)
[w_matrix, b_matrix]
//@function Initializes neural network weights and biases using Xavier initialization
//@param nodeLayerArray Array containing the number of nodes in each layer
//@param numInputsInt Number of input features
//@param seed Random seed
//@returns A matrices object containing all network weights and biases
initializeNetwork(array<int> nodeLayerArray, int numInputsInt, seed) =>
new_w = matrices.new()
new_b = matrices.new()
numLayers = array.size(nodeLayerArray)
for i = 0 to numLayers - 1
inputSize = i == 0 ? numInputsInt : array.get(nodeLayerArray, i - 1)
outputSize = array.get(nodeLayerArray, i)
[ww, bb] = xavierInitLayer(inputSize, outputSize, seed)
if i == 0
new_w.l0 := ww
new_b.l0 := bb
else if i == 1
new_w.l1 := ww
new_b.l1 := bb
else if i == 2
new_w.l2 := ww
new_b.l2 := bb
else if i == 3
new_w.l3 := ww
new_b.l3 := bb
else if i == 4
new_w.l4 := ww
new_b.l4 := bb
else if i == 5
new_w.l5 := ww
new_b.l5 := bb
else if i == 6
new_w.l6 := ww
new_b.l6 := bb
else if i == 7
new_w.l7 := ww
new_b.l7 := bb
else if i == 8
new_w.l8 := ww
new_b.l8 := bb
[new_w, new_b]
//@function Creates a new matrix with activation applied to all elements
//@param this The input matrix with raw values
//@param useTanh Whether to use tanh activation
//@returns A new matrix with activated values
method activate(matrix<float> this, bool useTanh = false) =>
result = matrix.new<float>(matrix.rows(this), matrix.columns(this))
for q = 0 to matrix.rows(this) - 1
for r = 0 to matrix.columns(this) - 1
x = matrix.get(this, q, r)
tanh_val = compressToRange(x, useTanh)
matrix.set(result, q, r, tanh_val)
result
getLayerMatrix(matrices matrices_obj, int layer) =>
if layer == 0
matrices_obj.l0
else if layer == 1
matrices_obj.l1
else if layer == 2
matrices_obj.l2
else if layer == 3
matrices_obj.l3
else if layer == 4
matrices_obj.l4
else if layer == 5
matrices_obj.l5
else if layer == 6
matrices_obj.l6
else if layer == 7
matrices_obj.l7
else if layer == 8
matrices_obj.l8
else
matrices_obj.l9
setLayerMatrix(matrices matrices_obj, int layer, matrix<float> mat) =>
if layer == 0
matrices_obj.l0 := mat
else if layer == 1
matrices_obj.l1 := mat
else if layer == 2
matrices_obj.l2 := mat
else if layer == 3
matrices_obj.l3 := mat
else if layer == 4
matrices_obj.l4 := mat
else if layer == 5
matrices_obj.l5 := mat
else if layer == 6
matrices_obj.l6 := mat
else if layer == 7
matrices_obj.l7 := mat
else if layer == 8
matrices_obj.l8 := mat
matrices_obj
calculateDeltas(matrix<float> weights, matrix<float> activations, matrix<float> next_layer_deltas) =>
rows = matrix.rows(weights)
cols = matrix.columns(weights)
deltas = matrix.new<float>(1, rows, 0.0)
for i = 0 to rows - 1
error_sum = 0.0
for j = 0 to matrix.rows(next_layer_deltas) - 1
for k = 0 to matrix.columns(next_layer_deltas) - 1
error_sum := error_sum + matrix.get(weights, i, j) * matrix.get(next_layer_deltas, j, k)
a_val = matrix.get(activations, 0, i)
delta_val = error_sum * (1.0 - a_val * a_val)
matrix.set(deltas, 0, i, delta_val)
deltas
updateLayerWeights(matrix<float> weights, matrix<float> activations, matrix<float> deltas, float learning_rate, float max_gradient) =>
new_weights = matrix.copy(weights)
rows = matrix.rows(weights)
cols = matrix.columns(weights)
delta_cols = matrix.columns(deltas)
for i = 0 to rows - 1
for j = 0 to cols - 1
a_val = matrix.get(activations, 0, i)
d_val = j < delta_cols ? matrix.get(deltas, 0, j) : 0.0
grad = a_val * d_val
grad := math.max(-max_gradient, math.min(grad, max_gradient))
old_w = matrix.get(weights, i, j)
matrix.set(new_weights, i, j, old_w - learning_rate * grad)
new_weights
updateLayerBiases(matrix<float> biases, matrix<float> deltas, float learning_rate, float max_gradient) =>
new_biases = matrix.copy(biases)
cols = matrix.columns(biases)
delta_cols = matrix.columns(deltas)
for j = 0 to cols - 1
d_val = j < delta_cols ? matrix.get(deltas, 0, j) : 0.0
grad = d_val
grad := math.max(-max_gradient, math.min(grad, max_gradient))
old_b = matrix.get(biases, 0, j)
matrix.set(new_biases, 0, j, old_b - learning_rate * grad)
new_biases
//@function Performs forward pass through the neural network
//@param input_arr Array of input features
//@returns Array containing [prediction, z_values, a_values]
forwardPass(array<float> input_arr) =>
z_values = matrices.new()
a_values = matrices.new()
input_matrix = matrix.new<float>(1, numInputs)
for i = 0 to numInputs - 1
feature_value = array.get(input_arr, i)
if not na(feature_value)
matrix.set(input_matrix, 0, i, feature_value)
setLayerMatrix(a_values, 0, input_matrix)
current_a = input_matrix
numLayers = array.size(nodesPerLayer)
for i = 0 to numLayers - 1
current_w = getLayerMatrix(w, i)
current_b = getLayerMatrix(b, i)
z = matrix.mult(current_a, current_w)
for c = 0 to matrix.columns(z) - 1
matrix.set(z, 0, c, matrix.get(z, 0, c) + matrix.get(current_b, 0, c))
setLayerMatrix(z_values, i, z)
current_a := activate(z)
setLayerMatrix(a_values, i + 1, current_a)
output_value = matrix.columns(current_a) > 0 ? matrix.get(current_a, 0, 0) : 0.0
[output_value, z_values, a_values]
//@function Performs backpropagation to update network weights and biases
//@param prediction The predicted output value from forward pass
//@param target The target value for training
//@param z_values Matrices object containing pre-activation values
//@param a_values Matrices object containing activation values
//@returns Array of updated weight and bias matrices
backpropagate(float prediction, float target, matrices z_values, matrices a_values) =>
if na(w) or na(b)
[w, b]
else
new_w = matrices.new()
new_b = matrices.new()
numLayers = array.size(nodesPerLayer)
for i = 0 to numLayers - 1
curr_w = getLayerMatrix(w, i)
curr_b = getLayerMatrix(b, i)
if not na(curr_w) and not na(curr_b)
setLayerMatrix(new_w, i, matrix.copy(curr_w))
setLayerMatrix(new_b, i, matrix.copy(curr_b))
var float smooth_error_deriv = 0.0
current_learning_rate = learning_rate / (1.0 + learning_rate_decay * bar_index)
error_derivative = huberLossGradient(prediction, target, 0.7)
smooth_error_deriv := error_k * error_derivative + (1.0 - error_k) * smooth_error_deriv
delta_values = matrices.new()
output_delta = matrix.new<float>(1, 1, smooth_error_deriv)
setLayerMatrix(delta_values, numLayers - 1, output_delta)
if numLayers > 1
for i = numLayers - 2 to 0
curr_w = getLayerMatrix(w, i + 1)
curr_a = getLayerMatrix(a_values, i + 1)
next_delta = getLayerMatrix(delta_values, i + 1)
curr_delta = calculateDeltas(curr_w, curr_a, next_delta)
setLayerMatrix(delta_values, i, curr_delta)
if numLayers == 1
input_delta = matrix.new<float>(1, numInputs, 0.0)
setLayerMatrix(delta_values, 0, input_delta)
for i = 0 to numLayers - 1
curr_w = getLayerMatrix(w, i)
curr_b = getLayerMatrix(b, i)
curr_delta = getLayerMatrix(delta_values, i)
curr_a = getLayerMatrix(a_values, i)
new_curr_w = updateLayerWeights(curr_w, curr_a, curr_delta, current_learning_rate, max_gradient)
new_curr_b = updateLayerBiases(curr_b, curr_delta, current_learning_rate, max_gradient)
setLayerMatrix(new_w, i, new_curr_w)
setLayerMatrix(new_b, i, new_curr_b)
[new_w, new_b]
var matrices z_matrices = na
var matrices a_matrices = na
var float normalized_actual_return = na
var float normalized_predicted_return = na
var float predicted_price = na
var float future_price = na
if bar_index > offset
normalized_inputs = calculateInputs(offset)
if barstate.isfirst or (bar_index == offset + 1)
[new_w, new_b] = initializeNetwork(nodesPerLayer, numInputs, 42)
w := new_w
b := new_b
[temp_pred, temp_z, temp_a] = forwardPass(normalized_inputs)
normalized_predicted_return := temp_pred
z_matrices := temp_z
a_matrices := temp_a
actual_return = transform(close[offset], close, algoType)
normalized_actual_return := compressToRange(actual_return)
if not barstate.isrealtime
if not na(normalized_predicted_return) and not na(normalized_actual_return)
[new_ww, new_bb] = backpropagate(normalized_predicted_return, normalized_actual_return, z_matrices, a_matrices)
w := new_ww
b := new_bb
[temp_pred, temp_z, temp_a] = forwardPass(normalized_inputs)
normalized_predicted_return := temp_pred
z_matrices := temp_z
a_matrices := temp_a
normalized_predicted_price = expandFromRange(normalized_predicted_return)
predicted_price := detransform(close[offset], normalized_predicted_price, algoType)
if barstate.isrealtime
future_inputs = calculateInputs(0)
[future_pred, _, _] = forwardPass(future_inputs)
future_denorm = expandFromRange(future_pred)
future_price := detransform(close, future_denorm, algoType)
if not na(future_price)
label.new(bar_index, high,
"Predicted in " + str.tostring(offset) + " bars: " + str.tostring(future_price, "#.##"),
color=color.green, style=label.style_label_down)
plot(predicted_price, "Historical Prediction", color=color.yellow, linewidth=2, offset = -offset)
+21 -65
View File
@@ -1,71 +1,27 @@
# Momentum Indicators # Momentum
> "Momentum tells you how fast price is moving. Whether that movement has meaning: entirely different question." > "Momentum tells you how fast price is moving. Whether that movement has meaning: entirely different question." Unknown
Momentum indicators measure the velocity and acceleration of price changes. Unlike trend indicators (which answer "where is price going?"), momentum indicators answer "how fast?" and "is it slowing down?". This distinction matters: a strong trend can have weakening momentum (divergence), and a ranging market can show momentum spikes (false breakouts). Momentum indicators measure the velocity and acceleration of price changes. Unlike trend indicators (which answer "where is price going?"), momentum indicators answer "how fast?" and "is it slowing down?". This distinction matters: a strong trend can have weakening momentum (divergence), and a ranging market can show momentum spikes (false breakouts).
Core momentum concepts: ## Indicators
- **Rate of Change**: Simple difference or ratio between current and historical prices | Indicator | Full Name | Description |
- **Smoothed Momentum**: Filtered velocity to reduce noise while preserving turning points
- **Bounded Oscillators**: Normalized to fixed range (0-100 or -100 to +100) for threshold-based signals
- **Unbounded Oscillators**: Raw magnitude, requiring context-dependent interpretation
## Implementation Status
| Indicator | Full Name | Status | Description |
| :--- | :--- | :---: | :--- |
| ADX | Average Directional Index | =Ë | Quantifies trend intensity by smoothing the expansion of daily ranges, independent of direction |
| ADXR | ADX Rating | =Ë | Averages current and historical ADX to measure momentum change |
| AMAT | Archer Moving Averages Trends | =Ë | Identifies trend direction and strength using dual EMAs with slope confirmation |
| AO | Awesome Oscillator | =Ë | Measures immediate velocity vs broader trend using fast/slow median-price SMAs |
| APO | Absolute Price Oscillator | =Ë | Absolute difference between two EMAs |
| AROON | Aroon | =Ë | Gauges trend freshness by measuring time elapsed since last high and low |
| AROONOSC | Aroon Oscillator | =Ë | Difference between Aroon Up and Aroon Down |
| [BOP](bop/Bop.md) | Balance of Power |  | Measures buyer/seller strength by comparing close to open relative to range |
| CCI | Commodity Channel Index | =Ë | Measures price deviation from statistical mean, identifies cyclical turns |
| [CFB](cfb/Cfb.md) | Composite Fractal Behavior |  | Measures trend duration and quality via fractal efficiency across 96 time scales |
| CHOP | Choppiness Index | =Ë | Quantifies market choppiness vs trending behavior |
| CMO | Chande Momentum Oscillator | =Ë | Momentum using both up and down changes, bounded but not clamped like RSI |
| DMX | Directional Movement Index | =Ë | Low-lag, bipolar replacement for DMI/ADX combining direction and strength |
| DPO | Detrended Price Oscillator | =Ë | Removes trend to isolate cycles |
| DX | Directional Index | =Ë | Base component for ADX calculation |
| FISHER | Fisher Transform | =Ë | Gaussian normalization for clearer turning points |
| IMI | Intraday Momentum Index | =Ë | Candlestick-based momentum for intraday analysis |
| INERTIA | Inertia | =Ë | Measures resistance to price change |
| KDJ | KDJ Indicator | =Ë | Extended stochastic with J line for divergence |
| [MACD](macd/Macd.md) | Moving Average Convergence Divergence |  | Relationship between two EMAs, identifies momentum and trend direction |
| MOM | Momentum | =Ë | Raw price change over specified period |
| PGO | Pretty Good Oscillator | =Ë | Normalized momentum relative to ATR |
| PMO | Price Momentum Oscillator | =Ë | Double-smoothed ROC oscillator |
| PPO | Percentage Price Oscillator | =Ë | MACD expressed as percentage for cross-instrument comparison |
| PRS | Price Relative Strength | =Ë | Performance ratio between two assets |
| QSTICK | Qstick | =Ë | Quantifies candlestick patterns |
| [ROC](roc/Roc.md) | Rate of Change | | Absolute price change over N periods |
| ROCP | Rate of Change Percentage | =Ë | Percentage price change over N periods |
| ROCR | Rate of Change Ratio | =Ë | Price ratio over N periods |
| [RSI](rsi/Rsi.md) | Relative Strength Index |  | Speed and change of price movements, bounded 0-100 |
| [RSX](rsx/Rsx.md) | Relative Strength Quality Index |  | Noise-free RSI using cascaded IIR filters, zero lag at turning points |
| SMI | Stochastic Momentum Index | =Ë | Stochastic variant measuring distance from midpoint of range |
| STOCH | Stochastic Oscillator | =Ë | Position within recent range, classic overbought/oversold indicator |
| STOCHF | Stochastic Fast | =Ë | Unsmoothed stochastic for faster signals |
| STOCHRSI | Stochastic RSI | =Ë | Stochastic applied to RSI for faster extremes |
| TRIX | Triple Exponential Average | =Ë | Triple-smoothed rate of change |
| TSI | True Strength Index | =Ë | Double-smoothed momentum oscillator |
| ULTOSC | Ultimate Oscillator | =Ë | Combines three timeframes with weighted averages |
| [VEL](vel/Vel.md) | Jurik Velocity |  | Market acceleration via PWMA vs WMA differential |
| VORTEX | Vortex Indicator | =Ë | Trend direction and strength from true range |
| WILLR | Williams %R | =Ë | Inverse stochastic, measures overbought/oversold |
**Legend**:  Implemented | =Ë Planned
## Indicator Selection Guide
| Use Case | Recommended | Rationale |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Overbought/Oversold | RSI, RSX | Bounded, well-understood thresholds | | APO | Absolute Price Oscillator | Absolute difference between two EMAs. |
| Trend Momentum | MACD, CFB | Combines direction with strength | | [BOP](lib/momentum/bop/Bop.md) | Balance of Power | Measures buyer/seller strength by comparing close to open relative to range. |
| Zero-Lag Signals | RSX, VEL | Jurik filters minimize lag at turning points | | CCI | Commodity Channel Index | Measures price deviation from statistical mean, identifies cyclical turns. |
| Divergence Analysis | RSX, MACD | Clear peaks without noise chatter | | [CFB](lib/momentum/cfb/Cfb.md) | Composite Fractal Behavior | Measures trend duration and quality via fractal efficiency across 96 time scales. |
| Cross-Instrument | PPO, CMO | Percentage-based for comparability | | CMO | Chande Momentum Oscillator | Momentum using both up and down changes, bounded but not clamped like RSI. |
| Noise Tolerance | RSX, VEL | Cascaded filtering rejects high-frequency noise | | [MACD](lib/momentum/macd/Macd.md) | Moving Average Convergence Divergence | Relationship between two EMAs, identifies momentum and trend direction. |
| MOM | Momentum | Raw price change over specified period. |
| PMO | Price Momentum Oscillator | Double-smoothed ROC oscillator. |
| PPO | Percentage Price Oscillator | MACD expressed as percentage for cross-instrument comparison. |
| PRS | Price Relative Strength | Performance ratio between two assets. |
| [ROC](lib/momentum/roc/Roc.md) | Rate of Change | Absolute price change over N periods. |
| ROCP | Rate of Change Percentage | Percentage price change over N periods. |
| ROCR | Rate of Change Ratio | Price ratio over N periods. |
| [RSI](lib/momentum/rsi/Rsi.md) | Relative Strength Index | Speed and change of price movements, bounded 0-100. |
| [RSX](lib/momentum/rsx/Rsx.md) | Relative Strength Quality Index | Noise-free RSI using cascaded IIR filters, zero lag at turning points. |
| TSI | True Strength Index | Double-smoothed momentum oscillator. |
| [VEL](lib/momentum/vel/Vel.md) | Jurik Velocity | Market acceleration via PWMA vs WMA differential. |
+1 -8
View File
@@ -124,14 +124,7 @@ public sealed class Roc : AbstractBase
for (int i = 0; i < source.Length; i++) for (int i = 0; i < source.Length; i++)
{ {
if (i < period) output[i] = i < period ? 0.0 : source[i] - source[i - period];
{
output[i] = 0.0;
}
else
{
output[i] = source[i] - source[i - period];
}
} }
} }
+32 -34
View File
@@ -1,39 +1,37 @@
# Numerics # Numerics
> "Price is raw signal. Transform exposes hidden structure. Derivative reveals momentum. Normalization enables comparison. Mathematics is lens, not oracle." > "Price is raw signal. Transform exposes hidden structure. Derivative reveals momentum. Normalization enables comparison."
Basic mathematical transforms and utility functions for time series. These building blocks convert raw price data into forms suitable for analysis, comparison, and downstream indicator consumption. Basic mathematical transforms and utility functions for time series. These building blocks convert raw price data into forms suitable for analysis, comparison, and downstream indicator consumption.
## Implementation Status | Indicator | Full Name | Description |
| :--- | :--- | :--- |
| Indicator | Full Name | Status | Description | | [ACCEL](lib/numerics/accel/Accel.md) | Acceleration | Momentum change; second derivative of price. |
| :--- | :--- | :---: | :--- | | [CHANGE](lib/numerics/change/Change.md) | Percentage Change | Relative price movement over lookback period. |
| [ACCEL](accel/Accel.md) | Acceleration | ✓ | Momentum change; second derivative of price. | | [EXPTRANS](lib/numerics/exptrans/Exptrans.md) | Exponential Transform | e^x transform for log-space conversion reversal. |
| BETADIST | Beta Distribution | ≡ | Continuous probability distribution defined on interval [0, 1] | | [HIGHEST](lib/numerics/highest/Highest.md) | Rolling Maximum | Maximum value over lookback window. |
| BINOMDIST | Binomial Distribution | ≡ | Discrete probability distribution of successes in n independent trials | | [JERK](lib/numerics/jerk/Jerk.md) | Jerk | Rate of acceleration; third derivative of price. |
| [CHANGE](change/Change.md) | Percentage Change | ✓ | Relative price movement over lookback period. | | [LINEARTRANS](lib/numerics/lineartrans/Lineartrans.md) | Linear Transform | y = ax + b scaling transformation. |
| CWT | Continuous Wavelet Transform | ≡ | Analyzes time series data across different frequency scales continuously | | [LOGTRANS](lib/numerics/logtrans/Logtrans.md) | Logarithmic Transform | Natural log for percentage-based analysis. |
| DIFF | Difference | ≡ | Calculates the simple difference between current and previous values | | [LOWEST](lib/numerics/lowest/Lowest.md) | Rolling Minimum | Minimum value over lookback window. |
| DWT | Discrete Wavelet Transform | ≡ | Analyzes time series data across different frequency scales at discrete intervals | | [MIDPOINT](lib/numerics/midpoint/Midpoint.md) | Midrange | (Highest + Lowest) / 2 over lookback window. |
| EXPDIST | Exponential Distribution | ≡ | Continuous probability distribution describing time between events | | [NORMALIZE](lib/numerics/normalize/Normalize.md) | Min-Max Normalization | Scale to [0,1] range using rolling min/max. |
| [EXPTRANS](exptrans/Exptrans.md) | Exponential Transform | ✓ | e^x transform for log-space conversion reversal. | | [RELU](lib/numerics/relu/Relu.md) | Rectified Linear Unit | max(0, x); neural network activation function. |
| FDIST | F-Distribution | ≡ | Continuous probability distribution ratio of two chi-squared distributions | | [SIGMOID](lib/numerics/sigmoid/Sigmoid.md) | Logistic Function | 1/(1+e^-x); bounded [0,1] transform. |
| FFT | Fast Fourier Transform | ≡ | Efficient algorithm for computing the discrete Fourier transform and its inverse | | [SLOPE](lib/numerics/slope/Slope.md) | Rate of Change | First derivative; velocity of price movement. |
| GAMMADIST | Gamma Distribution | ≡ | Continuous probability distribution generalizing exponential and chi-squared | | [SQRTTRANS](lib/numerics/sqrttrans/Sqrttrans.md) | Square Root Transform | Variance-stabilizing transformation. |
| [HIGHEST](highest/Highest.md) | Rolling Maximum | ✓ | Maximum value over lookback window. | | STANDARDIZE | Z-Score Normalization | (x - mean) / stddev; zero-mean unit-variance transform. |
| IFFT | Inverse Fast Fourier Transform | ≡ | Efficient algorithm for computing the inverse discrete Fourier transform | | BETADIST | Beta Distribution | Continuous probability distribution defined on interval [0, 1]. |
| [JERK](jerk/Jerk.md) | Jerk | ✓ | Rate of acceleration; third derivative of price. | | BINOMDIST | Binomial Distribution | Discrete probability distribution of successes in n independent trials. |
| [LINEARTRANS](lineartrans/Lineartrans.md) | Linear Transform | ✓ | y = ax + b scaling transformation. | | CWT | Continuous Wavelet Transform | Analyzes time series data across different frequency scales continuously. |
| LOGNORMDIST | Log-normal Distribution | ≡ | Continuous probability distribution of a variable whose log is normally distributed | | DWT | Discrete Wavelet Transform | Analyzes time series data across different frequency scales at discrete intervals. |
| [LOGTRANS](logtrans/Logtrans.md) | Logarithmic Transform | ✓ | Natural log for percentage-based analysis. | | EXPDIST | Exponential Distribution | Continuous probability distribution describing time between events. |
| [LOWEST](lowest/Lowest.md) | Rolling Minimum | ✓ | Minimum value over lookback window. | | FDIST | F-Distribution | Continuous probability distribution ratio of two chi-squared distributions. |
| [MIDPOINT](midpoint/Midpoint.md) | Midrange | ✓ | (Highest + Lowest) / 2 over lookback window. | | FFT | Fast Fourier Transform | Efficient algorithm for computing the discrete Fourier transform and its inverse. |
| [NORMALIZE](normalize/Normalize.md) | Min-Max Normalization | ✓ | Scale to [0,1] range using rolling min/max. | | GAMMADIST | Gamma Distribution | Continuous probability distribution generalizing exponential and chi-squared. |
| NORMDIST | Normal Distribution | ≡ | Gaussian bell-shaped probability distribution | | IFFT | Inverse Fast Fourier Transform | Efficient algorithm for computing the inverse discrete Fourier transform. |
| POISSONDIST | Poisson Distribution | ≡ | Discrete probability distribution expressing events in fixed time interval | | LOGNORMDIST | Log-normal Distribution | Continuous probability distribution of a variable whose log is normally distributed. |
| [RELU](relu/Relu.md) | Rectified Linear Unit | ✓ | max(0, x); neural network activation function. | | NORMDIST | Normal Distribution | Gaussian bell-shaped probability distribution. |
| [SIGMOID](sigmoid/Sigmoid.md) | Logistic Function | ✓ | 1/(1+e^-x); bounded [0,1] transform. | | POISSONDIST | Poisson Distribution | Discrete probability distribution expressing events in fixed time interval. |
| [SLOPE](slope/Slope.md) | Rate of Change | ✓ | First derivative; velocity of price movement. | | TDIST | Student's t-Distribution | Continuous probability distribution when estimating mean of normally distributed population. |
| [SQRTTRANS](sqrttrans/Sqrttrans.md) | Square Root Transform | ✓ | Variance-stabilizing transformation. | | WEIBULLDIST | Weibull Distribution | Continuous probability distribution useful in reliability and survival analysis. |
| TDIST | Student's t-Distribution | ≡ | Continuous probability distribution when estimating mean of normally distributed population |
| WEIBULLDIST | Weibull Distribution | ≡ | Continuous probability distribution useful in reliability and survival analysis |
+3 -10
View File
@@ -92,15 +92,8 @@ public sealed class Normalize : AbstractBase
var (min, max) = FindMinMax(_buffer.GetSpan()); var (min, max) = FindMinMax(_buffer.GetSpan());
double range = max - min; double range = max - min;
if (range > 0) // Flat range: return 0.5 as neutral
{ result = range > 0 ? (value - min) / range : 0.5;
result = (value - min) / range;
}
else
{
// Flat range: return 0.5 as neutral
result = 0.5;
}
_state = new State(result, min, max); _state = new State(result, min, max);
} }
@@ -209,4 +202,4 @@ public sealed class Normalize : AbstractBase
_p_state = _state; _p_state = _state;
Last = default; Last = default;
} }
} }
+4 -18
View File
@@ -74,14 +74,7 @@ public sealed class Slope : AbstractBase
_p_state = _state; _p_state = _state;
double val = GetValidValue(input.Value); double val = GetValidValue(input.Value);
if (_state.Count >= 1) result = _state.Count >= 1 ? val - _state.PrevValue : 0.0;
{
result = val - _state.PrevValue;
}
else
{
result = 0.0;
}
_state.PrevValue = val; _state.PrevValue = val;
_state.Count = Math.Min(_state.Count + 1, 2); _state.Count = Math.Min(_state.Count + 1, 2);
@@ -92,14 +85,7 @@ public sealed class Slope : AbstractBase
_state.LastValidValue = _p_state.LastValidValue; _state.LastValidValue = _p_state.LastValidValue;
double val = GetValidValue(input.Value); double val = GetValidValue(input.Value);
if (_p_state.Count >= 1) result = _p_state.Count >= 1 ? val - _p_state.PrevValue : 0.0;
{
result = val - _p_state.PrevValue;
}
else
{
result = 0.0;
}
_state.PrevValue = val; _state.PrevValue = val;
_state.Count = Math.Max(_p_state.Count, 1); _state.Count = Math.Max(_p_state.Count, 1);
@@ -238,7 +224,7 @@ public sealed class Slope : AbstractBase
} }
// Scalar fallback for remaining elements // Scalar fallback for remaining elements
// Track last valid value forward to avoid O(n²) backward scanning // Track last valid value forward to avoid O(n²) backward scanning
double lastValid = 0.0; double lastValid = 0.0;
// Find first valid value if we're starting from the beginning // Find first valid value if we're starting from the beginning
if (i == 1) if (i == 1)
@@ -293,4 +279,4 @@ public sealed class Slope : AbstractBase
output[i] = curr - prev; output[i] = curr - prev;
} }
} }
} }
+38 -61
View File
@@ -1,67 +1,44 @@
# Oscillators # Oscillators
> "Oscillators tell you when to act, not which direction to trade."  Unknown > "Oscillators tell you when to act, not which direction to trade." Unknown
Oscillators fluctuate above and below a centerline or within bounded ranges. Useful for identifying overbought/oversold conditions, momentum shifts, and divergences. Best in ranging markets; trend-following indicators work better in trending markets. Oscillators fluctuate above and below a centerline or within bounded ranges. Useful for identifying overbought/oversold conditions, momentum shifts, and divergences. Best in ranging markets; trend-following indicators work better in trending markets.
## Indicator Status | Indicator | Full Name | Description |
| Indicator | Full Name | Status | Description |
| :--- | :--- | :---: | :--- |
| AC | Acceleration Oscillator | = | Second derivative of AO. Measures acceleration of market driving force. |
| [AO](lib/oscillators/ao/ao.md) | Awesome Oscillator |  | 5-period SMA minus 34-period SMA of bar midpoint. Bill Williams creation. |
| [APO](lib/oscillators/apo/Apo.md) | Absolute Price Oscillator |  | Raw currency difference between fast and slow EMAs. Unbounded. |
| BBB | Bollinger %B | = | Position within Bollinger Bands. 0=lower band, 1=upper band. || BBI | Bulls Bears Index | ≡ | Measures the relative strength of bulls and bears based on price action. || BBS | Bollinger Band Squeeze | = | BB width < KC width indicates consolidation. Breakout imminent. || BOP | Balance of Power | ≡ | Measures the strength of buyers vs. sellers by relating price change to the trading range. |
| BRAR | BRAR | ≡ | Combines AR (sentiment) and BR (momentum) indicators to gauge market mood. |
| CCI | Commodity Channel Index | ≡ | Measures price deviation from its statistical mean, identifies cyclical turns. |
| COPPOCK | Coppock Curve | ≡ | Long-term momentum oscillator used primarily for identifying major market bottoms. |
| CRSI | Connors RSI | ≡ | Composite indicator combining RSI, Up/Down Streak Length, and Rate-of-Change. |
| CTI | Correlation Trend Indicator | ≡ | Measures the correlation between price and time to determine trend strength. |
| DOSC | Derivative Oscillator | ≡ | Measures the difference between a double-smoothed RSI and its signal line. || CFO | Chande Forecast Oscillator | = | Percentage difference between price and linear regression forecast. |
| DPO | Detrended Price Oscillator | = | Removes trend via displaced SMA. Reveals cycles. || ER | Efficiency Ratio | ≡ | Measures price efficiency by comparing net price movement to total price movement (KAMA component). |
| ERI | Elder Ray Index | ≡ | Measures buying (Bull Power) and selling (Bear Power) pressure relative to an EMA. || FISHER | Fisher Transform | = | Converts prices to Gaussian distribution. Sharp reversals. || FOSC | Forecast Oscillator | ≡ | Plots the percentage difference between a forecast price (e.g., linear regression) and the actual price. || INERTIA | Inertia | = | Trend strength from distance to linear regression line. |
| KDJ | KDJ Indicator | = | Enhanced Stochastic. J = 3K - 2D provides leading signal. || KRI | Kairi Relative Index | ≡ | Measures the deviation of the current price from its simple moving average. |
| KST | KST Oscillator | ≡ | Smoothed, weighted Rate-of-Change oscillator combining multiple timeframes. || PGO | Pretty Good Oscillator | = | Distance from SMA normalized by ATR. Units: ATR multiples. || PSL | Psychological Line | ≡ | Measures percentage of days closing up over a specified period, gauges sentiment. |
| QQE | Quantitative Qualitative Estimation | ≡ | Smoothing technique applied to RSI, providing trade signals via signal line crossovers. |
| RVGI | Relative Vigor Index | ≡ | Compares closing price to trading range. || SMI | Stochastic Momentum Index | = | Distance from range midpoint. More sensitive than classic Stochastic. || SQUEEZE | Squeeze | ≡ | Identifies periods of low volatility (Bollinger Bands inside Keltner Channels) for potential breakouts. || STOCH | Stochastic Oscillator | = | Close position within N-period high-low range. Classic overbought/oversold. |
| STOCHF | Stochastic Fast | = | Unsmoothed Stochastic. Faster but noisier. |
| STOCHRSI | Stochastic RSI | = | Stochastic applied to RSI. More sensitive than either alone. || TD_SEQ | TD Sequential | ≡ | Identifies potential price exhaustion points and reversals based on price bar counting. || TRIX | Triple Exponential Average | = | ROC of triple EMA. Filters noise through three smoothings. |
| [ULTOSC](lib/oscillators/ultosc/ultosc.md) | Ultimate Oscillator |  | Multi-timeframe oscillator. Combines 7, 14, 28 period buying pressure. |
| WILLR | Williams %R | = | Inverse Stochastic. -100 to 0 range. Overbought/oversold. |
**Status Key:**  Implemented | = Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Momentum confirmation | AO, APO | AO for bar midpoint. APO for close price. Both unbounded. | | AC | Acceleration Oscillator | Second derivative of AO. Measures acceleration of market driving force. |
| Overbought/oversold | STOCH, WILLR, STOCHRSI | Bounded 0-100 or -100 to 0. Classic mean reversion signals. | | [AO](lib/oscillators/ao/Ao.md) | Awesome Oscillator | 5-period SMA minus 34-period SMA of bar midpoint. Bill Williams creation. |
| Multi-timeframe analysis | ULTOSC | Combines three periods. Reduces false signals. | | APO | Absolute Price Oscillator | Raw currency difference between fast and slow EMAs. Unbounded. |
| Cycle detection | DPO | Removes trend to reveal underlying cycles. | | BBB | Bollinger %B | Position within Bollinger Bands. 0=lower band, 1=upper band. |
| Leading signals | KDJ, FISHER | J-line leads K and D. Fisher provides sharp turns. | | BBS | Bollinger Band Squeeze | BB width < KC width indicates consolidation. Breakout imminent. |
| Noise filtering | TRIX | Triple smoothing removes most short-term noise. | | CFO | Chande Forecast Oscillator | Percentage difference between price and linear regression forecast. |
| Volatility-normalized | PGO | ATR normalization makes signals comparable across instruments. | | DPO | Detrended Price Oscillator | Removes trend via displaced SMA. Reveals cycles. |
| FISHER | Fisher Transform | Converts prices to Gaussian distribution. Sharp reversals. |
## Oscillator Types | INERTIA | Inertia | Trend strength from distance to linear regression line. |
| KDJ | KDJ Indicator | Enhanced Stochastic. J = 3K - 2D provides leading signal. |
| Type | Examples | Range | Best For | | PGO | Pretty Good Oscillator | Distance from SMA normalized by ATR. Units: ATR multiples. |
| :--- | :--- | :--- | :--- | | SMI | Stochastic Momentum Index | Distance from range midpoint. More sensitive than classic Stochastic. |
| Bounded (0-100) | STOCH, STOCHRSI | 0 to 100 | Overbought/oversold zones | | STOCH | Stochastic Oscillator | Close position within N-period high-low range. Classic overbought/oversold. |
| Bounded (-100 to 0) | WILLR | -100 to 0 | Mean reversion | | STOCHF | Stochastic Fast | Unsmoothed Stochastic. Faster but noisier. |
| Bounded (-1 to +1) | FISHER | - to + (practical: 3) | Sharp reversal signals | | STOCHRSI | Stochastic RSI | Stochastic applied to RSI. More sensitive than either alone. |
| Unbounded | AO, APO, DPO | - to + | Trend momentum | | TRIX | Triple Exponential Average | ROC of triple EMA. Filters noise through three smoothings. |
| Normalized | PGO, CFO | ATR or % units | Cross-market comparison | | [ULTOSC](lib/oscillators/ultosc/Ultosc.md) | Ultimate Oscillator | Multi-timeframe oscillator. Combines 7, 14, 28 period buying pressure. |
| WILLR | Williams %R | Inverse Stochastic. -100 to 0 range. Overbought/oversold. |
## Divergence Analysis | BBI | Bulls Bears Index | Measures relative strength of bulls and bears based on price action. |
| BOP | Balance of Power | Measures strength of buyers vs. sellers by relating price change to trading range. |
Oscillator divergence signals potential reversals: | BRAR | BRAR | Combines AR (sentiment) and BR (momentum) indicators to gauge market mood. |
| CCI | Commodity Channel Index | Measures price deviation from statistical mean, identifies cyclical turns. |
| Price Action | Oscillator Action | Signal | | COPPOCK | Coppock Curve | Long-term momentum oscillator for identifying major market bottoms. |
| :--- | :--- | :--- | | CRSI | Connors RSI | Composite indicator combining RSI, Up/Down Streak Length, and Rate-of-Change. |
| Higher high | Lower high | Bearish divergence. Weakening momentum. | | CTI | Correlation Trend Indicator | Measures correlation between price and time to determine trend strength. |
| Lower low | Higher low | Bullish divergence. Strengthening support. | | DOSC | Derivative Oscillator | Measures difference between double-smoothed RSI and its signal line. |
| Higher high | Higher high | Confirmation. Trend intact. | | ER | Efficiency Ratio | Measures price efficiency by comparing net to total price movement. |
| Lower low | Lower low | Confirmation. Trend intact. | | ERI | Elder Ray Index | Measures buying (Bull Power) and selling (Bear Power) pressure relative to EMA. |
| FOSC | Forecast Oscillator | Percentage difference between forecast price and actual price. |
Divergences work best with bounded oscillators (STOCH, RSI, WILLR) where extremes are well-defined. | KRI | Kairi Relative Index | Measures deviation of current price from its simple moving average. |
| KST | KST Oscillator | Smoothed, weighted Rate-of-Change combining multiple timeframes. |
| PSL | Psychological Line | Percentage of days closing up over period, gauges sentiment. |
| QQE | Quantitative Qualitative Estimation | Smoothing technique applied to RSI with signal line crossovers. |
| RVGI | Relative Vigor Index | Compares closing price to trading range. |
| SQUEEZE | Squeeze | Identifies low volatility when BB inside KC for potential breakouts. |
| TD_SEQ | TD Sequential | Identifies price exhaustion points and reversals via bar counting. |
+15 -72
View File
@@ -1,76 +1,19 @@
# Reversals # Reversals
> "Pivot point is hypothesis, not prophecy. Mathematics identifies levels where crowd psychology may shift. Market decides whether to respect calculation or ignore it entirely." > "The market speaks in reversals. The art is hearing it above the noise."
Tools indicating potential reversals, support/resistance, or pivot points. These indicators identify price levels where trend exhaustion or continuation decisions occur. Reversal indicators identify potential turning points where price may change direction. Pivot points calculate support/resistance from prior period data. Pattern-based tools detect structural shifts in price action.
## Implementation Status | Indicator | Full Name | Description |
| :--- | :--- | :--- |
| Indicator | Full Name | Status | Description | | FRACTALS | Williams Fractals | Five-bar pattern identifying local peaks/troughs; marks support/resistance levels. |
| :--- | :--- | :---: | :--- | | PIVOT | Pivot Points (Classic) | Standard floor trader pivots with 7 levels (PP, R1-R3, S1-S3). |
| FRACTALS | Williams Fractals | 📋 | Five-bar pattern identifying local peaks/troughs; marks support/resistance levels. | | PIVOTCAM | Camarilla Pivot Points | Mean-reversion pivots with 9 levels; R3/S3 are key reversal zones. |
| PIVOT | Pivot Points (Classic) | 📋 | Standard floor trader pivots with 7 levels (PP, R1-R3, S1-S3). | | PIVOTDEM | DeMark Pivot Points | Minimalist trend-following pivots with only 3 levels and conditional logic. |
| PIVOTCAM | Camarilla Pivot Points | 📋 | Mean-reversion pivots with 9 levels; R3/S3 are key reversal zones. | | PIVOTEXT | Extended Traditional Pivots | Extended pivots with 11 levels (R1-R5, S1-S5) for volatile markets. |
| PIVOTDEM | DeMark Pivot Points | 📋 | Minimalist trend-following pivots with only 3 levels and conditional logic. | | PIVOTFIB | Fibonacci Pivot Points | Fibonacci-ratio based pivots; Golden Ratio (61.8%) at R2/S2. |
| PIVOTEXT | Extended Traditional Pivots | 📋 | Extended pivots with 11 levels (R1-R5, S1-S5) for volatile markets. | | PIVOTWOOD | Woodie's Pivot Points | Weighted close pivots (2× close weight) for intraday trading. |
| PIVOTFIB | Fibonacci Pivot Points | 📋 | Fibonacci-ratio based pivots; Golden Ratio (61.8%) at R2/S2. | | PSAR | Parabolic Stop And Reverse | Trailing stop that accelerates with trend; SAR dots mark entry/exit signals. |
| PIVOTWOOD | Woodie's Pivot Points | 📋 | Weighted close pivots (2× close weight) for intraday trading. | | SWINGS | Swing High/Low Detection | Identifies significant price reversals and swing points using configurable lookback. |
| PSAR | Parabolic Stop And Reverse | 📋 | Trailing stop indicator that accelerates with trend; provides entry/exit signals via SAR dots. | | CHANDELIER | Chandelier Exit | ATR-based trailing stop; Highest High - (ATR × Multiplier) for long exits. |
| SWINGS | Swing High/Low Detection | 📋 | Identifies significant price reversals and swing points using configurable lookback. | | CKSTOP | Chande Kroll Stop | Dual stop system using True Range for both long and short positions. |
## Selection Guide
**For intraday trading:** Classic PIVOT provides baseline levels. PIVOTWOOD emphasizes closing price for day-session context. PIVOTCAM targets mean-reversion at R3/S3 zones.
**For swing trading:** PIVOTFIB uses Fibonacci ratios aligned with retracement analysis. PIVOTEXT provides extended levels for multi-day moves. FRACTALS marks structural highs/lows.
**For trend-following:** PSAR provides trailing stop with acceleration. PIVOTDEM uses conditional logic based on prior bar relationship. SWINGS identifies trend reversal points.
**For volatile markets:** PIVOTEXT with 11 levels captures extreme moves. PIVOTCAM's outer levels (R4/S4) act as volatility breakout zones.
## Pivot Point Comparison
| System | Levels | Formula Basis | Trading Style |
| :--- | :---: | :--- | :--- |
| Classic | 7 | (H+L+C)/3 | General purpose |
| Woodie | 7 | (H+L+2C)/4 | Intraday, close-weighted |
| Camarilla | 9 | Range × multipliers | Mean-reversion |
| DeMark | 3 | Conditional on O/C relationship | Trend-following |
| Fibonacci | 7 | PP ± (H-L) × Fib ratios | Retracement alignment |
| Extended | 11 | Classic + outer levels | High volatility |
## Pivot Level Calculations
| Level | Classic | Woodie | Camarilla |
| :--- | :--- | :--- | :--- |
| R4 | — | — | C + (H-L) × 1.5/2 |
| R3 | 2×PP - 2×L | — | C + (H-L) × 1.25/4 |
| R2 | PP + (H-L) | PP + (H-L) | C + (H-L) × 1.1/6 |
| R1 | 2×PP - L | 2×PP - L | C + (H-L) × 1.1/12 |
| PP | (H+L+C)/3 | (H+L+2C)/4 | — |
| S1 | 2×PP - H | 2×PP - H | C - (H-L) × 1.1/12 |
| S2 | PP - (H-L) | PP - (H-L) | C - (H-L) × 1.1/6 |
| S3 | 2×PP - 2×H | — | C - (H-L) × 1.25/4 |
| S4 | — | — | C - (H-L) × 1.5/2 |
## Reversal Pattern Types
| Pattern | Indicator | Bars Required | Signal Type |
| :--- | :--- | :---: | :--- |
| Williams Fractal Up | FRACTALS | 5 | Resistance marked at middle high |
| Williams Fractal Down | FRACTALS | 5 | Support marked at middle low |
| Swing High | SWINGS | Configurable | Local maximum confirmation |
| Swing Low | SWINGS | Configurable | Local minimum confirmation |
| SAR Flip | PSAR | 1 | Trend reversal signal |
## PSAR Mechanics
Parabolic SAR uses acceleration factor that increases with each new extreme:
| Parameter | Default | Range | Effect |
| :--- | :---: | :--- | :--- |
| Initial AF | 0.02 | 0.01-0.05 | Starting sensitivity |
| AF Step | 0.02 | 0.01-0.05 | Acceleration rate |
| Max AF | 0.20 | 0.10-0.30 | Maximum sensitivity |
Higher AF values create tighter stops (more whipsaws, earlier exits). Lower AF values create wider stops (fewer signals, later exits).
+35 -58
View File
@@ -4,62 +4,39 @@
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. 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 Status | Indicator | Full Name | Description |
| Indicator | Full Name | Status | Description |
| :--- | :--- | :---: | :--- |
| [BETA](lib/statistics/beta/beta.md) | Beta Coefficient | ✅ | Asset volatility relative to market. β=1 means market-matched risk. |
| BIAS | 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 | Cointegration | 📋 | Tests if series share long-term equilibrium. Pairs trading foundation. |
| CORRELATION | Correlation (Pearson's) | 📋 | 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 | Cumulative Mean | 📋 | Cumulative mean from series start. Ignores NaN values. |
| ENTROPY | Shannon Entropy | 📋 | Measures uncertainty/randomness. Higher entropy = less predictable. |
| GEOMEAN | Geometric Mean | 📋 | nth root of product. Use for growth rates and ratios. |
| GRANGER | Granger Causality | 📋 | Tests if one series helps predict another. Not true causality. |
| HARMEAN | Harmonic Mean | 📋 | Reciprocal of arithmetic mean of reciprocals. For rates/ratios. |
| HURST | Hurst Exponent | 📋 | Long-term memory. H>0.5: trending. H<0.5: mean-reverting. |
| IQR | Interquartile Range | 📋 | P75 - P25. Robust dispersion measure. |
| JB | Jarque-Bera Test | 📋 | Normality test using skewness and kurtosis. |
| KENDALL | Kendall Rank Correlation | 📋 | Ordinal association. Robust to outliers. |
| KURTOSIS | 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 | Mode | 📋 | Most frequent value. Use for categorical or discrete data. |
| PERCENTILE | Percentile | 📋 | Value below which given percentage of observations fall. |
| QUANTILE | Quantile | 📋 | Divides distribution into equal probability intervals. |
| [SKEW](lib/statistics/skew/Skew.md) | Skewness | ✅ | Distribution asymmetry. Positive: right tail. Negative: left tail. |
| SPEARMAN | 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 | 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 | Z-Score | 📋 | Standard deviations from mean. Normalizes different scales. |
| ZTEST | Z-Test | 📋 | Hypothesis test comparing sample mean to population mean. |
**Status Key:** ✅ Implemented | 📋 Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Dispersion measurement | STDDEV, VARIANCE | Standard measures. STDDEV in original units. | | [BETA](lib/statistics/beta/Beta.md) | Beta Coefficient | Asset volatility relative to market. β=1 means market-matched risk. |
| Outlier-robust dispersion | MEDIAN, IQR | Median ignores extremes. IQR measures middle 50%. | | BIAS | Bias | Percentage deviation from moving average. Measures overextension. |
| Central tendency | CMA, MEDIAN | CMA for normal data. MEDIAN for skewed data. | | [CMA](lib/statistics/cma/Cma.md) | Cumulative Moving Average | Running average of all values. Welford's algorithm. No window. |
| Trend fitting | LINREG | Least squares regression. Provides slope and R². | | COINTEGRATION | Cointegration | Tests if series share long-term equilibrium. Pairs trading foundation. |
| Distribution shape | SKEW, KURTOSIS | Skew for asymmetry. Kurtosis for tail risk. | | CORRELATION | Correlation | Linear relationship between two variables. Range: -1 to +1. |
| Pair relationships | CORRELATION, COVARIANCE, BETA | Correlation normalized. Covariance raw. Beta relative to benchmark. | | [COVARIANCE](lib/statistics/covariance/Covariance.md) | Covariance | Joint variability of two random variables. Building block for β. |
| Regime detection | HURST, ENTROPY | Hurst for trending vs mean-reverting. Entropy for randomness. | | CUMMEAN | Cumulative Mean | Cumulative mean from series start. Ignores NaN values. |
| Normality testing | JB | Quick normality check before parametric tests. | | ENTROPY | Shannon Entropy | Measures uncertainty/randomness. Higher entropy = less predictable. |
| GEOMEAN | Geometric Mean | nth root of product. Use for growth rates and ratios. |
## Statistical Concepts | GRANGER | Granger Causality | Tests if one series helps predict another. Not true causality. |
| HARMEAN | Harmonic Mean | Reciprocal of arithmetic mean of reciprocals. For rates/ratios. |
| Concept | Implemented As | Interpretation | | HURST | Hurst Exponent | Long-term memory. H>0.5: trending. H<0.5: mean-reverting. |
| :--- | :--- | :--- | | IQR | Interquartile Range | P75 - P25. Robust dispersion measure. |
| Location | CMA, MEDIAN | Where is the center? | | JB | Jarque-Bera Test | Normality test using skewness and kurtosis. |
| Spread | VARIANCE, STDDEV, IQR | How dispersed is data? | | KENDALL | Kendall Rank Correlation | Ordinal association. Robust to outliers. |
| Shape | SKEW, KURTOSIS | Is distribution symmetric? Fat-tailed? | | KURTOSIS | Kurtosis | Tail heaviness. High kurtosis = fat tails = more extreme events. |
| Relationship | CORRELATION, COVARIANCE, BETA | How do two series move together? | | [LINREG](lib/statistics/linreg/LinReg.md) | Linear Regression | Least squares fit. Outputs slope, intercept, R². |
| Trend | LINREG | What is underlying direction? | | [MEDIAN](lib/statistics/median/Median.md) | Median | Middle value in sorted window. Robust to outliers. |
| Memory | HURST | Does past predict future? | | MODE | Mode | Most frequent value. Use for categorical or discrete data. |
| PERCENTILE | Percentile | Value below which given percentage of observations fall. |
| QUANTILE | Quantile | Divides distribution into equal probability intervals. |
| [SKEW](lib/statistics/skew/Skew.md) | Skewness | Distribution asymmetry. Positive: right tail. Negative: left tail. |
| SPEARMAN | 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 | 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 | Z-Score | Standard deviations from mean. Normalizes different scales. |
| ZTEST | Z-Test | Hypothesis test comparing sample mean to population mean. |
| ACF | Autocorrelation Function | Measures correlation between observations at different time lags. |
| PACF | Partial Autocorrelation | Correlation at lag k without intermediate correlations. |
| POLYFIT | Polynomial Fitting | Fits polynomial curve to data points. |
| TSF | Time Series Forecast | Predicts future values based on past data. |
| WAVG | Weighted Average | Average where each value has weight determining relative importance. |
+20 -58
View File
@@ -1,65 +1,27 @@
# Trends (FIR) # Trends (FIR)
> "FIR filters are always stable. The question is how many coefficients you need."  Digital Signal Processing folklore > "FIR filters are always stable. The question is how many coefficients you need." Digital Signal Processing folklore
Finite Impulse Response (FIR) trend indicators. These use fixed-length windows with explicit coefficients. No feedback loops, no recursion. Output depends only on current and past inputs. Always stable. Linear phase possible. SIMD-friendly batch computation. Finite Impulse Response (FIR) trend indicators. These use fixed-length windows with explicit coefficients. No feedback loops, no recursion. Output depends only on current and past inputs. Always stable. Linear phase possible. SIMD-friendly batch computation.
## Indicator Status ## Indicators
| Indicator | Full Name | Status | Description | | Indicator | Full Name | Description |
| :--- | :--- | :---: | :--- |
| [ALMA](lib/trends_FIR/alma/Alma.md) | Arnaud Legoux MA |  | Gaussian window with offset parameter. Smooth with configurable lag. |
| [BLMA](lib/trends_FIR/blma/Blma.md) | Blackman MA |  | Blackman window. Excellent side-lobe suppression (-58 dB). |
| [BWMA](lib/trends_FIR/bwma/Bwma.md) | Bessel-Weighted MA |  | Bessel window function. Good frequency resolution. |
| [Conv](lib/trends_FIR/conv/Conv.md) | Convolution MA |  | Generic convolution with custom kernel. Building block for others. |
| [DWMA](lib/trends_FIR/dwma/Dwma.md) | Double Weighted MA |  | WMA of WMA. Smoother than single WMA. Triangular-like response. |
| [GWMA](lib/trends_FIR/gwma/Gwma.md) | Gaussian Weighted MA |  | Centered Gaussian bell curve. No overshoot. Ã controls width. |
| [HAMMA](lib/trends_FIR/hamma/Hamma.md) | Hamming MA |  | Hamming window. -43 dB side lobes. Good general purpose. |
| [HANMA](lib/trends_FIR/hanma/Hanma.md) | Hanning MA |  | Hanning (raised cosine). Zero at edges. Smooth roll-off. |
| [HMA](lib/trends_FIR/hma/Hma.md) | Hull MA |  | Reduced lag via weighted average differencing. Can overshoot. |
| [HWMA](lib/trends_FIR/hwma/Hwma.md) | Holt-Winters MA |  | Triple exponential smoothing. Tracks level, velocity, acceleration. |
| [LSMA](lib/trends_FIR/lsma/Lsma.md) | Least Squares MA |  | Linear regression endpoint. Extrapolates trend. |
| [PWMA](lib/trends_FIR/pwma/Pwma.md) | Pascal Weighted MA |  | Pascal's triangle coefficients. Binomial distribution weights. |
| [SGMA](lib/trends_FIR/sgma/Sgma.md) | Savitzky-Golay MA |  | Polynomial fit. Preserves higher moments. Shape-preserving. |
| [SINEMA](lib/trends_FIR/sinema/Sinema.md) | Sine-Weighted MA |  | Sine wave weighting. Smooth bell-shaped emphasis. |
| [SMA](lib/trends_FIR/sma/Sma.md) | Simple MA |  | Equal weights. Baseline reference. Lag = (N-1)/2. |
| [TRIMA](lib/trends_FIR/trima/Trima.md) | Triangular MA |  | Triangular weights. SMA of SMA. Emphasizes middle. |
| [WMA](lib/trends_FIR/wma/Wma.md) | Weighted MA |  | Linear weights. Recent prices weighted more. Lag < SMA. |
**Status Key:**  Implemented | =Ë Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Baseline comparison | SMA | Simple, well-understood. Reference for lag/smoothness. | | [ALMA](lib/trends_FIR/alma/Alma.md) | Arnaud Legoux MA | Gaussian window with offset parameter. Smooth with configurable lag. |
| Reduced lag | HMA, WMA, LSMA | HMA aggressive. WMA moderate. LSMA extrapolates. | | [BLMA](lib/trends_FIR/blma/Blma.md) | Blackman MA | Blackman window. Excellent side-lobe suppression (-58 dB). |
| Minimal overshoot | GWMA, TRIMA | Gaussian and triangular weights are gentle. | | [BWMA](lib/trends_FIR/bwma/Bwma.md) | Bessel-Weighted MA | Bessel window function. Good frequency resolution. |
| Spectral purity | BLMA, HAMMA | Window functions designed for frequency analysis. | | [CONV](lib/trends_FIR/conv/Conv.md) | Convolution MA | Generic convolution with custom kernel. Building block for others. |
| Shape preservation | SGMA | Polynomial fit preserves peaks and valleys. | | [DWMA](lib/trends_FIR/dwma/Dwma.md) | Double Weighted MA | WMA of WMA. Smoother than single WMA. Triangular-like response. |
| Configurable response | ALMA, Conv | ALMA has offset/sigma. Conv accepts any kernel. | | [GWMA](lib/trends_FIR/gwma/Gwma.md) | Gaussian Weighted MA | Centered Gaussian bell curve. No overshoot. σ controls width. |
| Trend extrapolation | LSMA, HWMA | LSMA extends regression. HWMA tracks velocity. | | [HAMMA](lib/trends_FIR/hamma/Hamma.md) | Hamming MA | Hamming window. -43 dB side lobes. Good general purpose. |
| [HANMA](lib/trends_FIR/hanma/Hanma.md) | Hanning MA | Hanning (raised cosine). Zero at edges. Smooth roll-off. |
## FIR vs IIR Comparison | [HMA](lib/trends_FIR/hma/Hma.md) | Hull MA | Reduced lag via weighted average differencing. Can overshoot. |
| [HWMA](lib/trends_FIR/hwma/Hwma.md) | Holt-Winters MA | Triple exponential smoothing. Tracks level, velocity, acceleration. |
| Aspect | FIR (This Category) | IIR (trends_IIR) | | [LSMA](lib/trends_FIR/lsma/Lsma.md) | Least Squares MA | Linear regression endpoint. Extrapolates trend. |
| :--- | :--- | :--- | | [PWMA](lib/trends_FIR/pwma/Pwma.md) | Pascal Weighted MA | Pascal's triangle coefficients. Binomial distribution weights. |
| Stability | Always stable | Can be unstable if poorly designed | | [SGMA](lib/trends_FIR/sgma/Sgma.md) | Savitzky-Golay MA | Polynomial fit. Preserves higher moments. Shape-preserving. |
| Phase | Linear phase possible | Nonlinear phase (causes distortion) | | [SINEMA](lib/trends_FIR/sinema/Sinema.md) | Sine-Weighted MA | Sine wave weighting. Smooth bell-shaped emphasis. |
| Coefficients | Many (N = period) | Few (2-4 typically) | | [SMA](lib/trends_FIR/sma/Sma.md) | Simple MA | Equal weights. Baseline reference. Lag = (N-1)/2. |
| Memory | Higher | Lower | | [TRIMA](lib/trends_FIR/trima/Trima.md) | Triangular MA | Triangular weights. SMA of SMA. Emphasizes middle. |
| Computation | O(N) per sample, SIMD-friendly | O(1) per sample, recursive | | [WMA](lib/trends_FIR/wma/Wma.md) | Weighted MA | Linear weights. Recent prices weighted more. Lag < SMA. |
| Lag | Fixed for given N | Can be lower for same smoothness |
| Overshoot | Generally low | Can overshoot (especially JMA, HMA) |
## Window Function Characteristics
| Window | Main Lobe Width | Side Lobe (dB) | Best For |
| :--- | :--- | :--- | :--- |
| Rectangular (SMA) | Narrow | -13 | Frequency resolution |
| Hanning | Medium | -31 | General purpose |
| Hamming | Medium | -43 | Better side-lobe rejection |
| Blackman | Wide | -58 | Excellent side-lobe rejection |
| Gaussian | Configurable | Configurable | Tunable trade-off |
Narrower main lobe = better frequency resolution. Lower side lobes = less spectral leakage.
@@ -1,79 +0,0 @@
---
description: Configuration for AI behavior when interacting with Codacy's MCP Server
applyTo: '**'
---
---
# Codacy Rules
Configuration for AI behavior when interacting with Codacy's MCP Server
## using any tool that accepts the arguments: `provider`, `organization`, or `repository`
* ALWAYS use:
* provider: gh
* organization: mihakralj
* repository: QuanTAlib
* Avoid calling `git remote -v` unless really necessary
## CRITICAL: After ANY successful `edit_file` or `reapply` operation
* YOU MUST IMMEDIATELY run the `codacy_cli_analyze` tool from Codacy's MCP Server for each file that was edited, with:
* `rootPath`: set to the workspace path
* `file`: set to the path of the edited file
* `tool`: leave empty or unset
* If any issues are found in the new edits, propose and apply fixes for them.
* > NOTE: Failure to follow this rule is considered a critical error.
## When you tried to run the `codacy_cli_analyze` tool and the Codacy CLI is not installed
* Ask the user 'Codacy CLI is not installed. Would you like me to install it now?'
* If the user responds with "yes", run the `codacy_cli_install` tool and then continue with the original task
* If the user responds with "no", instruct the user that they can disable automatic analysis in the extension settings
* Wait for the user to respond before proceeding with any other actions
## After every response
* If you made any file edits in this conversation, verify you ran `codacy_cli_analyze` tool from Codacy's MCP Server
## When there are no Codacy MCP Server tools available, or the MCP Server is not reachable
* Suggest the user the following troubleshooting steps:
* Try to reset the MCP on the extension
* If the user is using VSCode, suggest them to review their Copilot > MCP settings in Github, under their organization or personal account. Refer them to Settings > Copilot > Enable MCP servers in Copilot. Suggested URL (https://github.com/settings/copilot/features) or https://github.com/organizations/{organization-name}/settings/copilot/features (This can only be done by their organization admins / owners)
* If none of the above steps work, suggest the user to contact Codacy support
## Trying to call a tool that needs a rootPath as a parameter
* Always use the standard, non-URL-encoded file system path
## CRITICAL: Dependencies and Security Checks
* IMMEDIATELY after ANY of these actions:
* Running npm/yarn/pnpm install
* Adding dependencies to package.json
* Adding requirements to requirements.txt
* Adding dependencies to pom.xml
* Adding dependencies to build.gradle
* Any other package manager operations
* You MUST run the `codacy_cli_analyze` tool with:
* `rootPath`: set to the workspace path
* `tool`: set to "trivy"
* `file`: leave empty or unset
* If any vulnerabilities are found because of the newly added packages:
* Stop all other operations
* Propose and apply fixes for the security issues
* Only continue with the original task after security issues are resolved
* EXAMPLE:
* After: npm install react-markdown
* Do: Run codacy_cli_analyze with trivy
* Before: Continuing with any other tasks
## General
* Repeat the relevant steps for each modified file.
* "Propose fixes" means to both suggest and, if possible, automatically apply the fixes.
* You MUST NOT wait for the user to ask for analysis or remind you to run the tool.
* Do not run `codacy_cli_analyze` looking for changes in duplicated code or code complexity metrics.
* Complexity metrics are different from complexity issues. When trying to fix complexity in a repository or file, focus on solving the complexity issues and ignore the complexity metric.
* Do not run `codacy_cli_analyze` looking for changes in code coverage.
* Do not try to manually install Codacy CLI using either brew, npm, npx, or any other package manager.
* If the Codacy CLI is not installed, just run the `codacy_cli_analyze` tool from Codacy's MCP Server.
* When calling `codacy_cli_analyze`, only send provider, organization and repository if the project is a git repository.
## Whenever a call to a Codacy tool that uses `repository` or `organization` as a parameter returns a 404 error
* Offer to run the `codacy_setup_repository` tool to add the repository to Codacy
* If the user accepts, run the `codacy_setup_repository` tool
* Do not ever try to run the `codacy_setup_repository` tool on your own
* After setup, immediately retry the action that failed (only retry once)
---
-4
View File
@@ -1,4 +0,0 @@
#Ignore vscode AI rules
.github\instructions\codacy.instructions.md
-1
View File
@@ -1 +0,0 @@
{}
+4 -10
View File
@@ -637,15 +637,9 @@ public sealed class Wma : AbstractBase
var vWsums = Avx.Add(vWsumState, vPw2); var vWsums = Avx.Add(vWsumState, vPw2);
Vector256<double> vResult; Vector256<double> vResult = Fma.IsSupported
if (Fma.IsSupported) ? Fma.MultiplyAdd(vWsums, vInvDivisor, vZero)
{ : Avx.Multiply(vWsums, vInvDivisor);
vResult = Fma.MultiplyAdd(vWsums, vInvDivisor, vZero);
}
else
{
vResult = Avx.Multiply(vWsums, vInvDivisor);
}
vResult.StoreUnsafe(ref Unsafe.Add(ref outRef, idx)); vResult.StoreUnsafe(ref Unsafe.Add(ref outRef, idx));
vSumState = Avx2.Permute4x64(vSums.AsUInt64(), 0b_11_11_11_11).AsDouble(); // skipcq: CS-R1131 vSumState = Avx2.Permute4x64(vSums.AsUInt64(), 0b_11_11_11_11).AsDouble(); // skipcq: CS-R1131
@@ -832,4 +826,4 @@ public sealed class Wma : AbstractBase
Unsafe.Add(ref outRef, idx) = wsum * invDivisor; Unsafe.Add(ref outRef, idx) = wsum * invDivisor;
} }
} }
} }
+25 -84
View File
@@ -4,88 +4,29 @@
Trend indicators based on Infinite Impulse Response (IIR) filters. Recursive architecture uses previous outputs to compute current values, enabling lower lag with fewer coefficients than equivalent FIR filters. Trend indicators based on Infinite Impulse Response (IIR) filters. Recursive architecture uses previous outputs to compute current values, enabling lower lag with fewer coefficients than equivalent FIR filters.
## Implementation Status | Indicator | Full Name | Description |
| Indicator | Full Name | Status | Description |
| :--- | :--- | :---: | :--- |
| [DEMA](dema/Dema.md) | Double Exponential MA |  | Reduces lag by applying double exponential smoothing, enhancing responsiveness while maintaining signal quality. |
| [DSMA](dsma/Dsma.md) | Deviation-Scaled MA |  | Adaptive IIR filter that adjusts smoothing factor based on market volatility, increasing responsiveness during high-deviation periods. |
| [EMA](ema/Ema.md) | Exponential MA |  | Applies exponentially decreasing weights to price data, balancing responsiveness and stability. |
| [FRAMA](frama/Frama.md) | Fractal Adaptive MA |  | Adapts smoothing based on fractal dimension analysis, minimizing lag in trends and maximizing smoothing in consolidation. |
| [HEMA](hema/Hema.md) | Hull Exponential MA |  | EMA-domain Hull analog using half-life timing and de-lagged EMA cascade. |
| [HTIT](htit/Htit.md) | Hilbert Transform Instantaneous Trend |  | Utilizes Hilbert Transform to isolate instantaneous trend component, providing zero-lag trendline with hybrid FIR-in-IIR design. |
| [JMA](jma/Jma.md) | Jurik MA |  | Adaptive filter achieving high noise reduction and low phase delay through multi-stage volatility normalization and dynamic parameter optimization. |
| [KAMA](kama/Kama.md) | Kaufman Adaptive MA |  | Automatically adjusts sensitivity based on market volatility using Efficiency Ratio, balancing responsiveness and stability. |
| [MAMA](mama/Mama.md) | MESA Adaptive MA |  | Applies Hilbert Transform for phase-based adaptation, using dual-line system (MAMA/FAMA) for cycle-sensitive smoothing. |
| [MGDI](mgdi/Mgdi.md) | McGinley Dynamic Indicator |  | Adjusts speed based on market volatility using dynamic factor, aiming to hug prices closely. |
| [MMA](mma/Mma.md) | Modified MA |  | Combines simple and weighted components, emphasizing central values for balanced smoothing. |
| [QEMA](qema/Qema.md) | Quad Exponential MA |  | Zero-lag filter with four cascaded EMAs using geometrically ramped alphas and minimum-energy weights for DC lag elimination. |
| [REMA](rema/Rema.md) | Regularized Exponential MA |  | Applies regularization to EMA using lambda parameter, balancing smoothing and momentum-based prediction. |
| [RGMA](rgma/Rgma.md) | Recursive Gaussian MA |  | Approximates Gaussian smoothing by recursively applying EMA filters multiple times (passes), controlled by adjusted period. |
| [RMA](rma/Rma.md) | wildeR MA (SMMA, MMA) |  | Wilder's smoothing average using specific alpha (1/period), designed for indicators like RSI and ATR. |
| [T3](t3/T3.md) | Tillson T3 MA |  | Six-stage EMA cascade with optimized coefficients based on volume factor for reduced lag and superior noise reduction. |
| [TEMA](tema/Tema.md) | Triple Exponential MA |  | Triple-cascade EMA architecture with optimized coefficients (3, -3, 1) for further lag reduction compared to DEMA. |
| [VAMA](vama/Vama.md) | Volatility Adjusted MA |  | Dynamically adjusts moving average length based on ATR volatility ratio, shortening during high volatility and lengthening during low volatility. |
| [VIDYA](vidya/Vidya.md) | Variable Index Dynamic Average |  | Adjusts smoothing factor based on market volatility using Volatility Index (ratio of short-term to long-term standard deviation). |
| [YZVAMA](yzvama/Yzvama.md) | Yang-Zhang Volatility Adjusted MA |  | Adjusts MA length based on percentile rank of short-term YZV, providing context-aware volatility adaptation for gap-prone markets. |
| [ZLEMA](zlema/Zlema.md) | Zero-Lag Exponential MA |  | Reduces lag by estimating future price based on current momentum, using dynamically calculated lag period. |
## Selection Guide
**For trend-following systems:** EMA provides baseline stability. DEMA/TEMA reduce lag at cost of increased overshoot. T3 offers best lag-to-smoothness ratio for most applications.
**For adaptive response:** KAMA adjusts to efficiency ratio (trend vs noise). VIDYA responds to volatility changes. FRAMA uses fractal dimension for market state detection. JMA combines all adaptive mechanisms into unified filter.
**For zero-lag requirements:** ZLEMA applies momentum-based lag compensation. HTIT uses Hilbert Transform for instantaneous trend. QEMA achieves DC lag elimination through cascaded architecture.
**For Wilder-family indicators:** RMA (SMMA) provides standard smoothing for RSI, ATR, ADX calculations.
## IIR Characteristics Comparison
| Filter | Lag (bars) | Smoothness | Overshoot | Adaptivity | Complexity |
| :--- | :---: | :---: | :---: | :---: | :---: |
| EMA | Period/2 | Medium | Low | None | O(1) |
| DEMA | Period/3 | Medium | Medium | None | O(1) |
| TEMA | Period/4 | Low | High | None | O(1) |
| T3 | Period/5 | High | Low | None | O(1) |
| ZLEMA | ~0 | Low | High | None | O(1) |
| KAMA | Variable | Variable | Low | Efficiency | O(n) |
| VIDYA | Variable | Variable | Low | Volatility | O(n) |
| FRAMA | Variable | Variable | Medium | Fractal | O(n) |
| JMA | ~1-2 | High | Very Low | Multi-factor | O(1) |
## Adaptive Filter Categories
| Category | Filters | Adaptation Mechanism | Best Application |
| :--- | :--- | :--- | :--- |
| **Fixed Alpha** | EMA, RMA, MMA | Constant smoothing factor | Stable trending markets |
| **Cascade** | DEMA, TEMA, T3, QEMA | Multiple EMA stages | Lag reduction priority |
| **Efficiency-Based** | KAMA | Direction vs noise ratio | Choppy/trending detection |
| **Volatility-Based** | VIDYA, VAMA, DSMA, YZVAMA | Standard deviation or ATR | Regime-change adaptation |
| **Fractal-Based** | FRAMA | Hurst exponent proxy | Range/trend detection |
| **Phase-Based** | MAMA, HTIT | Hilbert Transform | Cycle-sensitive smoothing |
| **Multi-Stage Adaptive** | JMA, MGDI | Combined mechanisms | Universal application |
## IIR vs FIR Design Principles
| Aspect | IIR Filters | FIR Filters |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| **Memory** | O(1) state | O(period) buffer | | [DEMA](lib/trends_IIR/dema/Dema.md) | Double Exponential MA | Reduces lag by applying double exponential smoothing, enhancing responsiveness while maintaining signal quality. |
| **Computation** | 2-4 multiplications | period multiplications | | [DSMA](lib/trends_IIR/dsma/Dsma.md) | Deviation-Scaled MA | Adaptive IIR filter that adjusts smoothing factor based on market volatility, increasing responsiveness during high-deviation periods. |
| **Stability** | Requires careful design | Always stable | | [EMA](lib/trends_IIR/ema/Ema.md) | Exponential MA | Applies exponentially decreasing weights to price data, balancing responsiveness and stability. |
| **Phase Response** | Non-linear phase | Can be linear phase | | [FRAMA](lib/trends_IIR/frama/Frama.md) | Fractal Adaptive MA | Adapts smoothing based on fractal dimension analysis, minimizing lag in trends and maximizing smoothing in consolidation. |
| **Lag Achievable** | Lower lag possible | Minimum lag = (period-1)/2 | | [HEMA](lib/trends_IIR/hema/Hema.md) | Hull Exponential MA | EMA-domain Hull analog using half-life timing and de-lagged EMA cascade. |
| **Adaptivity** | Natural (modify alpha) | Requires coefficient recalc | | [HTIT](lib/trends_IIR/htit/Htit.md) | Hilbert Transform Instantaneous Trend | Utilizes Hilbert Transform to isolate instantaneous trend component, providing zero-lag trendline with hybrid FIR-in-IIR design. |
| **SIMD Potential** | Limited (recursive) | High (parallel windows) | | [JMA](lib/trends_IIR/jma/Jma.md) | Jurik MA | Adaptive filter achieving high noise reduction and low phase delay through multi-stage volatility normalization and dynamic parameter optimization. |
| [KAMA](lib/trends_IIR/kama/Kama.md) | Kaufman Adaptive MA | Automatically adjusts sensitivity based on market volatility using Efficiency Ratio, balancing responsiveness and stability. |
## Alpha-Period Relationship | [MAMA](lib/trends_IIR/mama/Mama.md) | MESA Adaptive MA | Applies Hilbert Transform for phase-based adaptation, using dual-line system (MAMA/FAMA) for cycle-sensitive smoothing. |
| [MGDI](lib/trends_IIR/mgdi/Mgdi.md) | McGinley Dynamic Indicator | Adjusts speed based on market volatility using dynamic factor, aiming to hug prices closely. |
IIR filters use smoothing factor ± instead of explicit period. Conversion formulas: | [MMA](lib/trends_IIR/mma/Mma.md) | Modified MA | Combines simple and weighted components, emphasizing central values for balanced smoothing. |
| [QEMA](lib/trends_IIR/qema/Qema.md) | Quad Exponential MA | Zero-lag filter with four cascaded EMAs using geometrically ramped alphas and minimum-energy weights for DC lag elimination. |
| Formula | Expression | Use Case | | [REMA](lib/trends_IIR/rema/Rema.md) | Regularized Exponential MA | Applies regularization to EMA using lambda parameter, balancing smoothing and momentum-based prediction. |
| :--- | :--- | :--- | | [RGMA](lib/trends_IIR/rgma/Rgma.md) | Recursive Gaussian MA | Approximates Gaussian smoothing by recursively applying EMA filters multiple times (passes), controlled by adjusted period. |
| Standard EMA | ± = 2/(period+1) | General purpose | | [RMA](lib/trends_IIR/rma/Rma.md) | wildeR MA | Wilder's smoothing average using specific alpha (1/period), designed for indicators like RSI and ATR. |
| Wilder (RMA) | ± = 1/period | RSI, ATR, ADX | | [T3](lib/trends_IIR/t3/T3.md) | Tillson T3 MA | Six-stage EMA cascade with optimized coefficients based on volume factor for reduced lag and superior noise reduction. |
| Percentage | ± = percentage/100 | Direct control | | [TEMA](lib/trends_IIR/tema/Tema.md) | Triple Exponential MA | Triple-cascade EMA architecture with optimized coefficients (3, -3, 1) for further lag reduction compared to DEMA. |
| [VAMA](lib/trends_IIR/vama/Vama.md) | Volatility Adjusted MA | Dynamically adjusts moving average length based on ATR volatility ratio, shortening during high volatility and lengthening during low volatility. |
Effective period approximation: `period H 2/± - 1` for standard EMA weighting. | [VIDYA](lib/trends_IIR/vidya/Vidya.md) | Variable Index Dynamic Average | Adjusts smoothing factor based on market volatility using Volatility Index (ratio of short-term to long-term standard deviation). |
| [YZVAMA](lib/trends_IIR/yzvama/Yzvama.md) | Yang-Zhang Volatility Adjusted MA | Adjusts MA length based on percentile rank of short-term YZV, providing context-aware volatility adaptation for gap-prone markets. |
| [ZLEMA](lib/trends_IIR/zlema/Zlema.md) | Zero-Lag Exponential MA | Reduces lag by estimating future price based on current momentum, using dynamically calculated lag period. |
| LTMA | Linear Trend MA | Projects the linear trend of price data using linear regression, focusing on the endpoint of the trendline. |
| ZLDEMA | Zero-Lag Double Exponential MA | Hybrid dual-stage predictive architecture combining two ZLEMAs with optimized 1.5/0.5 coefficients for reduced lag and noise suppression. |
| ZLTEMA | Zero-Lag Triple Exponential MA | Advanced triple-cascade predictive architecture combining three ZLEMAs with optimized 2/2/1 coefficients for maximum lag reduction. |
+3 -12
View File
@@ -303,17 +303,8 @@ public sealed class Kama : AbstractBase
// oldest: when full, oldest is at bufferIdx (the next write position) // oldest: when full, oldest is at bufferIdx (the next write position)
// Note: bufferIdx has already been advanced, so current value is at (bufferIdx - 1 + bufSize) % bufSize // Note: bufferIdx has already been advanced, so current value is at (bufferIdx - 1 + bufSize) % bufSize
double change; // When full, oldest is at bufferIdx (next write position); when not full, oldest is at index 0
if (count == bufSize) double change = Math.Abs(val - buffer[count == bufSize ? bufferIdx : 0]);
{
// When full, oldest is at bufferIdx (next write position)
change = Math.Abs(val - buffer[bufferIdx]);
}
else
{
// When not full, oldest is at index 0
change = Math.Abs(val - buffer[0]);
}
double er = (volatilitySum > 1e-10) ? change / volatilitySum : 0.0; double er = (volatilitySum > 1e-10) ? change / volatilitySum : 0.0;
if (er > 1.0) er = 1.0; if (er > 1.0) er = 1.0;
@@ -338,4 +329,4 @@ public sealed class Kama : AbstractBase
_p_state = _state; _p_state = _state;
Last = default; Last = default;
} }
} }
+29 -69
View File
@@ -1,75 +1,35 @@
# Volatility Indicators # Volatility
> "Volatility is the price of admission. The question is whether the ride is worth it." > "Volatility is the price of admission. The question is whether the ride is worth it."
Volatility measures the magnitude of price changes, independent of direction. Low volatility indicates consolidation and coiling energy; high volatility indicates explosive movement and trend development. These indicators answer "how much?" and "how fast?", not "which way?". Volatility measures the magnitude of price changes, independent of direction. Low volatility indicates consolidation and coiling energy; high volatility indicates explosive movement and trend development. These indicators answer "how much?" and "how fast?", not "which way?".
Core volatility concepts: | Indicator | Full Name | Description |
- **Range-Based**: High minus Low, with or without gap adjustment (TR, ATR)
- **Return-Based**: Standard deviation of log returns (HV, EWMA)
- **Estimator-Based**: Statistical models using OHLC combinations (Garman-Klass, Yang-Zhang)
- **Normalized**: Percentage or [0,1] scaled for cross-asset comparison (ATRP, ATRN)
## Implementation Status
| Indicator | Full Name | Status | Description |
| :--- | :--- | :---: | :--- |
| [ADR](adr/Adr.md) | Average Daily Range | ✅ | Simple High-Low range without gap adjustment |
| [ATR](atr/Atr.md) | Average True Range | ✅ | Standard volatility measure accounting for gaps via True Range |
| [ATRN](atrn/Atrn.md) | ATR Normalized | ✅ | ATR normalized to [0,1] based on historical min/max |
| [ATRP](atrp/Atrp.md) | ATR Percent | ✅ | ATR as percentage of close price |
| BBW | Bollinger Band Width | 📋 | Distance between upper and lower Bollinger Bands |
| BBWN | BB Width Normalized | 📋 | BBW normalized to [0,1] range |
| BBWP | BB Width Percentile | 📋 | BBW percentile rank over lookback |
| CCV | Close-to-Close Volatility | 📋 | Annualized volatility from log returns |
| CV | Conditional Volatility | 📋 | GARCH(1,1) model for time-varying volatility |
| CVI | Chaikin Volatility | 📋 | Rate of change in smoothed High-Low range |
| EWMA | EWMA Volatility | 📋 | Exponentially weighted squared returns |
| GKV | Garman-Klass Volatility | 📋 | Efficient OHLC-based estimator |
| HLV | High-Low Volatility | 📋 | Range-based volatility without close |
| HV | Historical Volatility | 📋 | Standard deviation of returns |
| JVOLTY | Jurik Volatility | 📋 | Low-lag, smooth Jurik volatility |
| JVOLTYN | Jurik Volatility Normalized | 📋 | JVOLTY normalized to [0,1] |
| MASSI | Mass Index | 📋 | Range expansion/contraction for reversal detection |
| NATR | Normalized ATR | 📋 | ATR as percentage (equivalent to ATRP) |
| PV | Parkinson Volatility | 📋 | High-Low estimator assuming no drift |
| RSV | Rogers-Satchell Volatility | 📋 | OHLC estimator with drift adjustment |
| RV | Realized Volatility | 📋 | High-frequency intraday volatility |
| RVI | Relative Volatility Index | 📋 | Directional volatility measure |
| TR | True Range | 📋 | Single-bar volatility with gap capture |
| UI | Ulcer Index | 📋 | Downside risk and drawdown depth/duration |
| VOV | Volatility of Volatility | 📋 | Second derivative: how fast volatility changes |
| VR | Volatility Ratio | 📋 | Current TR relative to average TR |
| YZV | Yang-Zhang Volatility | 📋 | OHLC plus overnight gap estimator |
**Legend**: ✅ Implemented | 📋 Planned
## Indicator Selection Guide
| Use Case | Recommended | Rationale |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Position Sizing | ATR, ATRP | Standard for risk-based sizing | | [ADR](lib/volatility/adr/Adr.md) | Average Daily Range | Simple High-Low range without gap adjustment. |
| Stop Loss Distance | ATR | Absolute measure in price units | | [ATR](lib/volatility/atr/Atr.md) | Average True Range | Standard volatility measure accounting for gaps via True Range. |
| Cross-Asset Comparison | ATRP, ATRN | Normalized for different price scales | | [ATRN](lib/volatility/atrn/Atrn.md) | ATR Normalized | ATR normalized to [0,1] based on historical min/max. |
| Regime Detection | ATRN | [0,1] scale with clear thresholds | | [ATRP](lib/volatility/atrp/Atrp.md) | ATR Percent | ATR as percentage of close price. |
| Intraday Analysis | ADR | Gaps irrelevant for same-session | | BBW | Bollinger Band Width | Distance between upper and lower Bollinger Bands. |
| Gap-Sensitive Analysis | ATR | True Range captures overnight gaps | | BBWN | BB Width Normalized | BBW normalized to [0,1] range. |
| BBWP | BB Width Percentile | BBW percentile rank over lookback. |
## Volatility Regime Interpretation | CCV | Close-to-Close Volatility | Annualized volatility from log returns. |
| CV | Conditional Volatility | GARCH(1,1) model for time-varying volatility. |
| ATRN Range | ATRP Typical | Regime | Implications | | CVI | Chaikin Volatility | Rate of change in smoothed High-Low range. |
| :---: | :---: | :--- | :--- | | EWMA | EWMA Volatility | Exponentially weighted squared returns. |
| 0.8 - 1.0 | > 5% | Crisis/Extreme | Widen stops, reduce size, expect whipsaws | | GKV | Garman-Klass Volatility | Efficient OHLC-based estimator. |
| 0.5 - 0.8 | 2-5% | Elevated | Trending conditions, standard trend-following | | HLV | High-Low Volatility | Range-based volatility without close. |
| 0.2 - 0.5 | 1-2% | Normal | Balanced conditions, mixed strategies | | HV | Historical Volatility | Standard deviation of returns. |
| 0.0 - 0.2 | < 1% | Compressed | Consolidation, mean-reversion, breakout setups | | JVOLTY | Jurik Volatility | Low-lag, smooth Jurik volatility. |
| JVOLTYN | Jurik Volatility Normalized | JVOLTY normalized to [0,1]. |
## ATR Family Comparison | MASSI | Mass Index | Range expansion/contraction for reversal detection. |
| NATR | Normalized ATR | ATR as percentage (equivalent to ATRP). |
| Indicator | Output | Use Case | | PV | Parkinson Volatility | High-Low estimator assuming no drift. |
| :--- | :--- | :--- | | RSV | Rogers-Satchell Volatility | OHLC estimator with drift adjustment. |
| ATR | Absolute price units | Stop distance, position sizing in same asset | | RV | Realized Volatility | High-frequency intraday volatility. |
| ATRP | Percentage (0-100%) | Cross-asset comparison, percentage-based sizing | | RVI | Relative Volatility Index | Directional volatility measure. |
| ATRN | Normalized [0,1] | Regime detection, volatility ranking | | TR | True Range | Single-bar volatility with gap capture. |
| ADR | Absolute price units | Intraday analysis, gap-insensitive | | UI | Ulcer Index | Downside risk and drawdown depth/duration. |
| VOV | Volatility of Volatility | Second derivative: how fast volatility changes. |
| VR | Volatility Ratio | Current TR relative to average TR. |
| YZV | Yang-Zhang Volatility | OHLC plus overnight gap estimator. |
+4 -9
View File
@@ -179,14 +179,9 @@ public sealed class Atrn : AbstractBase
double normalized = minAtr < maxAtr ? (currentAtr - minAtr) / (maxAtr - minAtr) : 0.5; double normalized = minAtr < maxAtr ? (currentAtr - minAtr) / (maxAtr - minAtr) : 0.5;
// Update state // Update state
if (isNew) _state = isNew
{ ? new State(input, true, tr, currentAtr)
_state = new State(input, true, tr, currentAtr); : _state with { LastValidTr = tr, LastValidAtr = currentAtr };
}
else
{
_state = _state with { LastValidTr = tr, LastValidAtr = currentAtr };
}
TValue result = new(input.Time, normalized); TValue result = new(input.Time, normalized);
Last = result; Last = result;
@@ -315,4 +310,4 @@ public sealed class Atrn : AbstractBase
} }
return min; return min;
} }
} }
+28 -54
View File
@@ -2,59 +2,33 @@
> "It takes volume to make prices move." — Charles Dow > "It takes volume to make prices move." — Charles Dow
Volume is market fuel. Price tells what happened; volume tells how hard the market worked to make it happen. Volume is market fuel. Price tells what happened; volume tells how hard the market worked to make it happen. In a world of algorithmic trading and dark pools, volume analysis reveals where money actually flows.
In a world of algorithmic trading and dark pools, volume analysis reveals where money actually flows. These indicators track conviction, not just shares traded. | Indicator | Full Name | Description |
## Indicator Status
| Indicator | Full Name | Status | Description |
| :--- | :--- | :---: | :--- |
| [ADL](lib/volume/adl/Adl.md) | Accumulation/Distribution Line | ✅ | Correlates price location within range to volume. Grandfather of volume flow analysis. |
| [ADOSC](lib/volume/adosc/Adosc.md) | Chaikin A/D Oscillator | ✅ | Momentum indicator for AD Line. Predicts reversals by measuring acceleration of money flow. |
| AOBV | Archer On-Balance Volume | 📋 | Modified OBV incorporating intra-period price movement. |
| CMF | Chaikin Money Flow | 📋 | Measures money flow volume over set period (typically 20-21 days). |
| EFI | Elder's Force Index | 📋 | Combines price movement, direction, volume to measure buying/selling power. |
| EOME | Ease of Movement | 📋 | Relates price change to volume. Highlights periods of effortless price movement. |
| III | Intraday Intensity Index | 📋 | Measures buying/selling pressure within day's range using close position. |
| KVO | Klinger Volume Oscillator | 📋 | Compares short-term and long-term volume trends to identify potential reversals. |
| MFI | Money Flow Index | 📋 | Volume-weighted RSI. Measures buying/selling pressure using price and volume. |
| NVI | Negative Volume Index | 📋 | Tracks price changes on lower volume days. Assumes smart money acts on quiet days. |
| OBV | On Balance Volume | 📋 | Fundamental volume indicator. Cumulative volume based on price direction. |
| PVD | Price Volume Divergence | 📋 | Systematic divergence detection between price and volume movements. |
| PVI | Positive Volume Index | 📋 | Tracks price changes on higher volume days. Assumes crowd behavior. |
| PVO | Percentage Volume Oscillator | 📋 | Compares short-term and long-term volume moving averages as percentages. |
| PVR | Price Volume Rank | 📋 | Ranks price performance relative to volume activity. |
| PVT | Price Volume Trend | 📋 | Cumulative volume adjusted by relative price changes. Similar to OBV. |
| TVI | Trade Volume Index | 📋 | Measures intra-day buying/selling pressure based on tick data. |
| TWAP | Time Weighted Average Price | 📋 | Average price weighted equally by time. Used as execution benchmark. |
| VA | Volume Accumulation | 📋 | Cumulative volume adjusted by close position relative to range midpoint. |
| VF | Volume Force | 📋 | Measures force of volume behind price movements. |
| VO | Volume Oscillator | 📋 | Difference between short and long volume moving averages. Shows volume momentum. |
| VROC | Volume Rate of Change | 📋 | Measures speed at which volume is changing over time. |
| VWAD | Volume Weighted A/D | 📋 | Similar to ADL but weights accumulation/distribution by volume. |
| VWAP | Volume Weighted Average Price | 📋 | Average price weighted by volume. Common execution benchmark. |
| VWMA | Volume Weighted MA | 📋 | Moving average where each price point is weighted by its volume. |
| WAD | Williams A/D | 📋 | Measures cumulative buying/selling pressure by comparing closes to opens/highs/lows. |
**Status Key:** ✅ Implemented | 📋 Planned
## Selection Guide
| Use Case | Recommended | Why |
| :--- | :--- | :--- | | :--- | :--- | :--- |
| Smart money detection | ADL | Tracks close position within range. Reveals accumulation vs distribution. | | [ADL](lib/volume/adl/Adl.md) | Accumulation/Distribution Line | Correlates price location within range to volume. Grandfather of volume flow analysis. |
| Trend confirmation | ADL, ADOSC | Volume should confirm price moves. Divergences warn of weakness. | | [ADOSC](lib/volume/adosc/Adosc.md) | Chaikin A/D Oscillator | Momentum indicator for AD Line. Predicts reversals by measuring acceleration of money flow. |
| Momentum of money flow | ADOSC | EMA difference on ADL shows acceleration of buying/selling pressure. | | AOBV](lib/volume/aobv/Aobv.md) | Archer On-Balance Volume | Modified OBV incorporating intra-period price movement. |
| Reversal anticipation | ADOSC | Fast/slow EMA crossovers on volume flow precede price reversals. | | CMF | Chaikin Money Flow | Measures money flow volume over set period (typically 20-21 days). |
| EFI | Elder's Force Index | Combines price movement, direction, volume to measure buying/selling power. |
## Volume Analysis Principles | EOM | Ease of Movement | Relates price change to volume. Highlights periods of effortless price movement. |
| III | Intraday Intensity Index | Measures buying/selling pressure within day's range using close position. |
Volume reveals conviction. Four key patterns: | KVO | Klinger Volume Oscillator | Compares short-term and long-term volume trends to identify potential reversals. |
| MFI | Money Flow Index | Volume-weighted RSI. Measures buying/selling pressure using price and volume. |
1. **Rising price + rising volume**: Strong trend. Smart money participating. | NVI | Negative Volume Index | Tracks price changes on lower volume days. Assumes smart money acts on quiet days. |
2. **Rising price + falling volume**: Weakening trend. Distribution possible. | OBV | On Balance Volume | Fundamental volume indicator. Cumulative volume based on price direction. |
3. **Falling price + rising volume**: Strong selling. Capitulation or accumulation. | PVD | Price Volume Divergence | Systematic divergence detection between price and volume movements. |
4. **Falling price + falling volume**: Weak selling. May find support. | PVI | Positive Volume Index | Tracks price changes on higher volume days. Assumes crowd behavior. |
| PVO | Percentage Volume Oscillator | Compares short-term and long-term volume moving averages as percentages. |
The ADL family quantifies these relationships through close position within range, normalized by volume. | PVR | Price Volume Rank | Ranks price performance relative to volume activity. |
| PVT | Price Volume Trend | Cumulative volume adjusted by relative price changes. Similar to OBV. |
| TVI | Trade Volume Index | Measures intra-day buying/selling pressure based on tick data. |
| TWAP | Time Weighted Average Price | Average price weighted equally by time. Used as execution benchmark. |
| VA | Volume Accumulation | Cumulative volume adjusted by close position relative to range midpoint. |
| VF | Volume Force | Measures force of volume behind price movements. |
| VO | Volume Oscillator | Difference between short and long volume moving averages. Shows volume momentum. |
| VROC | Volume Rate of Change | Measures speed at which volume is changing over time. |
| VWAD | Volume Weighted A/D | Similar to ADL but weights accumulation/distribution by volume. |
| VWAP | Volume Weighted Average Price | Average price weighted by volume. Common execution benchmark. |
| VWMA | Volume Weighted MA | Moving average where each price point is weighted by its volume. |
| WAD | Williams A/D | Measures cumulative buying/selling pressure by comparing closes to opens/highs/lows. |