mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-17 01:58:06 +00:00
- LTMA (Linear Trend Moving Average): Introduces a predictive moving average using dual cascaded EMAs for trend estimation. - MCNMA (McNicholl EMA): Implements a zero-lag TEMA using a cascaded EMA structure for enhanced responsiveness. - NLMA (Non-Lag Moving Average): Utilizes a damped cosine kernel to achieve reduced lag in moving averages. - NMA (Natural Moving Average): Adapts smoothing based on volatility profiles using a square-root kernel. - NYQMA (Nyquist Moving Average): Applies the Nyquist-Shannon theorem to prevent aliasing in cascaded moving averages. - RAIN (Rainbow Moving Average): Combines multiple SMA layers with weighted averages for multi-scale smoothing. - TRAMA (Trend Regularity Adaptive Moving Average): Adapts smoothing based on the frequency of new highs and lows in price data.
114 lines
4.4 KiB
Markdown
114 lines
4.4 KiB
Markdown
# AROON: Aroon Indicator
|
||
|
||
The Aroon indicator measures the temporal freshness of price extremes, answering not "how much did price move?" but "how long ago did it make a new high or low?" Aroon Up tracks the recency of the highest high within the lookback window; Aroon Down tracks the recency of the lowest low. Both are normalized to 0-100 where 100 means the extreme occurred on the current bar and 0 means it occurred at the far edge of the window. A companion Aroon Oscillator (Up minus Down) provides a single zero-centered metric for trend bias. Unlike recursive indicators that accumulate floating-point drift, Aroon is purely windowed — its value depends only on data within the lookback period, making it immune to initialization artifacts.
|
||
|
||
## Historical Context
|
||
|
||
Tushar Chande introduced Aroon in *Beyond Technical Analysis* (1995). The name comes from the Sanskrit word for "Dawn's Early Light," reflecting the indicator's purpose: to spot the dawn of a new trend rather than merely confirm an existing one. Chande's insight was that trends do not simply stop; they age. A trend that has not made a new high in 20 of the last 25 bars is statistically moribund, regardless of how strong the original breakout was. The temporal perspective inverts the usual analysis framework: instead of asking whether price is above or below some average, Aroon asks whether the market is still making progress in a given direction. This makes it particularly effective at identifying the transition zone between trending and ranging regimes.
|
||
|
||
## Architecture & Physics
|
||
|
||
### 1. Sliding Window
|
||
|
||
A circular buffer of size $N+1$ stores the last $N+1$ bars of High and Low values (the current bar plus $N$ historical bars).
|
||
|
||
### 2. Extremum Search
|
||
|
||
On each bar, the buffer is scanned to find the index of the highest high and the index of the lowest low within the window.
|
||
|
||
### 3. Aroon Up
|
||
|
||
$$\text{AroonUp} = \frac{N - \text{barsSinceHigh}}{N} \times 100$$
|
||
|
||
where barsSinceHigh is the number of bars elapsed since the highest high.
|
||
|
||
### 4. Aroon Down
|
||
|
||
$$\text{AroonDown} = \frac{N - \text{barsSinceLow}}{N} \times 100$$
|
||
|
||
### 5. Aroon Oscillator
|
||
|
||
$$\text{AroonOsc} = \text{AroonUp} - \text{AroonDown}$$
|
||
|
||
Range: $[-100, +100]$.
|
||
|
||
### 6. Complexity
|
||
|
||
- **Time:** $O(N)$ per bar for the min/max linear scan (monotonic deque optimization possible for amortized $O(1)$)
|
||
- **Space:** $O(N)$ — ring buffers for High and Low
|
||
- **Warmup:** $N$ bars to fill the window
|
||
|
||
## Mathematical Foundation
|
||
|
||
### Parameters
|
||
|
||
| Symbol | Parameter | Default | Constraint |
|
||
|--------|-----------|---------|------------|
|
||
| $N$ | period | 25 | $N \geq 1$ |
|
||
|
||
### Pseudo-code
|
||
|
||
```
|
||
Initialize:
|
||
highBuf = RingBuffer(period + 1)
|
||
lowBuf = RingBuffer(period + 1)
|
||
bar_count = 0
|
||
|
||
On each bar (high, low, isNew):
|
||
if !isNew: restore previous state
|
||
|
||
highBuf.Add(high)
|
||
lowBuf.Add(low)
|
||
bar_count++
|
||
|
||
// Find index of highest high in buffer
|
||
maxIdx = 0
|
||
maxVal = -∞
|
||
for i = 0 to min(bar_count, period):
|
||
if highBuf[i] >= maxVal:
|
||
maxVal = highBuf[i]
|
||
maxIdx = i
|
||
|
||
// Find index of lowest low in buffer
|
||
minIdx = 0
|
||
minVal = +∞
|
||
for i = 0 to min(bar_count, period):
|
||
if lowBuf[i] <= minVal:
|
||
minVal = lowBuf[i]
|
||
minIdx = i
|
||
|
||
len = min(bar_count, period)
|
||
barsSinceHigh = len - maxIdx
|
||
barsSinceLow = len - minIdx
|
||
|
||
AroonUp = (len - barsSinceHigh) / len × 100
|
||
AroonDown = (len - barsSinceLow) / len × 100
|
||
AroonOsc = AroonUp - AroonDown
|
||
|
||
output:
|
||
Up = AroonUp
|
||
Down = AroonDown
|
||
Oscillator = AroonOsc
|
||
```
|
||
|
||
### Interpretation
|
||
|
||
| Condition | Signal |
|
||
|-----------|--------|
|
||
| AroonUp > 70, AroonDown < 30 | Strong uptrend (recent highs, stale lows) |
|
||
| AroonDown > 70, AroonUp < 30 | Strong downtrend (recent lows, stale highs) |
|
||
| Both > 70 | Volatile; both extremes are fresh |
|
||
| Both < 30 | Consolidation; both extremes are stale |
|
||
| AroonOsc > 0 | Bullish bias |
|
||
| AroonOsc < 0 | Bearish bias |
|
||
|
||
### Step-Function Behavior
|
||
|
||
Aroon produces discrete jumps rather than smooth curves. When a new extreme occurs, the corresponding line snaps to 100. Between new extremes, the line decays linearly by $100/N$ per bar. This staircase pattern is a natural consequence of the temporal measurement and should not be smoothed away — it carries information about the periodicity of extremes.
|
||
|
||
## Resources
|
||
|
||
- Chande, T.S. — *Beyond Technical Analysis* (John Wiley & Sons, 1995)
|
||
- Chande, T.S. — *The New Technical Trader* (John Wiley & Sons, 1995)
|
||
- PineScript reference: `aroon.pine` in indicator directory
|