Indicator · Pine Script v5 · On the chart

Modified Momentum QQE-ZigZag

by wynnforthework

This indicator blends a modified multi-timeframe RSI and Quantitative Qualitative Estimation (QQE) logic with an ATR-based Supertrend overlay on the price chart.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code142
Settings14inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago7 Oct 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

142 lines of Pine Script v5 from 策略/开源分享/Modified Momentum QQE-ZigZag趋势线.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Modified Momentum QQE-ZigZag趋势线.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5

indicator("Modified Momentum QQE-ZigZag [Non Repaint During Candle Building]", overlay = true, max_labels_count = 500)

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Input: RSI-QQE ZigZag
r1_type = input.string("Wilders", title = "Rsi-Type", options = ["Cutlers", "Wilders"], group = "ZigZag", inline = "R_0", tooltip = 'Choose between Cutlers and Wilders RSI')

r1_len = input.int(14, title = "Rsi-Len", group = "ZigZag", inline = "R_2")
r1_mtf = input.int(2, title = "Mtf-Mult", group = "ZigZag", inline = "R_2", tooltip = "==> Rsi-Len: Set the Length for the RSI\n==> Mtf-Mult: Length Multiplier for RSI to get MTF Resolution")

r1_mult = input.float(3, title = "QQe-Mult", group = "ZigZag", inline = "Q_1")
r1_smooth = input.int(1, title = "Smooth", group = "ZigZag", inline = "Q_1", tooltip = "==> QQE-Mult: Set the distance between QQE and RSI (works similar like Supertrend Mult)\n==> Rsi-Smooth: Smooth the Rsi with EMA")
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Input: Supertrend
s1_show = input.bool(true, title = "Show-Supertrend", group = "Supertrend", inline = "S_00")

s1_len = input.int(34, title = "Ma-Len", group = "Supertrend", inline = "S_1")
s1_type = input.string("EMA", title = "Ma-Type", options = ["SMA", "EMA", "HH / LL"], group = "Supertrend", inline = "S_1", tooltip = "==> MA-Len: Set the Length for the Base of the Supertend\n==> MA-Type: Choose the Base Type for the Supertrend")

s1_atr_len = input.int(34, title = "Atr-Len", group = "Supertrend", inline = "S_2")
s1_atr_mult = input.float(4.25, title = "Atr-Mult", group = "Supertrend", inline = "S_2", tooltip = "==> Atr-Len: Set the Length for the Atr\n==> Atr:Mult: Set the Multiplier for the ATR")

s1_incl = input.bool(true, title = "Include-ZigZag", group = "Supertrend", inline = "S_0", tooltip = "Wanna include the ZigZag in the Supertrend calculation?")

s1_bull = input.color(color.green, title = "UpTrend", group = "Supertrend", inline = "S_3")
s1_bear = input.color(color.red, title = "DownTrend", group = "Supertrend", inline = "S_3")
s1_line = input.int(1, title = "Line", group = "Supertrend", inline = "S_3")
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

//- Functions -//

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Function: Modified MTF Relative Strength Index
f_rsi(_src, _len, _mtf, _type)=>

    _change = _src - _src[_mtf]
    
    _up = math.max(_change, 0)
    _down = (-math.min(_change, 0))
    
    _up_change = _type == "Wilders" ? ta.rma(_up, (_len * _mtf)) :
                 _type == "Cutlers" ? ta.sma(_up, (_len * _mtf)) : na

    _down_change = _type == "Wilders" ? ta.rma(_down, (_len * _mtf)) :
                   _type == "Cutlers" ? ta.sma(_down, (_len * _mtf)) : na
    
    _rsi = _down_change == 0 ? 100 : 
           _up_change == 0 ? 0 : 
           100 - (100 / (1 + _up_change / _down_change))

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Function: ZigZag
f_zz(_dir, _high, _low)=>

    _up = _dir == 1
    _down = _dir == -1
    
    _peak = 0.0
    _peak := _high > _peak[1] and _up or _down[1] and _up ? _high : 
             nz(_peak[1])

    _bottom = 0.0
    _bottom := _low < _bottom[1] and _down or _up[1] and _down ? _low : 
               nz(_bottom[1])

    _zz = _up and _down[1] ? _bottom[1] : 
          _up[1] and _down ? _peak[1] : na
    _top = _down and _up[1] ? _peak[1] : na
    _bot = _up and _down[1] ? _bottom[1] : na
    [_zz, _top, _bot]

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Function: Modified QQE 
f_qqe(_len, _mtf, _type, _smooth, _atr_mult)=>
    
    _wilders =  _len * 2 - 1 
    
    _up = 0.0
    _up_rsi = f_rsi(low, _len, _mtf, _type)
    _up_ema = ta.ema(_up_rsi, _smooth)
    _up_atr = math.abs(_up_ema[1] - _up_ema)
    _up_diff = ta.ema(ta.ema(_up_atr, _wilders), _wilders) * _atr_mult
    _up_ma = _up_ema - _up_diff
    _up := _up_ema[1] > _up[1] and _up_ema > _up[1] ? math.max(_up_ma, _up[1]) : _up_ma
    
    _dn = 0.0
    _dn_rsi = f_rsi(high, _len, _mtf, _type)
    _dn_ema = ta.ema(_dn_rsi, _smooth)
    _dn_atr = math.abs(_dn_ema[1] - _dn_ema)
    _dn_diff = ta.ema(ta.ema(_dn_atr, _wilders), _wilders) * _atr_mult
    _dn_ma = _dn_ema + _dn_diff
    _dn := _dn_ema[1] < _dn[1] and _dn_ema < _dn[1] ? math.min(_dn_ma, _dn[1]) : _dn_ma
    
    _trend = 0
    _trend := ta.crossover(_dn_ema, _dn[1]) ? 1 : 
              ta.crossunder(_up_ema, _up[1]) ? -1 : 
              nz(_trend[1], _trend)

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Function: Supertrend
f_supertrend(_top, _bot, _incl, _len, _type, _atr_len, _atr_mult)=>
    
    _atr = ta.atr(_atr_len) * _atr_mult
    
    _up_ma = _type == "EMA" ? ta.ema(low[1], _len) : 
             _type == "SMA" ? ta.sma(low[1], _len) : 
             _type == "HH / LL" ? ta.lowest(low[1], _len) : na
    _up_b = _incl ? _bot[1] - _atr : na
    _up = _up_ma - _atr
    _up := low[1] > _up[1] ? math.max(_up, _up[1], nz(_up_b, _up - 1)) : _up
    
    _dn_ma = _type == "EMA" ? ta.ema(high[1], _len) : 
             _type == "SMA" ? ta.sma(high[1], _len) : 
             _type == "HH / LL" ? ta.highest(high[1], _len) : na
    _dn_t = _incl ? _top[1] + _atr : na
    _dn = _dn_ma + _atr
    _dn := high[1] < _dn[1] ? math.min(_dn, _dn[1], nz(_dn_t, _dn + 1)) : _dn
    
    _trend = 0
    _trend := ta.crossover(high[1], _dn[1]) ? 1 :
              ta.crossunder(low[1], _up[1]) ? -1 :
              nz(_trend[1], _trend)
    [_trend, _up, _dn]

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Calc: Rsi QQE ZigZag 
qqe_trend = f_qqe(r1_len, r1_mtf, r1_type, r1_smooth, r1_mult)
[zz, zz_top, zz_bot] = f_zz(qqe_trend, high, low)
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

// Calc: Supertrend
[s_trend, s_up, s_dn] = f_supertrend(zz_top, zz_bot, s1_incl, s1_len, s1_type, s1_atr_len, s1_atr_mult)

st_up = s_trend == 1 ? s_up : na
st_dn = s_trend == -1 ? s_dn : na
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Draw: Supertrend
plot(s1_show ? st_up : na, title = "Up-Trend", color = s1_bull, linewidth = s1_line, editable = true, style = plot.style_linebr)
plot(s1_show ? st_dn : na, title = "Down-Trend", color = s1_bear, linewidth = s1_line, editable = true, style = plot.style_linebr)
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//

Overview

Users can select between Wilders and Cutlers RSI calculations, adjust the multi-timeframe length multiplier, and set smoothing levels. The Supertrend component supports SMA, EMA, or highest high/lowest low base types, with configurable ATR length and multiplier. It plots dynamic trendlines colored according to bullish or bearish conditions directly over price action.

Details

Published by

wynnforthework on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum, 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.

Settings

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

SettingTypeDefaultVariable
Rsi-TypestringWildersr1_type
Rsi-Lenint14r1_len
Mtf-Multint2r1_mtf
QQe-Multfloat3r1_mult
Smoothint1r1_smooth
Show-Supertrendbooltrues1_show
Ma-Lenint34s1_len
Ma-TypestringEMAs1_type
Atr-Lenint34s1_atr_len
Atr-Multfloat4.25s1_atr_mult
Include-ZigZagbooltrues1_incl
UpTrendcolorcolor.greens1_bull
Show all 14 settings
SettingTypeDefaultVariable
DownTrendcolorcolor.reds1_bear
Lineint1s1_line
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

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
257 stars

An overlay indicator that combines an ATR-based SuperTrend trailing stop with an integrated RSI-derived midline calculation on the price chart. The SuperTrend uses an ATR period and factor multiplier to plot dynamic green or red trend lines based on price dire

Indicator v5 TrendVolatility & bands
Updated 6 weeks ago · None stated GitHub repository of SuperTrend ATR + RSI
114 stars

ADX Strategy (original) is an overlay indicator that identifies trend-following trade signals using the Average Directional Index (ADX) combined with a Simple Moving Average filter. A long signal is generated when the ADX rises above a user-defined trend level

Indicator v4 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Strategy (original)

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
56 stars

Double Screened Decision is a multi-timeframe trend and momentum indicator overlaid directly on the price chart. It dynamically selects a higher timeframe based on the active chart resolution to evaluate higher-timeframe MACD, Bollinger Bands, RSI, and Stochas

Indicator v5 TrendMoving averages Repaints
Updated 4 months ago · None stated GitHub repository of Double Screened Decision
55 stars

The VibeTrader Signal System is an overlay indicator that identifies trend direction and potential reversal conditions. It calculates a Supertrend line alongside Bollinger Bands and a 14-period RSI indicator. The script highlights bullish and bearish trends by

Indicator v6 TrendVolatility & bands
Updated 6 months ago · Apache-2.0 GitHub repository of VibeTrader Signal System

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