QQE (Quantitative Qualitative Estimation) for ThinkorSwim

QQE modified by Iconoclastic 9.28.2021 http://tos.mx/37iIknw
  • # QQE charts as Histogram
  • # includes 5 period ADXmod with paint strategy
  • # includes 8 period RSI with paint strategy
  • # ADXmod & RSI8 paintstrategy adapted to bullish(ness) when greater than ZeroLine
  • # Histogram Blue, RSI8 Green, and ADXmod LightBlue is strongest indicator / likelihood of increasing stock price
  • # Minus10 line is there for entries with greater risk, ADXmod bounce or cross above -10
a1.png

Shared Study Link: http://tos.mx/37iIknw Click here for --> Easiest way to load shared links
Ruby:
# QQE Indicator
# Converted by Kory Gill for BenTen at useThinkScript.com
# Original https://www.tradingview.com/script/zwbe2plA-Ghosty-s-Zero-Line-QQE/
# ****************************************
# Modified by Iconoclastic 9.28.2021
# QQE charts as Histogram
# includes 5 period ADXmod with paint strategy
# includes 8 period RSI with paint strategy
# ADXmod & RSI8 paintstrategy adapted to bullish(ness) when greater than ZeroLine
# Histogram Blue, RSI8 Green, and ADXmod LightBlue is strongest indicator / likelihood
# of increasing stock price
# Minus10 line is there for entries with greater risk, ADXmod bounce or cross above -10

declare lower;

input length = 5;
input price = HLC3;
input averageType = AverageType.WILDERS;


def ADX = DMI(length, averageType).ADX;
plot ADXmod = ADX - 40;
ADXmod.SetPaintingStrategy(PaintingStrategy.LINE);
ADXmod.SetLineWeight(4);
ADXmod.DefineColor("Up", CreateColor(128,212,255));
ADXmod.DefineColor("Down", Color.DARK_ORANGE);
ADXmod.AssignValueColor(
if ADXmod >= ADXmod[1] then ADXmod.Color("Up")
else ADXmod.Color("Down"));

# ********************

input RSIlength = 14;
input RSIprice = close;
input RSIaverageType = AverageType.WILDERS;
input showBreakoutSignals = no;

def NetChgAvg = MovingAverage(RSIaverageType, RSIprice - RSIprice[1], RSIlength);
def TotChgAvg = MovingAverage(RSIaverageType, AbsValue(RSIprice - RSIprice[1]), RSIlength);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI8 = (50 * (ChgRatio + 1))-40;
RSI8.SetPaintingStrategy(PaintingStrategy.LINE);
RSI8.SetLineWeight(3);
RSI8.DefineColor("Up", CreateColor(51,255,85));
RSI8.DefineColor("Down", Color.Gray);
RSI8.AssignValueColor(
if RSI8 >= 0 then RSI8.Color("Up")
else RSI8.Color("Down"));

# ********************


input RSI_Period = 8;
input Slow_Factor = 5;
input QQE = 4.236;

def Wilder_Period = RSI_Period * 2 - 1;
def vClose = close;

def rsi = RSI(price = vClose, length = RSI_Period).RSI;
def rsi_ma = MovingAverage(AverageType.EXPONENTIAL, rsi, Slow_Factor);
def atr_rsi = AbsValue(rsi_ma[1] - rsi_ma);
def atr_rsi_ma = MovingAverage(AverageType.EXPONENTIAL, atr_rsi, Wilder_Period);
def dar = MovingAverage(AverageType.EXPONENTIAL, atr_rsi_ma, Wilder_Period) * QQE;

def DeltaFastAtrRsi = dar;
def RSIndex = rsi_ma;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;

def longband = if RSIndex[1] > longband[1] and RSIndex > longband[1]
then max(longband[1],newlongband)
else newlongband;

def shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1]
then min(shortband[1], newshortband)
else newshortband;

def trend = if Crosses(RSIndex, shortband[1])
then 1
else if Crosses(longband[1], RSIndex)
then -1
else if !IsNAN(trend[1])
then trend[1]
else 1;

def FastAtrRsiTL = if trend == 1
then longband
else shortband;

plot pFastAtrRsiTL = FastAtrRsiTL;
pFastAtrRsiTL.Hide();
plot pRsiMa = rsi_ma;
pRsiMa.Hide();
plot Minus10 = -10;
plot Zero = 0;
Minus10.SetDefaultColor(Color.Light_Gray);
Zero.SetDefaultColor(Color.Light_Gray);
plot Diff = rsi_ma - 50;
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(4);
#plot line50 = 50;
Diff.DefineColor("Long", CreateColor(25,102,255));
Diff.DefineColor("Short", Color.Light_red);
Diff.DefineColor("Wait", Color.Light_Gray);

def condition1 = pRsiMa > 50 and pRsiMa > FastAtrRsiTL;
def condition2 = pRsiMa < 50 and pRsiMa < FastAtrRsiTL;

Diff.AssignValueColor(if condition1==1 then
Diff.Color("Long")
else if condition2==1 then
Diff.Color("Short")
else Diff.Color("Wait"));
# end code
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

How to scan
when QQE crosses up then its a buy indication and when it crosses down a sell indication.
 
Last edited by a moderator:
@BenTen I would really like this to be converted to TOS

I have used many variations of QQE but this one seems to be most accurate. not the best coder so I need help please.
Code:
//@version=4
//By Glaz, Modified
//
study("QQE MOD")
 
Last edited by a moderator:
@BenTen I would really like this to be converted to TOS

I have used many variations of QQE but this one seems to be most accurate. not the best coder so I need help please.
Code:
//@version=4
//By Glaz, Modified
//
study("QQE MOD")
RSI_Period = input(6, title='RSI Length')
SF = input(5, title='RSI Smoothing')
QQE = input(3, title='Fast QQE Factor')
ThreshHold = input(3, title="Thresh-hold")
//

src = input(close, title="RSI Source")
//

//
Wilders_Period = RSI_Period * 2 - 1


Rsi = rsi(src, RSI_Period)
RsiMa = ema(Rsi, SF)
AtrRsi = abs(RsiMa[1] - RsiMa)
MaAtrRsi = ema(AtrRsi, Wilders_Period)
dar = ema(MaAtrRsi, Wilders_Period) * QQE

longband = 0.0
shortband = 0.0
trend = 0

DeltaFastAtrRsi = dar
RSIndex = RsiMa
newshortband = RSIndex + DeltaFastAtrRsi
newlongband = RSIndex - DeltaFastAtrRsi
longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ?
max(longband[1], newlongband) : newlongband
shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ?
min(shortband[1], newshortband) : newshortband
cross_1 = cross(longband[1], RSIndex)
trend := cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1)
FastAtrRsiTL = trend == 1 ? longband : shortband
////////////////////


length = input(50, minval=1, title="Bollinger Length")
mult = input(0.35, minval=0.001, maxval=5, step=0.1, title="BB Multiplier")
basis = sma(FastAtrRsiTL - 50, length)
dev = mult * stdev(FastAtrRsiTL - 50, length)
upper = basis + dev
lower = basis - dev
color_bar = RsiMa - 50 > upper ? #00c3ff : RsiMa - 50 < lower ? #ff0062 : color.gray


//
// Zero cross
QQEzlong = 0
QQEzlong := nz(QQEzlong[1])
QQEzshort = 0
QQEzshort := nz(QQEzshort[1])
QQEzlong := RSIndex >= 50 ? QQEzlong + 1 : 0
QQEzshort := RSIndex < 50 ? QQEzshort + 1 : 0
//

Zero = hline(0, color=color.white, linestyle=hline.style_dotted, linewidth=1)

////////////////////////////////////////////////////////////////

RSI_Period2 = input(6, title='RSI Length')
SF2 = input(5, title='RSI Smoothing')
QQE2 = input(1.61, title='Fast QQE2 Factor')
ThreshHold2 = input(3, title="Thresh-hold")

src2 = input(close, title="RSI Source")
//

//
Wilders_Period2 = RSI_Period2 * 2 - 1


Rsi2 = rsi(src2, RSI_Period2)
RsiMa2 = ema(Rsi2, SF2)
AtrRsi2 = abs(RsiMa2[1] - RsiMa2)
MaAtrRsi2 = ema(AtrRsi2, Wilders_Period2)
dar2 = ema(MaAtrRsi2, Wilders_Period2) * QQE2
longband2 = 0.0
shortband2 = 0.0
trend2 = 0

DeltaFastAtrRsi2 = dar2
RSIndex2 = RsiMa2
newshortband2 = RSIndex2 + DeltaFastAtrRsi2
newlongband2 = RSIndex2 - DeltaFastAtrRsi2
longband2 := RSIndex2[1] > longband2[1] and RSIndex2 > longband2[1] ?
max(longband2[1], newlongband2) : newlongband2
shortband2 := RSIndex2[1] < shortband2[1] and RSIndex2 < shortband2[1] ?
min(shortband2[1], newshortband2) : newshortband2
cross_2 = cross(longband2[1], RSIndex2)
trend2 := cross(RSIndex2, shortband2[1]) ? 1 : cross_2 ? -1 : nz(trend2[1], 1)
FastAtrRsi2TL = trend2 == 1 ? longband2 : shortband2


//
// Zero cross
QQE2zlong = 0
QQE2zlong := nz(QQE2zlong[1])
QQE2zshort = 0
QQE2zshort := nz(QQE2zshort[1])
QQE2zlong := RSIndex2 >= 50 ? QQE2zlong + 1 : 0
QQE2zshort := RSIndex2 < 50 ? QQE2zshort + 1 : 0
//

hcolor2 = RsiMa2 - 50 > ThreshHold2 ? color.silver :
RsiMa2 - 50 < 0 - ThreshHold2 ? color.silver : na
plot(FastAtrRsi2TL - 50, title='QQE Line', color=color.white, transp=0, linewidth=2)
plot(RsiMa2 - 50, color=hcolor2, transp=50, title='Histo2', style=plot.style_columns)

Greenbar1 = RsiMa2 - 50 > ThreshHold2
Greenbar2 = RsiMa - 50 > upper

Redbar1 = RsiMa2 - 50 < 0 - ThreshHold2
Redbar2 = RsiMa - 50 < lower
plot(Greenbar1 and Greenbar2 == 1 ? RsiMa2 - 50 : na, title="QQE Up", style=plot.style_columns, color=#00c3ff, transp=0)
plot(Redbar1 and Redbar2 == 1 ? RsiMa2 - 50 : na, title="QQE Down", style=plot.style_columns, color=#ff0062, transp=0)
I believe the reason why it seems so accurate is that it's using two "Shorter" periods. The bars are being calculated by how far they're from the 50 line it seems.

Try using QQE on Tos with the settings.

Rsi = 6
SlowFactor = 3
QQE = 2.621

It should give you around the same results as the QQE version you showed.
 
@OptionsGOAT found this from somebody's share, not sure exactly what the source is, but I guess this is what you are looking for.

Ruby:
# QQE_Mod

declare lower;

input RSI_Length = 6;
input RSI_Smoothing = 5;
input Fast_QQE_Factor = 3.0;
input Threshold = 3;
input RSI_Source = close;
input RSI_Length2 = 6;
input RSI_Smoothing2 = 5;
input Fast_QQE_Factor2 = 1.61;
input Threshold2 = 3;
input RSI_Source2 = close;
input Bollinger_Length = 50;
input BB_Multiplier = 0.35; # min: 0.001, max: 5

# QQE 1
def Wilders_period = RSI_Length * 2 - 1;

def Rsi = RSI(price = RSI_Source, length = RSI_Length);
def RsiMa = MovAvgExponential(Rsi, RSI_Smoothing);
def AtrRsi = absValue(RsiMa[1] - RsiMa);
def MaAtrRsi = MovAvgExponential(AtrRsi, Wilders_Period);
def dar = MovAvgExponential(MaAtrRsi, Wilders_Period) * Fast_QQE_Factor;

def DeltaFastAtrRsi = dar;
def RSIndex = RsiMa;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;
def longband = if RSIndex[1] > longband[1] and RSIndex > longband[1] then max(longband[1], newlongband) else newlongband;
def shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1] then min(shortband[1], newshortband) else newshortband;
def cross_1 = Crosses(longband[1], RSIndex, CrossingDirection.ANY);
def trend = if Crosses(RSIndex, shortband[1], CrossingDirection.ANY) then 1 else if cross_1 then -1 else if isNaN(trend[1]) then 1 else trend[1];
def FastAtrRsiTL = if trend == 1 then longband else shortband;

# QQE 2
def Wilders_period2 = RSI_Length2 * 2 - 1;

def Rsi2 = RSI(price = RSI_Source2, length = RSI_Length2);
def RsiMa2 = MovAvgExponential(Rsi2, RSI_Smoothing2);
def AtrRsi2 = absValue(RsiMa2[1] - RsiMa2);
def MaAtrRsi2 = MovAvgExponential(AtrRsi2, Wilders_Period2);
def dar2 = MovAvgExponential(MaAtrRsi2, Wilders_Period2) * Fast_QQE_Factor;

def DeltaFastAtrRsi2 = dar2;
def RSIndex2 = RsiMa2;
def newshortband2 = RSIndex2 + DeltaFastAtrRsi2;
def newlongband2 = RSIndex2 - DeltaFastAtrRsi2;
def longband2 = if RSIndex2[1] > longband2[1] and RSIndex2 > longband2[1] then max(longband2[1], newlongband2) else newlongband2;
def shortband2 = if RSIndex2[1] < shortband2[1] and RSIndex2 < shortband2[1] then min(shortband2[1], newshortband2) else newshortband2;
def cross_2 = Crosses(longband2[1], RSIndex2, CrossingDirection.ANY);
def trend2 = if Crosses(RSIndex2, shortband2[1], CrossingDirection.ANY) then 1 else if cross_2 then -1 else if isNaN(trend2[1]) then 1 else trend2[1];
def FastAtrRsiTL2 = if trend2 == 1 then longband2 else shortband2;

# BB

def basis = SimpleMovingAvg(FastAtrRsiTL - 50, Bollinger_Length);
def dev = BB_Multiplier * stdev(FastAtrRsiTL - 50, Bollinger_Length);
def upper = basis + dev;
def lower = basis - dev;

# Ups and Downs

def Greenbar1 = RsiMa2 - 50 > Threshold2;
def Greenbar2 = RsiMa - 50 > upper;

def Redbar1 = RsiMa2 - 50 < 0 - Threshold2;
def Redbar2 = RsiMa - 50 < lower;

# Plots

plot Zero = 0;
Zero.SetDefaultColor(Color.WHITE);

plot QQE_Line = FastAtrRsiTL2 - 50;
QQE_Line.SetDefaultColor(Color.WHITE);
QQE_Line.SetLineWeight(2);

plot Hist = RsiMa2 - 50;
Hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Hist.SetLineWeight(4);
Hist.AssignValueColor(
    if Greenbar1 and Greenbar2 == 1 then CreateColor(0, 195, 255)
    else if Redbar1 and Redbar2 == 1 then CreateColor(255, 0, 98)
    else if RsiMa2 - 50 > Threshold2 then Color.DARK_GRAY
    else if RsiMa2 - 50 < 0 - Threshold2 then Color.DARK_GRAY
    else Color.BLACK
);
 
The script https://usethinkscript.com/threads/...imation-for-thinkorswim.938/page-2#post-77353 that belongs to the image that you posted does not include any code to paint the 'candles colours.".

if you are asking about the histogram colors, they are based on a moving average of a 5 length RSI
If the RSI_ma is greater than 50 and if the ma of RSI_ma - absValue(rsi_ma[1] - rsi_ma) crosses RSI_ma then blue else if the opposite the red. If neither than gray.
im talking about candles colors. i was thinking that theres a colors rules plotted. thank you man!!!! I'm really lovin' it
 
this is a very good indicator! I will use next week to try but I already hear the sound of the money!!! thanks BenTen. I just would like to know this number come from where QQE = 4.236;?

QQE = 4.236 is a multiplier. Just as you have multipliers when you use the ADX, etc… They are set to optimize the script in relation to the other settings.

The two most common QQE settings that members seem to gravitate to are the settings you are currently using and the other is:
Rsi = 6
SlowFactor = 3
QQE = 2.621
 
Last edited:
hello is this above code available? could you direct me thanks
Here you go

Code:
#Break 20EMA Signal

input length = 20;

plot AvgExp = ExpAverage(close, length);
AvgExp.HideTitle();
AvgExp.HideBubble();

def UpSignal = if close[1] crosses below AvgExp and close crosses above AvgExp or close crosses above AvgExp then 1 else 0;
def DnSignal = if close[1] crosses above AvgExp and close crosses below AvgExp or close crosses below AvgExp then 1 else 0;

AssignPriceColor(if UpSignal or DnSignal then CreateColor(0,130,211) else Color.CURRENT);

def prange = high - low;
def phigh = high + prange * .2;
def plow = low - prange * .2;

def SignUpDn = if UpSignal or DnSignal then 1 else if SignUpDn[1] == 1 and UpSignal or DnSignal then 1 else 0;

def debug = yes;
plot x = if !debug then Double.NAN else SignUpDn;
x.Hide();

## Yellow Point Signal ##
plot SignUpDt = if UpSignal and signUpDn[-1] == 0 then plow else if DnSignal and signUpDn[-1] == 0 then phigh else Double.NaN;
SignUpDt.SetDefaultColor(Color.YELLOW);
SignUpDt.SetStyle(Curve.POINTS);
SignUpDt.SetLineWeight(3);
SignUpDt.HideTitle();
SignUpDt.HideBubble();
 
I having a displaying issue here and I just trying understand why it showing like this? the signal on this indicator displaying under the line50 when I put some color on it, I try few ways but not look at the moment? any advice what could I missing?

Code:
def FastAtrRsiTL = if trend == 1 then longband else shortband;
plot pFastAtrRsiTL = FastAtrRsiTL;
pFastAtrRsiTL.SetDefaultColor(CreateColor(60,115,144));
pFastAtrRsiTL.SetStyle(Curve.SHORT_DASH);
pFastAtrRsiTL.HideBubble();
pFastAtrRsiTL.HideTitle();

def line50 = 50;

plot pRsiMa = rsi_ma;
pRsiMa.SetDefaultColor(CreateColor(204,0,204));
pRsiMa.SetLineWeight(2);
pRsiMa.HideBubble();
pRsiMa.HideTitle();

plot colft = line50;
colft.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
colft.AssignValueColor(if pFastAtrRsiTL > pRsiMa then Color.RED else if pFastAtrRsiTL < pRsiMa then Color.GREEN else Color.DARK_GRAY);
colft.SetLineWeight(2);
colft.HideTitle();

 
QQE Indicator Scan

Code:
# QQE Indicator Scan
# Converted by Kory Gill for BenTen at useThinkScript.com
# Original https://www.tradingview.com/script/zwbe2plA-Ghosty-s-Zero-Line-QQE/
# Pensar - modified into scan with 4 different choices -

input RSI_Period = 20;
input Slow_Factor = 5;
input QQE = 4.236;

def Wilder_Period = RSI_Period * 2 - 1;
def vClose = close;

def rsi = RSI(price = vClose, length = RSI_Period).RSI;
def rsi_ma = MovingAverage(AverageType.EXPONENTIAL, rsi, Slow_Factor);
def atr_rsi = AbsValue(rsi_ma[1] - rsi_ma);
def atr_rsi_ma = MovingAverage(AverageType.EXPONENTIAL, atr_rsi, Wilder_Period);
def dar = MovingAverage(AverageType.EXPONENTIAL, atr_rsi_ma, Wilder_Period) * QQE;

def DeltaFastAtrRsi = dar;
def RSIndex = rsi_ma;
def newshortband =  RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;

def longband = if RSIndex[1] > longband[1] and RSIndex > longband[1]
               then max(longband[1],newlongband)
               else newlongband;

def shortband = if RSIndex[1] < shortband[1] and  RSIndex < shortband[1]
                then min(shortband[1], newshortband)
                else newshortband;

def trend = if Crosses(RSIndex, shortband[1])
            then 1
            else if Crosses(longband[1], RSIndex)
            then -1
            else if !IsNAN(trend[1])
            then trend[1]
            else 1;

def FastAtrRsiTL = if trend == 1 then longband else shortband;

plot CrossAbove = if rsi_ma crosses above FastAtrRsiTL then 1 else 0;
#plot CrossBelow = if rsi_ma crosses below FastAtrRsiTL then 1 else 0;
#plot Above = if rsi_ma > FastAtrRsiTL then 1 else 0;
#plot Below = if rsi_ma < FastAtrRsiTL then 1 else 0;

# end scan

Here's a picture of what the scan is doing - it visually shows each choice that you can scan for.

QQE.png
Pensar, Thank you for the Scan Script. When I ran the Scan today Jan20-22, get only "Bullish" results, 17 Stocks. Is this due to current market condition or this scan is for only "longTrades"? Please post for short trades also.
 
Pensar, Thank you for the Scan Script. When I ran the Scan today Jan20-22, get only "Bullish" results, 17 Stocks. Is this due to current market condition or this scan is for only "longTrades"? Please post for short trades also.
for Bearish scan, you need to add another study in you scan setup and change this 2 line

Code:
#plot CrossAbove = if rsi_ma crosses above FastAtrRsiTL then 1 else 0;
plot CrossBelow = if rsi_ma crosses below FastAtrRsiTL then 1 else 0;

this way you can scan both way!
 
Thread starter Similar threads Forum Replies Date
Xiuying QQE MTF (Multi Timeframe) for ThinkorSwim Indicators 20

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
301 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top