Indicator · Pine Script v6 · Own pane

QQE + AK Trend + EFI

by realanthonyc· code credited to Anthony

This Pine Script indicator combines QQE, AK Trend, and EFI indicators.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code118
Settings16inputs
LicenceMPL-2.0
Last update10 months ago4 Dec 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

118 lines of Pine Script v6 from Archive/qqe-ak-trend-v1.4.6.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

qqe-ak-trend-v1.4.6.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Anthony C. https://x.com/anthonycxc

//@version=6
// -------------------------------------------------------------------------
//  QQE + AK Trend + EFI
//  - QQE histogram with Wilder's smoothing (ta.rma) for ATR-of-RSI
//  - AK Scale Factor based on timeframe
//  - Elder Force Index (EFI) with dynamic scaling to match QQE trend range
//  - Dynamic scaling adjusts EFI height based on QQE range over the specified number of bars
//  v1.4.6
// -------------------------------------------------------------------------
indicator("QQE + AK Trend + EFI", shorttitle="QQE + AK + EFI", overlay=false, max_lines_count=1, max_bars_back=800)

// === QQE Settings ===
rsiLengthPrimary     = input.int(6, "RSI Length", minval=1, group="QQE Settings")
rsiSmoothingPrimary  = input.int(5, "RSI Smoothing", minval=1, group="QQE Settings")
qqeFactorPrimary     = input.float(2.0, "QQE Factor", minval=0.1, step=0.1, tooltip="Lower = smoother QQE band.", group="QQE Settings")
thresholdPrimary     = input.float(10.0, "Threshold", minval=0.1, step=0.1, tooltip="RSI distance from 50 to color histogram.", group="QQE Settings")
sourcePrimary        = input.source(close, "RSI Source", group="QQE Settings")
atrLen               = input.int(14, "ATR Length for QQE (Wilder)", minval=1, group="QQE Settings")

// === AK Trend Settings ===
showAkTrend          = input.bool(true, "Compute and show the AK Trend line", group="AK Trend Settings")
input1               = input.int(3, "Fast EMA 1", minval=1, group="AK Trend Settings")
input2               = input.int(8, "Fast EMA 2", minval=1, group="AK Trend Settings")
ak_scale_less_15m    = input.float(32.0, "AK Scale Factor (<15m)", minval=0.1, step=0.1, tooltip="Scale factor for timeframes less than 15 minutes", group="AK Trend Settings")
ak_scale_15m_1h      = input.float(16.0, "AK Scale Factor (15m-1h)", minval=0.1, step=0.1, tooltip="Scale factor for timeframes between 15 minutes and 1 hour", group="AK Trend Settings")
ak_scale_1h_1d       = input.float(8.0,  "AK Scale Factor (>1h-1d)", minval=0.1, step=0.1, tooltip="Scale factor for timeframes between 1 hour and 1 day", group="AK Trend Settings")
ak_scale_above_1d    = input.float(3.0,  "AK Scale Factor (>1d)", minval=0.1, step=0.1, tooltip="Scale factor for timeframes above 1 day", group="AK Trend Settings")

// === EFI Settings ===
efiLength            = input.int(13, "EFI Length", minval=1, group="EFI Settings")
efiMultiplier        = input.float(2.25, "EFI Multiplier", minval=0.1, step=0.05, tooltip="Multiplier to adjust EFI height relative to QQE range (higher value makes EFI taller).", group="EFI Settings")
dynamicScalingBars   = input.int(300, "Dynamic Scaling Bars", minval=1, tooltip="Number of bars to look back for dynamic scaling of EFI (larger value considers more historical data for range calculation).", group="EFI Settings")

// === AK Scale Factor based on timeframe ===
getAkScaleFactor(_less_15m, _15m_1h, _1h_1d, _above_1d) =>
    timeframeInMinutes = timeframe.period == "1" ? 1 :
                         timeframe.period == "5" ? 5 :
                         timeframe.period == "15" ? 15 :
                         timeframe.period == "30" ? 30 :
                         timeframe.period == "60" ? 60 :
                         timeframe.period == "240" ? 240 :
                         timeframe.period == "D" ? 1440 : 1440
    akScale = timeframeInMinutes < 15 ? _less_15m :
              timeframeInMinutes <= 60 ? _15m_1h :
              timeframeInMinutes <= 1440 ? _1h_1d : _above_1d
    akScale
ak_scale = getAkScaleFactor(ak_scale_less_15m, ak_scale_15m_1h, ak_scale_1h_1d, ak_scale_above_1d)

// === Calculate QQE ===
calculateQQE(_src, _rsiLen, _sLen, _qqeFactor, _atrLen) =>
    // RSI and smoothing
    _rsi         = ta.rsi(_src, _rsiLen)
    _smoothedRsi = ta.ema(_rsi, _sLen)

    // ATR of RSI via Wilder's smoothing (classic QQE style)
    _atrRsi = math.abs(_smoothedRsi - _smoothedRsi[1])
    _atrW   = ta.rma(_atrRsi, _atrLen)
    _delta  = _atrW * _qqeFactor

    // Bands with proper initialization using nz()
    var float _longBand = na
    var float _shortBand = na
    var int   _trendDir  = 0
    _newShort = _smoothedRsi + _delta
    _newLong  = _smoothedRsi - _delta
    _longPrev  = nz(_longBand[1],  _newLong)
    _shortPrev = nz(_shortBand[1], _newShort)
    _longBand  := _smoothedRsi > _longPrev  ? math.max(_longPrev,  _newLong)  : _newLong
    _shortBand := _smoothedRsi < _shortPrev ? math.min(_shortPrev, _newShort) : _newShort

    // Trend direction with explicit edge checks; seed with nz()
    _crossUp = _smoothedRsi > _shortPrev and _smoothedRsi[1] <= _shortPrev
    _crossDn = _smoothedRsi < _longPrev  and _smoothedRsi[1] >= _longPrev
    _trendDir := _crossUp ? 1 : _crossDn ? -1 : nz(_trendDir[1], 0)
    _qqeTrendLine = _trendDir == 1 ? _longBand : _shortBand
    [_qqeTrendLine, _smoothedRsi - 50]  // return QQE trend (unshifted) and RSI shifted to 0

// === Main Calculations ===
[qqeTrend, rsi0] = calculateQQE(sourcePrimary, rsiLengthPrimary, rsiSmoothingPrimary, qqeFactorPrimary, atrLen)

// AK Trend (compute only when shown)
fastmaa = showAkTrend ? ta.ema(close, input1) : na
fastmab = showAkTrend ? ta.ema(close, input2) : na
bspread = showAkTrend ? (fastmaa - fastmab) * 1.001 : na
akTrendColor = bspread > 0 ? color.rgb(5, 152, 5) : color.rgb(180, 0, 0)

// EFI Calculation
efi = ta.ema(ta.change(close) * volume, efiLength)

// Dynamic scaling to match QQE trend range
qqeShifted = qqeTrend - 50
qqeHighest = ta.highest(qqeShifted, dynamicScalingBars)
qqeLowest = ta.lowest(qqeShifted, dynamicScalingBars)
efiHighest = ta.highest(efi, dynamicScalingBars)
efiLowest = ta.lowest(efi, dynamicScalingBars)
scaleFactor = efiMultiplier * (math.max(math.abs(qqeHighest), math.abs(qqeLowest)) / math.max(math.max(math.abs(efiHighest), math.abs(efiLowest)), 0.0001))
scaledEfi = efi * scaleFactor

// === Plotting ===
// QQE histogram (shifted RSI around 0)
rsiColor = rsi0 >  thresholdPrimary ? color.rgb(144, 238, 144) :
           rsi0 < -thresholdPrimary ? color.rgb(255, 99, 71) :
                                      color.rgb(112, 112, 112, 50)
plot(rsi0, color=rsiColor, title="QQE Histogram", style=plot.style_columns)

// EFI area
efiAreaColor = scaledEfi >= 0 ? color.rgb(144, 238, 144, 60) : color.rgb(255, 99, 71, 60)
plot(scaledEfi, color=efiAreaColor, title="EFI Area", style=plot.style_area, display=display.none)

// EFI line (overlay to preserve original shape)
plot(scaledEfi, color=color.rgb(254,185,55), title="EFI Line", linewidth=1)

// AK Trend line (draw only when requested)
akTrendValue = showAkTrend ? bspread * ak_scale : na
plot(akTrendValue, title="AK Trend Line", color=akTrendColor, linewidth=2)

Overview

QQE + AK Trend + EFI calculates the QQE using RSI with smoothing and displays it as a histogram in a separate pane. The AK Trend line is formed by two exponential moving averages whose scale adjusts according to the current timeframe. The EFI is dynamically scaled to align with the QQE range based on historical bars. The script renders the QQE histogram, AK trend line, and EFI in a separate pane. Settings include RSI parameters, QQE factor, AK EMA lengths, timeframe-based scale factors, EFI length and multiplier, and dynamic scaling bars. It focuses on trend analysis and does not include exit rules.

Details

Published by

realanthonyc on GitHub

Code credit

Anthony, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend, Moving averages, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

indicatorpinescripttradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI Lengthint6rsiLengthPrimary
RSI Smoothingint5rsiSmoothingPrimary
QQE Factorfloat2.0qqeFactorPrimary
Thresholdfloat10.0thresholdPrimary
RSI SourcesourceclosesourcePrimary
ATR Length for QQE (Wilder)int14atrLen
Compute and show the AK Trend linebooltrueshowAkTrend
Fast EMA 1int3input1
Fast EMA 2int8input2
AK Scale Factor (<15m)float32.0ak_scale_less_15m
AK Scale Factor (15m-1h)float16.0ak_scale_15m_1h
AK Scale Factor (>1h-1d)float8.0ak_scale_1h_1d
Show all 16 settings
SettingTypeDefaultVariable
AK Scale Factor (>1d)float3.0ak_scale_above_1d
EFI Lengthint13efiLength
EFI Multiplierfloat2.25efiMultiplier
Dynamic Scaling Barsint300dynamicScalingBars
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator
29 stars

The Supertrended RSI [AlgoAlpha] indicator plots the Relative Strength Index combined with a Supertrend overlay in a separate indicator pane. It first computes standard RSI, with an optional Hull Moving Average smoothing step, and computes a secondary moving a

Indicator v5 Oscillators & momentumTrend
Updated 11 months ago · Custom licence GitHub repository of Supertrended RSI [AlgoAlpha]

This indicator computes and plots multiple technical analysis features on a separate pane. It calculates EMA-based trend indicators including fast and slow EMAs along with their slope, momentum oscillators such as RSI, Stochastic RSI, and MACD histogram, WaveT

Indicator v6 TrendOscillators & momentum
Updated yesterday · MIT GitHub repository of Vein Feature Exporter Core 4H [WavesUnchained]
3 stars

Short Term Alpha Indicator calculates a weighted alpha from price change multiplied by volume, then derives EMAs at fast, medium, and slow lengths. It computes ROC values for the EMAs and applies percentile rank functions to identify deviations. These deviatio

Indicator v5 Oscillators & momentumMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of Short Term Alpha Indicator

DMI Improve

by JohnsonHsiao
1 stars

This indicator improves the standard Directional Movement Index by adjusting plus and minus directional movement calculations with a weight factor and SMA adjustments for sensitivity. It calculates and plots improved DI+ and DI- lines in a separate pane. Setti

Indicator v5 TrendOscillators & momentum
Updated 3 years ago · None stated GitHub repository of DMI Improve

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers