Quantitative Qualitative Estimation (QQE) Pine Script Guide
The QQE (Quantitative Qualitative Estimation) is an adaptive momentum oscillator that wraps an EMA-smoothed RSI in double-smoothed ATR volatility bands to determine trend direction. Originally created by Igor Livshin in the early 2000s, the QQE solves the core limitation of standard RSI: rigid overbought and oversold levels. By calculating a dynamic trailing channel scaled to the Fibonacci multiplier 4.236, QQE adapts to changing market volatility. When the smoothed Fast line crosses above the adaptive Slow line, it marks an uptrend; when it falls below, it confirms a downtrend.
This guide provides the complete Pine Script v6 implementation, mathematical breakdown of the formula, parameter tuning rules for scalping and swing trading, crossover alert logic, and tested strategy combinations with trend filters.
What Is the QQE Indicator and How Does It Work?
The QQE indicator is an adaptive momentum oscillator that combines Welles Wilder RSI with double-smoothed ATR bands. Unlike standard RSI with static 70 and 30 thresholds, the QQE creates an adaptive channel around the smoothed RSI. The channel widens during volatile price action and tightens during quiet periods. Traders follow line crossovers rather than guessing fixed overbought levels.
History and Architecture
Igor Livshin introduced the QQE concept in the early 2000s, with coding contributions from Roman Ignatov (2006) and Tim Hyder (2008). It gained widespread adoption in MetaTrader communities before being ported to TradingView Pine Script. The indicator quantifies trend quality by evaluating whether price momentum exceeds the expected volatility threshold.
QQE Formula and Step-by-Step Calculation
The QQE indicator calculation runs in seven structured steps:
- Raw RSI: Compute standard RSI on the price source using lookback length N (default 14).
- Fast Line: Smooth the raw RSI using an EMA with the smoothing factor parameter (default 5).
- True Range of RSI: Calculate the absolute bar-to-bar change of the Fast line: `abs(Fast - Fast[1])`.
- First Wilder Smoothing: Apply Wilder moving average (alpha = 1 / N) to the true range.
- Second Wilder Smoothing: Apply Wilder moving average again to get the double-smoothed ATR of RSI.
- Volatility Threshold Bands: Multiply the smoothed ATR by 4.236 (phi cubed) to set upper and lower trailing boundaries.
- Slow Line Trailing Logic: The Slow line tracks between the upper and lower bands based on trend direction, creating the trailing stop channel.
QQE Mathematical Formulation
rsii = ta.ema(ta.rsi(source, rsi_length), rsi_smoothing_factor)
tr = math.abs(rsii - rsii[1])
wwma = (1 / rsi_length) * tr + (1 - 1 / rsi_length) * nz(wwma[1])
atr_rsi = (1 / rsi_length) * wwma + (1 - 1 / rsi_length) * nz(atr_rsi[1])
Upper Band = rsii + atr_rsi * 4.236
Lower Band = rsii - atr_rsi * 4.236
Note: The multiplier 4.236 is derived from the Fibonacci ratio cubed (1.6180339887^3 ≈ 4.236).
Indicator Type
Adaptive Momentum Oscillator
Primary Timeframes
1H, 4H, Daily charts
Supported Assets
Forex, Indices, Stocks, Crypto
Does the QQE Indicator Repaint?
No, the QQE indicator does not repaint historical bars. The underlying calculation uses causal historical series data (past closes, Wilder smoothed true range, and exponential moving averages). Once a bar closes, all values, line positions, and crossover signals are locked permanently.
Understanding Real-Time vs Historical Bar Behavior
When viewing QQE on the currently open (real-time) bar, the Fast and Slow lines update with every incoming price tick. If price spikes, a crossover may appear and then disappear before the bar closes. This is standard TradingView tick behavior, not indicator repainting.
To prevent premature execution in automated strategies or alerts, always evaluate signals on confirmed bar closes using barstate.isconfirmed or set alerts to Once Per Bar Close in TradingView.
QQE Pine Script v6 Source Code
Copy this complete Pine Script v6 implementation into TradingView. Open the Pine Script editor with Alt+P (Option+P on Mac), paste the code, and click Add to chart.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify
//@version=6
indicator(title="Quantitative Qualitative Estimation", overlay=false, max_labels_count=500)
p_ta_qqe(series float source, simple int rsi_length, simple int rsi_smoothing_factor) =>
rsii = ta.ema(ta.rsi(source, rsi_length), rsi_smoothing_factor)
tr = math.abs(rsii - rsii[1])
wwalpha = 1 / rsi_length
wwma = 0.0
wwma := wwalpha * tr + (1 - wwalpha) * nz(wwma[1])
atr_rsi = 0.0
atr_rsi := wwalpha * wwma + (1 - wwalpha) * nz(atr_rsi[1])
qqef = ta.ema(ta.rsi(source, rsi_length), rsi_smoothing_factor)
qup = qqef + atr_rsi * 4.236
qdown = qqef - atr_rsi * 4.236
qqes = 0.0
qqes := qup < nz(qqes[1]) ? qup : qqef > nz(qqes[1]) and qqef[1] < nz(qqes[1]) ? qdown : qdown > nz(qqes[1]) ? qdown : qqef < nz(qqes[1]) and qqef[1] > nz(qqes[1]) ? qup : nz(qqes[1])
buySignal = ta.crossover(qqef, qqes)
sellSignal = ta.crossunder(qqef, qqes)
[qqef, qqes, buySignal, sellSignal]
[p_ind_1_fast, p_ind_1_slow, p_ind_1_buySignal, p_ind_1_sellSignal] = p_ta_qqe(close, 14, 5)
p_ind_1_fast_plot = plot(p_ind_1_fast, title="QQE - Fast Line", color=color.rgb(136, 14, 79, 0), linewidth=2)
p_ind_1_slow_plot = plot(p_ind_1_slow, title="QQE - Slow Line", color=color.rgb(33, 150, 243, 0), linewidth=2)
fill(p_ind_1_fast_plot, p_ind_1_slow_plot, title="QQE - Trend Color", color=p_ind_1_fast > p_ind_1_slow ? color.rgb(76, 175, 80, 90) : color.rgb(242, 54, 69, 90))
// Alert conditions on confirmed bar close
alertcondition(p_ind_1_buySignal, title="QQE Buy Signal", message="QQE Fast crossed above Slow line")
alertcondition(p_ind_1_sellSignal, title="QQE Sell Signal", message="QQE Fast crossed below Slow line")Chart Visual Preview

Chart Visual Components
| Component | Role and Interpretation |
|---|---|
| Fast Line (Purple) | EMA-smoothed RSI momentum line. Reacts quickly to price shifts and initiates trend crossover triggers. |
| Slow Line (Blue) | Adaptive trailing band based on 4.236x Wilder ATR of RSI. Acts as dynamic support and resistance for momentum. |
| Green Cloud Fill | Fast line is above Slow line, indicating prevailing bullish momentum. |
| Red Cloud Fill | Fast line is below Slow line, indicating dominant bearish momentum. |
QQE Parameter Settings and Multi-Timeframe Tuning
| Parameter | Default | Role | Range |
|---|---|---|---|
| source | close | Input price series (close, hl2, or ohlc4). | close, hl2 |
| RSI Length | 14 | Lookback period for RSI calculation. | 7 to 21 |
| Smoothing Factor | 5 | EMA smoothing applied to the RSI before volatility banding. | 3 to 8 |
Best QQE Settings by Trading Style
Scalping (5M to 15M charts)
RSI Length = 7, Smoothing Factor = 3. Provides rapid signal generation for short-term momentum scalps. Pair with a 50 EMA filter.
Day Trading (1H charts)
RSI Length = 14, Smoothing Factor = 5. Balanced configuration filtering noise while capturing session moves.
Swing Trading (4H to Daily charts)
RSI Length = 14 or 21, Smoothing Factor = 5 or 8. Captures multi-day trends with minimal false crossovers.
QQE Signals and Threshold Levels Explained
QQE provides three distinct signal channels: Fast/Slow line crossovers, 50 centerline baseline momentum filter, and Fast line price divergences.
1. Bullish & Bearish Crossovers
A bullish crossover occurs when the Fast line crosses upward through the Slow line. A bearish crossunder occurs when the Fast line drops downward through the Slow line. These crossovers form the primary entry signals.
2. The 50 Level Momentum Baseline
The 50 level represents the neutral momentum balance. When the Fast line holds above 50, market momentum favors buyers. When it drops below 50, sellers maintain control. Filtering longs to only occur when Fast line is above 50 avoids false bottom-picking attempts.
3. Regular and Hidden Divergences
When price forms a lower low while the QQE Fast line prints a higher low, bullish divergence signals selling exhaustion. Conversely, a higher price high with a lower Fast line peak signals bearish exhaustion.
QQE Trend Following Strategy
Trading QQE crossovers in isolation can produce whipsaws in sideways markets. Pairing QQE with a 200 EMA trend filter and ATR volatility rules establishes a high-probability trading system.
Long Setup Rules
- Price is trading above the 200 EMA (macro uptrend).
- QQE Fast line crosses above the Slow line on a closed bar.
- QQE Fast line is above the 50 level baseline.
- Stop loss placed 1.5x ATR below the entry swing low.
- Take profit set at 2.0x risk or when QQE crosses back below the Slow line.
Short Setup Rules
- Price is trading below the 200 EMA (macro downtrend).
- QQE Fast line crosses below the Slow line on a closed bar.
- QQE Fast line is below the 50 level baseline.
- Stop loss placed 1.5x ATR above the entry swing high.
- Take profit set at 2.0x risk or when QQE crosses back above the Slow line.
Frequently Asked Questions
Related Indicators and Guides
QQE MOD Indicator
Dual QQE system with Bollinger Bands overlay for enhanced breakout filtering.
Relative Strength Index
The foundational momentum oscillator measuring price velocity on a 0 to 100 scale.
MACD Indicator
Moving average convergence divergence oscillator for trend following momentum.
Average Directional Index
Quantifies trend strength to filter ranging markets before taking QQE entries.
Supertrend Indicator
ATR-based trailing stop line for clear trend following and position management.
Stochastic Oscillator
Compares closing price to price range over lookback periods for turning points.
Generate Custom QQE Scripts with AI
Create and customize QQE indicators, multi-timeframe alerts, and automated strategies in Pine Script v6 or MetaTrader 5 without writing code manually.
Try Pineify Free