Files
QuanTAlib/lib/trends/t3/T3.md
T

69 lines
2.9 KiB
Markdown

# T3: Tillson T3 Moving Average
> "If one EMA is good, six must be better. Tim Tillson's logic is impeccable, provided you hate noise more than you love latency."
The T3 Moving Average is a hyper-smooth, low-lag filter that cascades six Exponential Moving Averages (EMAs). Unlike standard cascading (which increases lag), T3 uses a "Volume Factor" ($v$) to weight the EMAs in a way that partially cancels out the lag, resulting in a curve that is smoother than an EMA but more responsive than an SMA.
## Historical Context
Introduced by Tim Tillson in *Technical Analysis of Stocks & Commodities* (Jan 1998), "Smoothing Techniques for More Accurate Signals." Tillson sought to improve upon the DEMA (Double EMA) and TEMA (Triple EMA) concepts by generalizing the lag-reduction mathematics.
## Architecture & Physics
T3 is essentially a filter of filters. It passes data through a chain of 6 EMAs:
$Input \to EMA_1 \to EMA_2 \to EMA_3 \to EMA_4 \to EMA_5 \to EMA_6$
It then combines these outputs using coefficients derived from the Volume Factor ($v$).
### The Volume Factor ($v$)
* **$v = 0$**: T3 becomes a standard EMA (actually, a triple EMA of EMAs).
* **$v = 1$**: T3 behaves like DEMA/TEMA with aggressive lag reduction (and potential overshoot).
* **$v = 0.7$**: The default. A "Goldilocks" zone of smoothness and responsiveness.
## Mathematical Foundation
### 1. Coefficients
Given $v$ (default 0.7):
$$ c_1 = -v^3 $$
$$ c_2 = 3v^2 + 3v^3 $$
$$ c_3 = -6v^2 - 3v - 3v^3 $$
$$ c_4 = 1 + 3v + 3v^2 + v^3 $$
### 2. The Formula
(Note: There are multiple variations of T3. QuanTAlib uses the standard Tillson formula).
$$ T3 = c_1 e_6 + c_2 e_5 + c_3 e_4 + c_4 e_3 $$
Where $e_n$ is the output of the $n$-th EMA in the cascade.
## Performance Profile
| Metric | Score | Notes |
| :--- | :--- | :--- |
| **Throughput** | 8 | O(1), but involves 6 cascaded EMA calculations. |
| **Allocations** | 0 | Zero-allocation in hot paths. |
| **Complexity** | O(1) | Constant time regardless of period. |
| **Accuracy** | 10 | Matches TA-Lib exactly. |
| **Timeliness** | 9 | Very low lag due to volume factor cancellation. |
| **Overshoot** | 6 | Can overshoot significantly if $v > 1$. |
| **Smoothness** | 10 | Extremely smooth due to 6-pole filtering. |
## Validation
| Library | Status | Notes |
| :--- | :--- | :--- |
| **TA-Lib** | ✅ | Matches `TA_T3` exactly. |
| **Skender** | ✅ | Matches `GetT3` exactly. |
| **Tulip** | N/A | Not implemented. |
| **Ooples** | ✅ | Matches `CalculateTillsonT3MovingAverage`. |
### Common Pitfalls
1. **Warmup**: Because it cascades 6 EMAs, T3 takes significantly longer to stabilize than a standard EMA. A T3(10) might need 60+ bars to converge.
2. **Overshoot**: With high $v$ values ($>1$), T3 can overshoot price turns, creating false breakout signals.
3. **Complexity**: It is computationally heavier than SMA or EMA (approx 6x ops), though still negligible on modern CPUs.