• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

QQE (Quantitative Qualitative Estimation) for ThinkorSwim

Xiuying

New member
Hello all. I like this QQE indicator thus far. Have anyone able to write a scanner thinkscript to scan when the 2 lines crossed (daily timeframe)?
You can't scan for that sadly, because of how the Short/Long band are coded. You can however search for when the Prsima crosses anything (Besides the other line) . So a 50 cross, oversold cross, overbought, etc etc

You can also do Watchlist Custom Columns and use them in your scan results if you want.
 

Pensar

Well-known member
VIP
I'm not certain why there seems to be problems scanning, this worked fine

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.

 

Xiuying

New member
I'm not certain why there seems to be problems scanning, this worked fine

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.

Could you do it again and show the results from the scan ? There are no issues in showing the results on the actual chart itself of a crossover, it's the actual SCAN that there are issues with.

I tripled checked my own scan and then took the exact code you posted and attempted a scan. Zero results.

Been trying on/off for the past few months to get a scan working, so if you actually have a working one, I'd be excited asf ,lol.
 

Pensar

Well-known member
VIP
@Xiuying I absolutely have no idea why it generates results for me yet doesn't work for you. Given that I'm scanning in the "All Listed Stocks" category, it takes about 30-45 seconds to load results - it would be faster if the scan is run against far fewer stocks. Maybe reset the scan page to default and then try it? I'm out of ideas.
Been trying on/off for the past few months to get a scan working, so if you actually have a working one, I'd be excited asf ,lol.
The good news is you can be excited . . . I do have a working scan! 😁
 

Xiuying

New member
@Xiuying I absolutely have no idea why it generates results for me yet doesn't work for you. Given that I'm scanning in the "All Listed Stocks" category, it takes about 30-45 seconds to load results - it would be faster if the scan is run against far fewer stocks. Maybe reset the scan page to default and then try it? I'm out of ideas.

The good news is you can be excited . . . I do have a working scan! 😁
I've tried doing it exactly as I see you have and have also tried setting it up for scanning less and even just my watchlist which I know has had crosses.

Could you by chance share the scan via the top right button ? If for some reason the actual scan link ends up giving me zero results as well, then I'm going to start wondering if it's a software or account issue on my end.

I am excited but also angry and confused, all at the same time, lol.
 

Pensar

Well-known member
VIP
@Xiuying I usually don't do share links . . . perhaps someone else may be willing to post one. The result will be not likely be any different.
 

tem2005

Member
VIP
@FOTM_8888 Here you go:

Code:
# QQE Indicator
# Converted by Kory Gill for BenTen at useThinkScript.com
# Original https://www.tradingview.com/script/zwbe2plA-Ghosty-s-Zero-Line-QQE/

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;

def pFastAtrRsiTL = FastAtrRsiTL;
def pRsiMa = rsi_ma;
def line50 = 50;

plot UpSignal = if pRSIMA crosses above pFastAtrRsiTL then low else Double.NaN;
plot DownSignal = if pRSIMA crosses below pFastAtrRsiTL then high else Double.NaN;

UpSignal.SetDefaultColor(Color.MAGENTA);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.CYAN);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
@BenTen would this code work real time with no delay or repaint for daily chart for swing?
 

MerryDay

Well-known member
VIP
@tem2005 To determine if a script will repaint, you need to look at the code.
Statements with HighestAll/LowestAll or have fold operations in combination with high/lows have a high probability of repainting.
Because think about it: If a stock hits a low, then it will paint that the condition as true but as the stock continues lower, that low is no longer "the low" so it erases it and states that the new candle is the new low.

In answer to your question, I see none of that logic in this script so no repainting. As far as delays, this study uses the RSI which is a lagging indicator as are most technical indicators unless they repaint. One of the few positives of repainting indicators is that they are generally much faster while also being unreliable. It is a trade-off.
 

Xiuying

New member
Thread starter Similar threads Forum Replies Date
Xiuying QQE MTF (Multi Timeframe) for ThinkorSwim Indicators 15

Similar threads

Top