mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-17 01:58:06 +00:00
doc headers
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
# ALMA: Arnaud Legoux Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period`, `offset` (default 0.85), `sigma` (default 6.0) |
|
||||
| **Outputs** | Single series (Alma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- ALMA is a Finite Impulse Response (FIR) filter that applies a Gaussian window to price data.
|
||||
- Parameterized by `period`, `offset` (default 0.85), `sigma` (default 6.0).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Gaussian distributions govern everything from particle diffusion to the distribution of shoe sizes. Applying them to price action isn't 'technical analysis'; it's just physics with a profit motive."
|
||||
|
||||
ALMA is a Finite Impulse Response (FIR) filter that applies a Gaussian window to price data. Unlike the Simple Moving Average (which treats 10-minute-old data with the same reverence as 1-minute-old data) or the Exponential Moving Average (which holds onto history like a hoarder), ALMA allows you to shape the weight distribution precisely. It lets you define the trade-off between smoothness and lag using standard deviation ($\sigma$) and offset, rather than arbitrary periods.
|
||||
@@ -279,4 +296,4 @@ For ALMA(50), total memory is approximately 900 bytes per instance.
|
||||
* $\sigma = 1$: The curve is flat. You have reinvented the Simple Moving Average (badly).
|
||||
* $\sigma = 10$: The curve is a needle. You are sampling one specific bar in history.
|
||||
|
||||
3. **Cold Start**: ALMA requires a full window ($L$) to be mathematically valid. First $L-1$ bars are convergence noise. Ignore them.
|
||||
3. **Cold Start**: ALMA requires a full window ($L$) to be mathematically valid. First $L-1$ bars are convergence noise. Ignore them.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# BLMA: Blackman Window Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Blma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- The Blackman Window Moving Average (BLMA) applies a triple-cosine window function from digital signal processing to financial time series.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "If you want to filter noise, don't just average it - window it."
|
||||
|
||||
The Blackman Window Moving Average (BLMA) applies a triple-cosine window function from digital signal processing to financial time series. Originally developed by **Ralph Beebe Blackman** at Bell Labs in the 1950s for spectral analysis, this filter provides superior noise suppression compared to standard moving averages by minimizing spectral leakage.
|
||||
@@ -241,4 +258,4 @@ private static double ComputeWeightedAverage(double weightSum, double weightedSu
|
||||
### Common Pitfalls
|
||||
|
||||
* **Lag**: BLMA has more lag than EMA or WMA because it suppresses the most recent data. It is a smoothing filter, not a leading indicator.
|
||||
* **Warmup**: During the first $N$ bars, the window expands dynamically. The full noise-suppression characteristics are only achieved after $N$ bars.
|
||||
* **Warmup**: During the first $N$ bars, the window expands dynamically. The full noise-suppression characteristics are only achieved after $N$ bars.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# BWMA: Bessel-Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period`, `order` (default 0) |
|
||||
| **Outputs** | Single series (Bwma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- BWMA is a Finite Impulse Response (FIR) filter that applies a Bessel-derived window function to weight price data.
|
||||
- Parameterized by `period`, `order` (default 0).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The Bessel function appears in problems involving cylindrical symmetry—heat flow in pipes, vibration of drumheads, and apparently, the smoothing of financial time series. Mathematics doesn't care about your asset class."
|
||||
|
||||
BWMA is a Finite Impulse Response (FIR) filter that applies a Bessel-derived window function to weight price data. The weighting follows a parabolic (or higher-order polynomial) profile that emphasizes the center of the lookback window while smoothly tapering to zero at the edges. Unlike rectangular (SMA) or exponential (EMA) weighting, BWMA provides a mathematically smooth transition that reduces spectral leakage and Gibbs phenomenon artifacts.
|
||||
@@ -344,4 +361,4 @@ else
|
||||
|
||||
* [ALMA](../alma/Alma.md) - Gaussian window with adjustable offset
|
||||
* [WMA](../wma/Wma.md) - Linear weighting (triangular window)
|
||||
* [SINEMA](../sinema/Sinema.md) - Sine-weighted moving average
|
||||
* [SINEMA](../sinema/Sinema.md) - Sine-weighted moving average
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# CONV: Convolution Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | double[] kernel |
|
||||
| **Outputs** | Single series (Conv) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- CONV (Convolution Moving Average) is the ultimate tool for the signal processing purist.
|
||||
- Parameterized by double[] kernel.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "If you want a moving average that behaves exactly how you want it to, build it yourself. CONV is the 'Bring Your Own Kernel' of indicators."
|
||||
|
||||
CONV (Convolution Moving Average) is the ultimate tool for the signal processing purist. It doesn't presume to know what kind of smoothing you need; it simply asks for a kernel (a set of weights) and applies it to the data. Want a Gaussian filter? A Sinc filter? A custom edge-detection filter? CONV runs them all.
|
||||
@@ -151,4 +168,4 @@ For a typical 14-period kernel: ~68 + 224 ≈ **292 bytes** per instance.
|
||||
|
||||
1. **Kernel Direction**: Our implementation applies the kernel such that the last element of the kernel multiplies the most recent data point. If you import kernels from other DSP libraries, you might need to reverse them.
|
||||
2. **Normalization**: Kernel weights are *not* automatically normalized. If the sum of the weights is not 1.0, the output scale will be different from the input scale. This is a feature, not a bug (allows for differential filters).
|
||||
3. **Performance**: A kernel size of 1000 will be 100x slower than a kernel size of 10. Use FFT-based convolution for massive kernels (not implemented here; this is for trading, not searching for extraterrestrial life).
|
||||
3. **Performance**: A kernel size of 1000 will be 100x slower than a kernel size of 10. Use FFT-based convolution for massive kernels (not implemented here; this is for trading, not searching for extraterrestrial life).
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# CRMA: Cubic Regression Moving Average
|
||||
# CRMA: Cubic Regression Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Crma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- CRMA fits a degree-3 polynomial $y = a_0 + a_1 x + a_2 x^2 + a_3 x^3$ to the most recent $N$ bars via ordinary least squares, then returns the fitt...
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Linear regression tells you where the trend is going. Quadratic regression tells you it's curving. Cubic regression tells you the curve is changing its mind."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# DWMA: Double Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Dwma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `(period * 2) - 1` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- DWMA (Double Weighted Moving Average) is exactly what it says on the tin: a Weighted Moving Average of a Weighted Moving Average.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `(period * 2) - 1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "If one WMA is good, two must be better. DWMA is for when you want your signal so smooth it looks like it's been sanded, polished, and waxed."
|
||||
|
||||
DWMA (Double Weighted Moving Average) is exactly what it says on the tin: a Weighted Moving Average of a Weighted Moving Average. Unlike DEMA, which tries to *remove* lag, DWMA accepts lag as the price of admission for superior noise reduction. It produces a curve that is incredibly smooth, ideal for identifying long-term trends without getting faked out by market chop.
|
||||
@@ -209,4 +226,4 @@ protected override void Dispose(bool disposing)
|
||||
|
||||
1. **Lag**: This indicator lags. A lot. Do not use it for entry signals on tight timeframes. Use it for trend filtering (e.g., "only buy if price > DWMA").
|
||||
2. **Warmup**: It takes roughly $2 \times N$ bars to produce valid data.
|
||||
3. **Confusion with DEMA**: DEMA = Fast, DWMA = Smooth. Do not mix them up.
|
||||
3. **Confusion with DEMA**: DEMA = Fast, DWMA = Smooth. Do not mix them up.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# FWMA: Fibonacci Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 10) |
|
||||
| **Outputs** | Single series (Fwma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- The Fibonacci Weighted Moving Average applies the Fibonacci sequence as FIR filter weights, assigning exponentially growing importance to recent bars.
|
||||
- Parameterized by `period` (default 10).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Nature uses Fibonacci for sunflower seeds and nautilus shells. Using it for price weighting is either profound biological insight or the most expensive numerology in finance. The math doesn't care which."
|
||||
|
||||
The Fibonacci Weighted Moving Average applies the Fibonacci sequence as FIR filter weights, assigning exponentially growing importance to recent bars. Where WMA uses linear weights (1, 2, 3, ..., N) and PWMA uses parabolic weights ($1^2, 2^2, ..., N^2$), FWMA uses F(1), F(2), ..., F(N). The Fibonacci growth rate ($\phi \approx 1.618$) produces a weighting profile between exponential and parabolic, giving FWMA a distinctive "golden ratio decay" that concentrates roughly 61.8% of total weight in the most recent third of the window.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# GWMA: Gaussian-Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period`, `sigma` (default 0.4) |
|
||||
| **Outputs** | Single series (Gwma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- GWMA is a Finite Impulse Response (FIR) filter that applies a centered Gaussian window to price data.
|
||||
- Parameterized by `period`, `sigma` (default 0.4).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The Gaussian distribution shows up everywhere from thermal noise to the central limit theorem. Using it to weight price data isn't magic; it's just applied statistics with a trading account."
|
||||
|
||||
GWMA is a Finite Impulse Response (FIR) filter that applies a centered Gaussian window to price data. Unlike ALMA (which allows shifting the Gaussian peak via an offset parameter), GWMA centers the bell curve at the middle of the lookback window. The sigma parameter controls the width of the Gaussian, determining how sharply the weights decay from the center.
|
||||
@@ -357,4 +374,4 @@ public override TSeries Update(TSeries source)
|
||||
|
||||
3. **Cold Start**: GWMA requires a full window ($L$) to be mathematically valid. First $L-1$ bars are convergence noise.
|
||||
|
||||
4. **Centered vs Offset**: Don't confuse GWMA with ALMA. GWMA always centers the Gaussian; ALMA lets you shift it. If you find yourself wanting offset control, use ALMA instead.
|
||||
4. **Centered vs Offset**: Don't confuse GWMA with ALMA. GWMA always centers the Gaussian; ALMA lets you shift it. If you find yourself wanting offset control, use ALMA instead.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# HAMMA: Hamming-Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 10) |
|
||||
| **Outputs** | Single series (Hamma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- HAMMA is a Finite Impulse Response (FIR) filter that applies a Hamming window to price data.
|
||||
- Parameterized by `period` (default 10).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Julius von Hann picked his window function to suppress spectral leakage; we're just using it to smooth price data. Same math, different trading floor."
|
||||
|
||||
HAMMA is a Finite Impulse Response (FIR) filter that applies a Hamming window to price data. The Hamming window is a raised cosine with specific coefficients (0.54 and 0.46) chosen to minimize the amplitude of the first side lobe in the frequency domain. This makes it particularly effective at separating the signal (trend) from nearby noise frequencies.
|
||||
@@ -247,4 +264,4 @@ For a typical 14-period: ~92 + 224 ≈ **316 bytes** per instance.
|
||||
|
||||
4. **Small Periods**: With very small periods (e.g., 3), the window shape degenerates. The edge-center-edge pattern becomes less meaningful. Consider period >= 5 for meaningful Hamming characteristics.
|
||||
|
||||
5. **Side Lobe Trade-off**: The -43 dB first side lobe comes at the cost of slightly wider main lobe than Hanning. If frequency resolution matters more than side lobe suppression, consider other windows.
|
||||
5. **Side Lobe Trade-off**: The -43 dB first side lobe comes at the cost of slightly wider main lobe than Hanning. If frequency resolution matters more than side lobe suppression, consider other windows.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# HANMA: Hanning-Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 10) |
|
||||
| **Outputs** | Single series (Hanma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- HANMA is a Finite Impulse Response (FIR) filter that applies a Hanning (Hann) window to price data.
|
||||
- Parameterized by `period` (default 10).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Julius von Hann deserves credit for the window that bears his name—even if autocomplete keeps trying to change it to 'Hamming.' The zero-edge weights aren't a bug; they're the whole point."
|
||||
|
||||
HANMA is a Finite Impulse Response (FIR) filter that applies a Hanning (Hann) window to price data. The Hanning window is a pure raised cosine with edge weights of exactly zero, which provides excellent side lobe suppression while maintaining a narrower main lobe than Hamming. It's particularly effective when you want to eliminate boundary discontinuities entirely.
|
||||
@@ -252,4 +269,4 @@ For a typical 14-period: ~92 + 224 ≈ **316 bytes** per instance.
|
||||
|
||||
5. **Small Periods**: With very small periods (e.g., 3), the window shape degenerates. A period of 3 produces weights [0, 1, 0]—essentially just the middle value. Consider period >= 5 for meaningful Hanning characteristics.
|
||||
|
||||
6. **Side Lobe Trade-off**: The -32 dB first side lobe is worse than Hamming's -43 dB, but the narrower main lobe provides better frequency resolution. Choose based on whether you prioritize frequency resolution or side lobe suppression.
|
||||
6. **Side Lobe Trade-off**: The -32 dB first side lobe is worse than Hamming's -43 dB, but the narrower main lobe provides better frequency resolution. Choose based on whether you prioritize frequency resolution or side lobe suppression.
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# HEND: Henderson Moving Average
|
||||
# HEND: Henderson Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 7) |
|
||||
| **Outputs** | Single series (Hend) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- HEND is a symmetric FIR filter derived from the Henderson (1916) closed-form weight formula, designed to pass cubic polynomial trends without disto...
|
||||
- Parameterized by `period` (default 7).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Robert Henderson designed a filter so good that the Australian Bureau of Statistics still uses it a century later. When your smoothing algorithm outlasts empires, you did something right."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# HMA: Hull Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Hma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period + sqrtPeriod - 1` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- HMA (Hull Moving Average) is a solution to the eternal struggle between smoothness and lag.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period + sqrtPeriod - 1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Alan Hull looked at the lag in moving averages and said, 'I can fix that.' And he did, by making the math do gymnastics."
|
||||
|
||||
HMA (Hull Moving Average) is a solution to the eternal struggle between smoothness and lag. Most indicators force you to choose one; HMA gives you both. It achieves this by using weighted moving averages (WMAs) in a clever configuration that cancels out lag while maintaining the smoothing properties of the WMA.
|
||||
@@ -220,4 +237,4 @@ For HMA(100), total memory is approximately 1.7 KB per instance (three WMA insta
|
||||
|
||||
1. **Overshoot**: Like DEMA, HMA can overshoot price turns because of the lag correction.
|
||||
2. **Period Sensitivity**: The $\sqrt{N}$ smoothing is hardcoded into the definition. You can't easily tweak the smoothing independently of the lag correction without breaking the "Hull" definition.
|
||||
3. **Integer Math**: The periods $N/2$ and $\sqrt{N}$ are rounded to integers. This can cause slight discrepancies between implementations depending on rounding rules. Standard integer truncation is used in QuanTAlib.
|
||||
3. **Integer Math**: The periods $N/2$ and $\sqrt{N}$ are rounded to integers. This can cause slight discrepancies between implementations depending on rounding rules. Standard integer truncation is used in QuanTAlib.
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# ILRS: Integral of Linear Regression Slope
|
||||
# ILRS: Integral of Linear Regression Slope
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 14) |
|
||||
| **Outputs** | Single series (Ilrs) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- ILRS computes the linear regression slope over a rolling window, then accumulates it via discrete integration (running sum) to reconstruct a smooth...
|
||||
- Parameterized by `period` (default 14).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "John Ehlers took the slope of a regression line, integrated it, and got a smoother trend follower. Differentiate to find direction, integrate to find position. Calculus: still useful after 300 years."
|
||||
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# KAISER: Kaiser Window Moving Average
|
||||
# KAISER: Kaiser Window Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 14), `beta` (default 3.0) |
|
||||
| **Outputs** | Single series (Kaiser) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- KAISER applies the Kaiser-Bessel window function as FIR filter weights, providing a single parameter ($\beta$) that continuously controls the trade...
|
||||
- Parameterized by `period` (default 14), `beta` (default 3.0).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "James Kaiser gave signal processing a knob. Turn beta up, sidelobes go down, transition band widens. Turn it down, you get an SMA. One parameter to rule them all."
|
||||
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# LANCZOS: Lanczos (Sinc) Window Moving Average
|
||||
# LANCZOS: Lanczos (Sinc) Window Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 14) |
|
||||
| **Outputs** | Single series (Lanczos) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- LANCZOS applies the normalized sinc function $\text{sinc}(x) = \sin(\pi x)/(\pi x)$ as a symmetric FIR window, producing a moving average with near...
|
||||
- Parameterized by `period` (default 14).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Cornelius Lanczos used the sinc function to reconstruct band-limited signals from discrete samples. Apply it to price data and you get a moving average that respects the Nyquist limit while your competitors are still using SMAs."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# LSMA: Least Squares Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period`, `offset` (default 0) |
|
||||
| **Outputs** | Single series (Lsma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- LSMA (Least Squares Moving Average), also known as the Moving Linear Regression or Endpoint Moving Average, calculates the least squares regression...
|
||||
- Parameterized by `period`, `offset` (default 0).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "If you want to know where the price is going, draw a line through where it's been. LSMA does this for every single bar, tirelessly fitting linear regressions while you sleep."
|
||||
|
||||
LSMA (Least Squares Moving Average), also known as the Moving Linear Regression or Endpoint Moving Average, calculates the least squares regression line for the preceding time periods. In plain English: it finds the "best fit" line for the data window and tells you where that line ends.
|
||||
@@ -227,4 +244,4 @@ private double GetValidValue(double input)
|
||||
|
||||
1. **Overshoot**: Because it projects a trend, LSMA will overshoot significantly when the trend reverses. It assumes the trend continues.
|
||||
2. **Offset**: You can use a positive offset to extrapolate into the future (forecasting), or a negative offset to center the average.
|
||||
3. **Noise**: It is very sensitive to outliers because it tries to fit a line to them.
|
||||
3. **Noise**: It is very sensitive to outliers because it tries to fit a line to them.
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# NLMA: Non-Lag Moving Average
|
||||
# NLMA: Non-Lag Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 14) |
|
||||
| **Outputs** | Single series (Nlma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | 1 bar |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- NLMA uses a two-phase damped cosine kernel with $5P - 1$ taps (where $P$ is the user period).
|
||||
- Parameterized by `period` (default 14).
|
||||
- Output range: Tracks input.
|
||||
- Requires 1 bar of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Igorad at TrendLaboratory built a two-phase FIR kernel that uses five times more taps than the period parameter suggests. The extra taps carry negative weights that actively cancel group delay. Most 'non-lag' indicators are marketing. This one is signal processing."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# NYQMA: Nyquist Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 89), `nyquistPeriod` (default 21) |
|
||||
| **Outputs** | Single series (Nyqma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | 1 bar |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- NYQMA combines a primary LWMA (Linear Weighted Moving Average) with a secondary LWMA applied to the first, using lag-compensating extrapolation: $\...
|
||||
- Parameterized by `period` (default 89), `nyquistperiod` (default 21).
|
||||
- Output range: Tracks input.
|
||||
- Requires 1 bar of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Manfred Dürschner applied the Nyquist-Shannon sampling theorem to cascaded moving averages: the second smoothing period must not exceed half the first, or you get aliasing artifacts. Respect the theorem and the ghost signals disappear."
|
||||
|
||||
NYQMA combines a primary LWMA (Linear Weighted Moving Average) with a secondary LWMA applied to the first, using lag-compensating extrapolation: $\text{NYQMA} = (1+\alpha) \cdot \text{MA}_1 - \alpha \cdot \text{MA}_2$, where $\alpha = N_2 / (N_1 - N_2)$. The Nyquist constraint $N_2 \leq \lfloor N_1/2 \rfloor$ ensures the second smoothing does not introduce aliasing artifacts into the output. This produces a lag-reduced moving average grounded in sampling theory rather than ad-hoc coefficient tuning. Streaming update is O(1) per bar via composed Wma instances; batch mode uses stackalloc/ArrayPool with FMA in the extrapolation loop.
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# PARZEN: Parzen (de la Vallée-Poussin) Window Moving Average
|
||||
# PARZEN: Parzen (de la Vallée-Poussin) Window Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 14) |
|
||||
| **Outputs** | Single series (Parzen) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- PARZEN applies the Parzen (de la Vallée-Poussin) window function as FIR filter weights, producing a moving average with exceptional sidelobe suppre...
|
||||
- Parameterized by `period` (default 14).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Emanuel Parzen convolved two triangular windows and got a piecewise cubic with zero sidelobe discontinuity. When your window function is its own proof of smoothness, the spectral leakage has nowhere to hide."
|
||||
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# PMA: Predictive Moving Average
|
||||
# PMA: Predictive Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Pma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `(period * 2) - 1` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- PMA (Predictive Moving Average) is a lag-cancellation filter that uses linear extrapolation of dual WMA (Weighted Moving Average) cascades to predi...
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `(period * 2) - 1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "John Ehlers looked at WMA's lag and said: 'What if we just extrapolated it away?' The result is a moving average that actually tries to predict where price is going, not where it has been."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# PWMA: Parabolic Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Pwma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- PWMA (Parabolic Weighted Moving Average) applies a parabolic ($i^2$) weighting scheme to the data window.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Linear weighting is for people who think the world is flat. PWMA squares the weights, because recent data isn't just more important—it's exponentially more important."
|
||||
|
||||
PWMA (Parabolic Weighted Moving Average) applies a parabolic ($i^2$) weighting scheme to the data window. This assigns massive importance to the most recent data points while still technically including the older data. It's like a WMA on steroids.
|
||||
@@ -171,4 +188,4 @@ if (_state.TickCount >= 1000)
|
||||
### Common Pitfalls
|
||||
|
||||
1. **Resync**: Because triple running sums are used, floating-point errors can accumulate faster than in a simple SMA. The implementation automatically resyncs every 1000 ticks to maintain precision.
|
||||
2. **Sensitivity**: This indicator is very sensitive to the most recent bar. It can "repaint" visually if used on an open bar (though the math is consistent).
|
||||
2. **Sensitivity**: This indicator is very sensitive to the most recent bar. It can "repaint" visually if used on an open bar (though the math is consistent).
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# QRMA: Quadratic Regression Moving Average
|
||||
# QRMA: Quadratic Regression Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Qrma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- QRMA fits a second-degree polynomial $y = a + bx + cx^2$ to the most recent $N$ bars via ordinary least squares, then returns the fitted value at t...
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Linear regression assumes the world is a straight line. Quadratic regression admits it might curve. For parabolic price moves, that admission turns out to be worth 40% less endpoint error."
|
||||
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# RAIN: Rainbow Moving Average
|
||||
# RAIN: Rainbow Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Rain) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | 1 bar |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- RAIN recursively applies SMA 10 times, producing 10 layers of progressively smoother price representation, then computes a weighted average across ...
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires 1 bar of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Mel Widner applied SMA ten times recursively, then weighted the layers like a rainbow: brightest at the top, fading toward the base. Ten colors of smoothing, one composite average that sees both fast and slow structure simultaneously."
|
||||
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# RWMA: Range Weighted Moving Average
|
||||
# RWMA: Range Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | OHLCV bar (TBar) |
|
||||
| **Parameters** | `period` (default 14) |
|
||||
| **Outputs** | Single series (Rwma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `> period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- RWMA weights each bar's contribution to the average by its price range (high minus low), giving greater influence to volatile bars and less to narr...
|
||||
- Parameterized by `period` (default 14).
|
||||
- Output range: Tracks input.
|
||||
- Requires `> period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Most averages weight by position: recent bars matter more. RWMA weights by volatility: volatile bars matter more. The market spoke loudest when the range was widest, so listen to those bars."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# SGMA: Savitzky-Golay Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 9), `degree` (default 2) |
|
||||
| **Outputs** | Single series (Sgma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- SGMA is a Finite Impulse Response (FIR) filter that uses polynomial fitting to smooth data while preserving higher moments (peaks, valleys, and inf...
|
||||
- Parameterized by `period` (default 9), `degree` (default 2).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Least-squares polynomial fitting has been solving signal processing problems since 1964. That most traders still use medieval averaging techniques says more about the industry than the math."
|
||||
|
||||
SGMA is a Finite Impulse Response (FIR) filter that uses polynomial fitting to smooth data while preserving higher moments (peaks, valleys, and inflection points). Unlike the Simple Moving Average (which flattens everything) or the Exponential Moving Average (which introduces phase lag), SGMA uses polynomial weighting to maintain the original signal's shape characteristics.
|
||||
@@ -287,4 +304,4 @@ else
|
||||
|
||||
4. **Cold Start**: SGMA requires a full window ($L$) to produce mathematically valid output. The first $L-1$ bars are warmup noise. Check `IsHot` before trading on the signal.
|
||||
|
||||
5. **High Degree Instability**: Degrees 3-4 concentrate weight heavily in the center. While this preserves shape, it also means a small number of bars dominate the output—approaching the behavior of a very short moving average with extra smoothing on the tails.
|
||||
5. **High Degree Instability**: Degrees 3-4 concentrate weight heavily in the center. While this preserves shape, it also means a small number of bars dominate the output—approaching the behavior of a very short moving average with extra smoothing on the tails.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# SINEMA: Sine-Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Sinema) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- The Sine-Weighted Moving Average (SINEMA) applies sine-wave weighting to data points within the lookback window.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Nature doesn't do straight lines, and neither should your weights."
|
||||
|
||||
The Sine-Weighted Moving Average (SINEMA) applies sine-wave weighting to data points within the lookback window. Weights follow the formula $w_i = \sin(\pi \cdot (i+1) / N)$, creating a smooth bell-shaped distribution that emphasizes middle values while gracefully tapering at the edges. Unlike SMA's uniform weighting or WMA's linear ramp, sine weighting provides a natural transition that reduces high-frequency noise while preserving mid-frequency trends.
|
||||
@@ -220,4 +237,4 @@ This produces valid, smooth output from bar 1 without waiting for a full window.
|
||||
## References
|
||||
|
||||
- Harris, F. J. (1978). "On the use of windows for harmonic analysis with the discrete Fourier transform." *Proceedings of the IEEE*, 66(1), 51-83.
|
||||
- Oppenheim, A. V., & Schafer, R. W. (2010). *Discrete-Time Signal Processing* (3rd ed.). Pearson.
|
||||
- Oppenheim, A. V., & Schafer, R. W. (2010). *Discrete-Time Signal Processing* (3rd ed.). Pearson.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# SMA: Simple Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Sma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- The Simple Moving Average (SMA) is the unweighted arithmetic mean of the last $N$ data points.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The vanilla ice cream of technical analysis. Boring, ubiquitous, and the only thing your grandfather and your high-frequency trading bot agree on."
|
||||
|
||||
The Simple Moving Average (SMA) is the unweighted arithmetic mean of the last $N$ data points. It acts as a low-pass filter, smoothing out high-frequency noise to reveal the underlying trend. While conceptually simple, efficient implementation on modern hardware requires careful attention to memory access patterns and vectorization.
|
||||
@@ -186,4 +203,4 @@ For SMA(200), total memory is approximately 1.7 KB per instance.
|
||||
|
||||
1. **Lag**: SMA has the most lag of all moving averages (Lag $\approx N/2$).
|
||||
2. **Drop-off Effect**: An old, large outlier dropping out of the window causes the SMA to jump, even if the current price is flat. This "Barker effect" is why EMAs are often preferred.
|
||||
3. **NaN Handling**: A single `NaN` in the history window corrupts the entire SMA. QuanTAlib handles this by substituting the last valid value.
|
||||
3. **NaN Handling**: A single `NaN` in the history window corrupts the entire SMA. QuanTAlib handles this by substituting the last valid value.
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# SP15: Spencer 15-Point Moving Average
|
||||
# SP15: Spencer 15-Point Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | None |
|
||||
| **Outputs** | Single series (SP15) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `Period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- SP15 is a fixed-coefficient symmetric FIR filter with 15 weights: $[-3, -6, -5, 3, 21, 46, 67, 74, 67, 46, 21, 3, -5, -6, -3]$ divided by 320.
|
||||
- No configurable parameters; computation is stateless per bar.
|
||||
- Output range: Tracks input.
|
||||
- Requires `Period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "John Spencer designed 15 weights that zero out quarterly and quintile seasonality from economic data. Eighty years later, statisticians still reach for them when they need a quick seasonal adjustment that does not require the German engineering of X-13ARIMA."
|
||||
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# SWMA: Symmetric Weighted Moving Average
|
||||
# SWMA: Symmetric Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 4) |
|
||||
| **Outputs** | Single series (Swma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- SWMA applies triangular (symmetric) weights that peak at the center of the window and taper linearly to the edges.
|
||||
- Parameterized by `period` (default 4).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Take the SMA of an SMA and you get a triangular filter. It is the simplest possible smoothing kernel that has zero phase distortion and no frequency-domain discontinuities. Sometimes simple is exactly what you need."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# TRIMA: Triangular Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Trima) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `p1 + p2 - 1` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- The Triangular Moving Average (TRIMA) places the majority of its weight on the middle of the data window, tapering off linearly towards the ends.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `p1 + p2 - 1` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The weighted blanket of moving averages. It doesn't care where the price is going right now; it cares where the price feels most comfortable."
|
||||
|
||||
The Triangular Moving Average (TRIMA) places the majority of its weight on the middle of the data window, tapering off linearly towards the ends. This creates a triangular weight distribution (hence the name). It is mathematically equivalent to a double-smoothed SMA.
|
||||
@@ -181,4 +198,4 @@ This ensures consistent bar correction across the entire cascade.
|
||||
|
||||
1. **Lag**: TRIMA has more lag than SMA, EMA, or WMA. It is a lagging indicator, not a leading one.
|
||||
2. **Signal Generation**: Due to its lag, TRIMA is poor for crossover signals. It is best used for visual trend identification or as a baseline for envelopes (e.g., TMA Bands).
|
||||
3. **Even/Odd Periods**: The exact calculation of $P_1$ and $P_2$ differs slightly between implementations for even periods. QuanTAlib matches the standard definition used by TA-Lib.
|
||||
3. **Even/Odd Periods**: The exact calculation of $P_1$ and $P_2$ differs slightly between implementations for even periods. QuanTAlib matches the standard definition used by TA-Lib.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# TSF: Time Series Forecast
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 14) |
|
||||
| **Outputs** | Single series (Tsf) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- TSF projects the least-squares regression line one bar forward, providing a statistically grounded forecast of the next bar's value.
|
||||
- Parameterized by `period` (default 14).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "The best prediction of the future is the trend that's already in motion — extended by exactly one step."
|
||||
|
||||
TSF projects the least-squares regression line one bar forward, providing a statistically grounded forecast of the next bar's value. Unlike simple moving averages that smooth past data, TSF answers the question: "If the current trend continues, where will price be next?" This makes it inherently leading rather than lagging, though the forecast degrades quickly beyond one step.
|
||||
|
||||
@@ -1,4 +1,21 @@
|
||||
# TUKEY_W: Tukey (Tapered Cosine) Window Moving Average
|
||||
# TUKEY_W: Tukey (Tapered Cosine) Window Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` (default 20), `alpha` (default 0.5) |
|
||||
| **Outputs** | Single series (Tukey_w) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- TUKEY_W applies the Tukey (tapered cosine) window as FIR filter weights, offering a single parameter $\alpha$ that controls the fraction of the win...
|
||||
- Parameterized by `period` (default 20), `alpha` (default 0.5).
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "John Tukey designed a window with a knob that goes from 'do nothing' to 'full Hann' in one parameter. Set alpha to 0.5 and you get the pragmatist's compromise: flat where it matters, tapered where it would otherwise ring."
|
||||
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# WMA: Weighted Moving Average
|
||||
|
||||
| Property | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| **Category** | Trend (FIR MA) |
|
||||
| **Inputs** | Source (close) |
|
||||
| **Parameters** | `period` |
|
||||
| **Outputs** | Single series (Wma) |
|
||||
| **Output range** | Tracks input |
|
||||
| **Warmup** | `period` bars |
|
||||
|
||||
### TL;DR
|
||||
|
||||
- The Weighted Moving Average (WMA) assigns a linearly decreasing weight to data points.
|
||||
- Parameterized by `period`.
|
||||
- Output range: Tracks input.
|
||||
- Requires `period` bars of warmup before first valid output (IsHot = true).
|
||||
- Validated against TA-Lib, Skender, and Tulip reference implementations where available.
|
||||
|
||||
> "Because yesterday matters more than last Tuesday. WMA is the linear answer to the question: 'What have you done for me lately?'"
|
||||
|
||||
The Weighted Moving Average (WMA) assigns a linearly decreasing weight to data points. The most recent price gets weight $N$, the one before it $N-1$, down to 1. This makes it more responsive to recent price changes than an SMA, but without the infinite tail of an EMA.
|
||||
@@ -237,4 +254,4 @@ For WMA(200), total memory is approximately 1.75 KB per instance.
|
||||
|
||||
1. **Drift**: Like SMA, the O(1) algorithm is susceptible to floating-point drift. QuanTAlib resets the sums every 10,000 ticks to guarantee accuracy.
|
||||
2. **Aggressiveness**: WMA reacts faster than SMA but can be "twitchy." It is often used as a component in other indicators (e.g., HMA) rather than a standalone trend filter.
|
||||
3. **Weights**: Users sometimes confuse WMA (linear weights) with EMA (exponential weights) or VWAP (volume weights).
|
||||
3. **Weights**: Users sometimes confuse WMA (linear weights) with EMA (exponential weights) or VWAP (volume weights).
|
||||
|
||||
Reference in New Issue
Block a user