OPEN-SOURCE SCRIPT
Quadruple EMA (QEMA)

The Quadruple Exponential Moving Average (QEMA) is an advanced technical indicator that extends the concept of lag reduction beyond TEMA (Triple Exponential Moving Average) to a fourth order. By applying a sophisticated four-stage EMA cascade with optimized coefficient distribution, QEMA provides the ultimate evolution in EMA-based lag reduction techniques.
Unlike traditional compund moving averages like DEMA and TEMA, QEMA implements a progressive smoothing system that strategically distributes alphas across four EMA stages and combines them with balanced coefficients (4, -6, 4, -1). This approach creates an indicator that responds extremely quickly to price changes while still maintaining sufficient smoothness to be useful for trading decisions. QEMA is particularly valuable for traders who need the absolute minimum lag possible in trend identification.
▶️ **Core Concepts**
QEMA achieves its exceptional lag reduction by combining four progressive EMAs with mathematically optimized coefficients. The formula is designed to maximize responsiveness while minimizing the overshoot problems that typically occur with aggressive lag reduction techniques. The implementation uses a ratio-based alpha progression that ensures each EMA stage contributes appropriately to the final result.
▶️ **Common Settings and Parameters**
Pro Tip: Professional traders often use QEMA with longer periods than other moving averages (e.g., QEMA(20) instead of EMA(10)) since its extreme lag reduction provides earlier signals even with longer periods.
▶️ **Calculation and Mathematical Foundation**
Simplified explanation:
QEMA works by calculating four EMAs in sequence, with each EMA taking the previous one as input. It then combines these EMAs using balancing weights (4, -6, 4, -1) to create a moving average with extremely minimal lag and high level of smoothness. The alpha factors for each EMA are progressively adjusted using a mathematical ratio to ensure balanced responsiveness across all stages.
Technical formula:
Pine Script®
Where:
Mathematical Rationale for the Alpha Cascade:
The QEMA indicator employs a specific geometric progression for its smoothing factors (alphas) across the four EMA stages. This design is intentional and aims to optimize the filter's performance. The ratio between alphas is **r = (1/α₁)^(1/3)** - derived from the cube root of the reciprocal of the base alpha.
For typical smoothing (α₁ < 1), this results in a sequence of increasing alpha values (α₁ < α₂ < α₃ < α₄), meaning that subsequent EMAs in the cascade are progressively faster (less smoothed). This specific progression, when combined with the QEMA coefficients (4, -6, 4, -1), is chosen for the following reasons:
1. Optimized Frequency Response:
Using the same alpha for all EMA stages (as in a naive multi-EMA approach) can lead to an uneven frequency response, potentially causing over-shooting of certain frequencies or creating undesirable resonance. The geometric progression of alphas in QEMA helps to create a more balanced and controlled filter response across a wider range of movement frequencies. Each stage's contribution to the overall filtering characteristic is more harmonized.
2. Minimized Phase Lag:
A key goal of QEMA is extreme lag reduction. The specific alpha cascade, particularly the relationship defined by **r**, is designed to minimize the cumulative phase lag introduced by the four smoothing stages, while still providing effective noise reduction. Faster subsequent EMAs contribute to this reduced lag.
🔍 Technical Note: The ratio-based alpha progression is crucial for balanced response. The ratio r is calculated as the cube root of 1/α₁, ensuring that the combined effect of all four EMAs creates a mathematically optimal response curve. All EMAs are initialized with the first source value rather than using progressive initialization, eliminating warm-up artifacts and providing consistent results from the first bar.
▶️ **Interpretation Details**
QEMA provides several key insights for traders:
QEMA is particularly valuable in fast-moving markets and for short-term trading strategies where speed of signal generation is critical. It excels at capturing the very beginning of trends and identifying reversals earlier than any other EMA-derived indicator. This makes it especially useful for breakout trading and scalping strategies where getting in early is essential.
▶️ **Limitations and Considerations**
▶️ **References**
Unlike traditional compund moving averages like DEMA and TEMA, QEMA implements a progressive smoothing system that strategically distributes alphas across four EMA stages and combines them with balanced coefficients (4, -6, 4, -1). This approach creates an indicator that responds extremely quickly to price changes while still maintaining sufficient smoothness to be useful for trading decisions. QEMA is particularly valuable for traders who need the absolute minimum lag possible in trend identification.
▶️ **Core Concepts**
- Fourth-order processing: Extends the EMA cascade to four stages for maximum possible lag reduction while maintaining a useful signal
- Progressive alpha system: Uses mathematically derived ratio-based alpha progression to balance responsiveness across all four EMA stages
- Optimized coefficients: Employs calculated weights (4, -6, 4, -1) to effectively eliminate lag while preserving compound signal stability
- Numerical stability control: Implements initialization and alpha distribution to ensure consistent results from the first calculation bar
QEMA achieves its exceptional lag reduction by combining four progressive EMAs with mathematically optimized coefficients. The formula is designed to maximize responsiveness while minimizing the overshoot problems that typically occur with aggressive lag reduction techniques. The implementation uses a ratio-based alpha progression that ensures each EMA stage contributes appropriately to the final result.
▶️ **Common Settings and Parameters**
- Period: Default: 15| Base smoothing period | When to Adjust: Decrease for extremely fast signals, increase for more stable output
- Alpha: Default: auto | Direct control of base smoothing factor | When to Adjust: Manual setting allows precise tuning beyond standard period settings
- Source: Default: Close | Data point used for calculation | When to Adjust: Change to HL2 or HLC3 for more balanced price representation
Pro Tip: Professional traders often use QEMA with longer periods than other moving averages (e.g., QEMA(20) instead of EMA(10)) since its extreme lag reduction provides earlier signals even with longer periods.
▶️ **Calculation and Mathematical Foundation**
Simplified explanation:
QEMA works by calculating four EMAs in sequence, with each EMA taking the previous one as input. It then combines these EMAs using balancing weights (4, -6, 4, -1) to create a moving average with extremely minimal lag and high level of smoothness. The alpha factors for each EMA are progressively adjusted using a mathematical ratio to ensure balanced responsiveness across all stages.
Technical formula:
QEMA = 4 × EMA₁ - 6 × EMA₂ + 4 × EMA₃ - EMA₄
Where:
- EMA₁ = EMA(source, α₁)
- EMA₂ = EMA(EMA₁, α₂)
- EMA₃ = EMA(EMA₂, α₃)
- EMA₄ = EMA(EMA₃, α₄)
- α₁ = 2/(period + 1) is the base smoothing factor
- r = (1/α₁)^(1/3) is the derived ratio
- α₂ = α₁ × r, α₃ = α₂ × r, α₄ = α₃ × r are the progressive alphas
Mathematical Rationale for the Alpha Cascade:
The QEMA indicator employs a specific geometric progression for its smoothing factors (alphas) across the four EMA stages. This design is intentional and aims to optimize the filter's performance. The ratio between alphas is **r = (1/α₁)^(1/3)** - derived from the cube root of the reciprocal of the base alpha.
For typical smoothing (α₁ < 1), this results in a sequence of increasing alpha values (α₁ < α₂ < α₃ < α₄), meaning that subsequent EMAs in the cascade are progressively faster (less smoothed). This specific progression, when combined with the QEMA coefficients (4, -6, 4, -1), is chosen for the following reasons:
1. Optimized Frequency Response:
Using the same alpha for all EMA stages (as in a naive multi-EMA approach) can lead to an uneven frequency response, potentially causing over-shooting of certain frequencies or creating undesirable resonance. The geometric progression of alphas in QEMA helps to create a more balanced and controlled filter response across a wider range of movement frequencies. Each stage's contribution to the overall filtering characteristic is more harmonized.
2. Minimized Phase Lag:
A key goal of QEMA is extreme lag reduction. The specific alpha cascade, particularly the relationship defined by **r**, is designed to minimize the cumulative phase lag introduced by the four smoothing stages, while still providing effective noise reduction. Faster subsequent EMAs contribute to this reduced lag.
🔍 Technical Note: The ratio-based alpha progression is crucial for balanced response. The ratio r is calculated as the cube root of 1/α₁, ensuring that the combined effect of all four EMAs creates a mathematically optimal response curve. All EMAs are initialized with the first source value rather than using progressive initialization, eliminating warm-up artifacts and providing consistent results from the first bar.
▶️ **Interpretation Details**
QEMA provides several key insights for traders:
- When price crosses above QEMA, it signals the beginning of an uptrend with minimal delay
- When price crosses below QEMA, it signals the beginning of a downtrend with minimal delay
- The slope of QEMA provides immediate insight into trend direction and momentum
- QEMA responds to price reversals significantly faster than other moving averages
- Multiple QEMA lines with different periods can identify immediate support/resistance levels
QEMA is particularly valuable in fast-moving markets and for short-term trading strategies where speed of signal generation is critical. It excels at capturing the very beginning of trends and identifying reversals earlier than any other EMA-derived indicator. This makes it especially useful for breakout trading and scalping strategies where getting in early is essential.
▶️ **Limitations and Considerations**
- Market conditions: Can generate excessive signals in choppy, sideways markets due to its extreme responsiveness
- Overshooting: The aggressive lag reduction can create some overshooting during sharp reversals
- Calculation complexity: Requires four separate EMA calculations plus coefficient application, making it computationally more intensive
- Parameter sensitivity: Small changes in the base alpha or period can significantly alter behavior
- Complementary tools: Should be used with momentum indicators or volatility filters to confirm signals and reduce false positives
▶️ **References**
- Mulloy, P. (1994). "Smoothing Data with Less Lag," Technical Analysis of Stocks & Commodities.
- Ehlers, J. (2001). Rocket Science for Traders. John Wiley & Sons.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
github.com/mihakralj/pinescript
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
github.com/mihakralj/pinescript
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
A collection of mathematically rigorous technical indicators for Pine Script 6, featuring defensible math, optimized implementations, proper state initialization, and O(1) constant time efficiency where possible.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.