Smart QQE Mod for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
PVJQvKa.png


Creator Message: https://www.tradingview.com/v/X72V8xjH/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © traderharikrishna
#https://www.tradingview.com/v/X72V8xjH/
#indicator("Smart QQE",overlay=true)
#// Credits to Glaz
#// Rescaled for overlay by @traderharikrishna
# Converted by Sam4Cok@Samer800    - 03/2023
input ColorBars = yes;    # 'color bars?'
input ShowRsiCloud = yes;
input src = close;        # 'RSI Source'
input rsiMaType1 = {SMA, default EMA, RMA, WMA, VWMA, DEMA, TEMA, HMA, ALMA, SWMA, PEMA, LSMA};
input RSI_Period1 = 14;   # 'RSI Length'
input rsiMaType2 = {"EMA", "HMA", default "SMA", "WMA", "RMA", "VWMA"};    # 'RSI MA Type'
input RSI_Period2 = 50;   # 'RSI 100 level'
input RsiSmoothing = 5;             # 'RSI Smoothing'
input FastQqeFactor = 4.238;        # 'Fast QQE Factor'
input ThreshHold = 10;    # 'Thresh-hold'
input alma_offset = 0.85; # '* Arnaud Legoux (ALMA) Only - Offset Value'
input alma_sigma = 6;     # '* Arnaud Legoux (ALMA) Only - Sigma Value'


def na = Double.NaN;
#---- Color
DefineGlobalColor("blue"   , CreateColor(7, 196, 243));
DefineGlobalColor("red"    , CreateColor(247, 4, 117));
DefineGlobalColor("orange" , CreateColor(255, 152, 0));
DefineGlobalColor("dgreen" , CreateColor(20, 78, 05));
DefineGlobalColor("dred"   , CreateColor(134, 3, 3));
DefineGlobalColor("yellow" , CreateColor(241,226,14));
#// ] -------------- FUNCTIONS : Moving Avg ------------------ [
script nz {
    input data  = close;
    input repl  = 0;
    def ret_val = if !IsNaN(data) then data else repl;
    plot return = ret_val;
}
#pine_swma(source) =>
script swma {
    input source = close;
    def swma = source[3] * 1 / 6 + source[2] * 2 / 6 +  source[1] * 2 / 6 + source[0] * 1 / 6;
    plot retun = swma;
}
#pine_alma(series, windowsize, offset, sigma) =>
script ALMA {
    input series = close;
    input windowsize = 9;
    input Offset = 0.85;
    input Sigma = 6;
    def m = Offset * (windowsize - 1);
    def s = windowsize / Sigma;
    def norm  = fold z = 0 to windowsize with CW do
         CW + Exp(-(Sqr(z - m)) / (2 * Sqr(s)));
    def sum  = fold y = 0 to windowsize with WS do
         WS + Exp(-(Sqr(y - m)) / (2 * Sqr(s))) * GetValue(series, windowsize - 1 - y);
    plot ALMA = sum  / norm ;
}
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    def v = volume;
    def VWMA = SimpleMovingAvg(src * nz(v, 1), len) / SimpleMovingAvg(nz(v, 1), len);
    plot result = VWMA;
}
#export multiMa(float source, simple int length, string type) =>
script Ma {
    input type = "SMA";
    input source = close;
    input length = 14;
    input alma_offset = 0.85;
    input alma_sigma  = 6;
    def ema1 = ExpAverage(source, length);
    def ema2 = ExpAverage(ema1, length);
    def ema3 = ExpAverage(ema2, length);
    def ema4 = ExpAverage(ema3, length);
    def ema5 = ExpAverage(ema4, length);
    def ema6 = ExpAverage(ema5, length);
    def ema7 = ExpAverage(ema6, length);
    def ema8 = ExpAverage(ema7, length);
    def pema = 8 * ema1 - 28 * ema2 + 56 * ema3 - 70 * ema4 + 56 * ema5 - 28 * ema6 + 8 * ema7 - ema8;
    def multiMa =
        if type == "SMA"  then SimpleMovingAvg(source, length) else
        if type == "EMA"  then ExpAverage(source, length) else
        if type == "RMA"  then WildersAverage(source, length) else
        if type == "WMA"  then WMA(source, length) else
        if type == "VWMA" then vwma(source, length) else
        if type == "DEMA" then DEMA(source, length) else
        if type == "TEMA" then TEMA(source, length) else
        if type == "LSMA" then Inertia(source, length) else
        if type == "PEMA" then pema else
        if type == "ALMA" then ALMA(source, length, alma_offset, alma_sigma) else
        if type == "SWMA" then SWMA(source) else
        if type == "HMA"  then HullMovingAvg(source, length) else Double.NaN;
    plot return = multiMa;
}
def Wilders_Period = RSI_Period1 * 2 - 1;
def Rsi = RSI(PRICE = src, LENGTH = RSI_Period1);
def RsiMa = Ma(rsiMaType1, Rsi, RsiSmoothing , alma_offset, alma_sigma);
def AtrRsi = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = Ma(rsiMaType1, AtrRsi, Wilders_Period, alma_offset, alma_sigma);
def dar = Ma(rsiMaType1, MaAtrRsi, Wilders_Period, alma_offset, alma_sigma) * FastQqeFactor;

def longband;# = 0.0
def shortband;# = 0.0
def trendx;# = 0

def DeltaFastAtrRsi = dar;
def RSIndex = RsiMa;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;
longband = if RSIndex[1] > longband[1] and RSIndex > longband[1] then Max(longband[1], newlongband) else newlongband;
shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1] then Min(shortband[1], newshortband) else newshortband;
def cross_1 = Crosses(longband[1], RSIndex);
trendx  = if Crosses(RSIndex, shortband[1]) then 1 else if cross_1 then -1 else nz(trendx[1], 1);
def FastAtrRsiTL = if trendx == 1 then longband else shortband;

#//
#// Find all the QQE Crosses
def QQExlong;# = 0
def QQExshort;# = 0
def QQExlong1  = nz(QQExlong[1]);
def QQExshort1 = nz(QQExshort[1]);
QQExlong   = if FastAtrRsiTL < RSIndex then QQExlong1 + 1 else 0;
QQExshort  = if FastAtrRsiTL > RSIndex then QQExshort1 + 1 else 0;

def hcolor = if RsiMa - 50 > ThreshHold then 1 else
             if RsiMa - 50 < 0 - ThreshHold then -1 else 0;

#//EOF
AssignPriceColor(if !ColorBars then Color.CURRENT else
                 if hcolor > 0 then GlobalColor("blue") else
                 if hcolor < 0 then GlobalColor("red") else GlobalColor("orange"));

def nATR   = ATR(Length = 100);
def orsi   = RSI(PRICE = close, LENGTH = RSI_Period1);
def adjrsi = close + nATR * orsi / 100;

def rma = Ma(rsiMaType2, adjrsi, RSI_Period2);
def rsi100 = rma + nATR * (50 / 10);
def rsi0 = rma - nATR * (50 / 10);
def r100 = rsi100;
def r0 = rsi0;
def rsi90 = rma + nATR * (30 / 10);
def rsi10 = rma - nATR * (30 / 10);
def r90 = rsi90;
def r10 = rsi10;

AddCloud(r100, r90, Color.DARK_RED, Color.DARK_RED, yes);      # 'Overbought'
AddCloud(r10, r0, Color.DARK_GREEN, Color.DARK_GREEN, yes);    # 'Oversold'


plot midBand = rma;
midBand.AssignValueColor(if open>rma then GlobalColor("blue") else if open<rma then Color.RED else GlobalColor("yellow"));
def rsim = rma + nATR * (RsiMa - 50) / 10;

def frsim = rma + nATR * (FastAtrRsiTL - 50) / 10;
def QQE_RSI = if ShowRsiCloud then Ma(rsiMaType1, rsim, RsiSmoothing) else na;
def Fast_RSI = Ma(rsiMaType1, frsim, RsiSmoothing);

AddCloud(QQE_RSI,Fast_RSI,GlobalColor("dgreen"), GlobalColor("dred"));    # 'QQE Trend'

def qqeLong = if QQExlong == 1 then frsim else na;
def qqeShort = if QQExshort == 1 then frsim else na;

AddChartBubble(qqeLong,low, "Long", Color.GREEN, no);
AddChartBubble(qqeShort, high, "Short", Color.RED, yes);


#--- END CODE
 
Last edited by a moderator:

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

Is this backtested?

I’m not sure if auto does it too without share number manipulation. Anyway, I already know how to handle it. I was wondering if anyone manually tested this strategy in their own trading. Auto trading doesn’t always reflect real results.
 
Last edited by a moderator:
Is this backtested?

This script was converted from Tradingview. You can find out more at the below link:

If you are asking how to turn this script into a strategy for backtesting, add the following to the end of your script:
Ruby:
AddOrder(OrderType.BUY_TO_OPEN, qqeLong);
AddOrder(OrderType.SELL_TO_CLOSE, qqeShort);

OR
You can change your ordertype:
OrderType.BUY_AUTO
OrderType.Sell_AUTO
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/OrderType

I was wondering if anyone manually tested this strategy in their own trading. Auto trading doesn’t always reflect real results.
The indicator was posted on this forum just this past Thursday, so the answer is probably, no.
 
Last edited:
PVJQvKa.png


Creator Message: https://www.tradingview.com/v/X72V8xjH/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © traderharikrishna
#https://www.tradingview.com/v/X72V8xjH/
#indicator("Smart QQE",overlay=true)
#// Credits to Glaz
#// Rescaled for overlay by @traderharikrishna
# Converted by Sam4Cok@Samer800    - 03/2023
input ColorBars = yes;    # 'color bars?'
input ShowRsiCloud = yes;
input src = close;        # 'RSI Source'
input rsiMaType1 = {SMA, default EMA, RMA, WMA, VWMA, DEMA, TEMA, HMA, ALMA, SWMA, PEMA, LSMA};
input RSI_Period1 = 14;   # 'RSI Length'
input rsiMaType2 = {"EMA", "HMA", default "SMA", "WMA", "RMA", "VWMA"};    # 'RSI MA Type'
input RSI_Period2 = 50;   # 'RSI 100 level'
input RsiSmoothing = 5;             # 'RSI Smoothing'
input FastQqeFactor = 4.238;        # 'Fast QQE Factor'
input ThreshHold = 10;    # 'Thresh-hold'
input alma_offset = 0.85; # '* Arnaud Legoux (ALMA) Only - Offset Value'
input alma_sigma = 6;     # '* Arnaud Legoux (ALMA) Only - Sigma Value'


def na = Double.NaN;
#---- Color
DefineGlobalColor("blue"   , CreateColor(7, 196, 243));
DefineGlobalColor("red"    , CreateColor(247, 4, 117));
DefineGlobalColor("orange" , CreateColor(255, 152, 0));
DefineGlobalColor("dgreen" , CreateColor(20, 78, 05));
DefineGlobalColor("dred"   , CreateColor(134, 3, 3));
DefineGlobalColor("yellow" , CreateColor(241,226,14));
#// ] -------------- FUNCTIONS : Moving Avg ------------------ [
script nz {
    input data  = close;
    input repl  = 0;
    def ret_val = if !IsNaN(data) then data else repl;
    plot return = ret_val;
}
#pine_swma(source) =>
script swma {
    input source = close;
    def swma = source[3] * 1 / 6 + source[2] * 2 / 6 +  source[1] * 2 / 6 + source[0] * 1 / 6;
    plot retun = swma;
}
#pine_alma(series, windowsize, offset, sigma) =>
script ALMA {
    input series = close;
    input windowsize = 9;
    input Offset = 0.85;
    input Sigma = 6;
    def m = Offset * (windowsize - 1);
    def s = windowsize / Sigma;
    def norm  = fold z = 0 to windowsize with CW do
         CW + Exp(-(Sqr(z - m)) / (2 * Sqr(s)));
    def sum  = fold y = 0 to windowsize with WS do
         WS + Exp(-(Sqr(y - m)) / (2 * Sqr(s))) * GetValue(series, windowsize - 1 - y);
    plot ALMA = sum  / norm ;
}
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    def v = volume;
    def VWMA = SimpleMovingAvg(src * nz(v, 1), len) / SimpleMovingAvg(nz(v, 1), len);
    plot result = VWMA;
}
#export multiMa(float source, simple int length, string type) =>
script Ma {
    input type = "SMA";
    input source = close;
    input length = 14;
    input alma_offset = 0.85;
    input alma_sigma  = 6;
    def ema1 = ExpAverage(source, length);
    def ema2 = ExpAverage(ema1, length);
    def ema3 = ExpAverage(ema2, length);
    def ema4 = ExpAverage(ema3, length);
    def ema5 = ExpAverage(ema4, length);
    def ema6 = ExpAverage(ema5, length);
    def ema7 = ExpAverage(ema6, length);
    def ema8 = ExpAverage(ema7, length);
    def pema = 8 * ema1 - 28 * ema2 + 56 * ema3 - 70 * ema4 + 56 * ema5 - 28 * ema6 + 8 * ema7 - ema8;
    def multiMa =
        if type == "SMA"  then SimpleMovingAvg(source, length) else
        if type == "EMA"  then ExpAverage(source, length) else
        if type == "RMA"  then WildersAverage(source, length) else
        if type == "WMA"  then WMA(source, length) else
        if type == "VWMA" then vwma(source, length) else
        if type == "DEMA" then DEMA(source, length) else
        if type == "TEMA" then TEMA(source, length) else
        if type == "LSMA" then Inertia(source, length) else
        if type == "PEMA" then pema else
        if type == "ALMA" then ALMA(source, length, alma_offset, alma_sigma) else
        if type == "SWMA" then SWMA(source) else
        if type == "HMA"  then HullMovingAvg(source, length) else Double.NaN;
    plot return = multiMa;
}
def Wilders_Period = RSI_Period1 * 2 - 1;
def Rsi = RSI(PRICE = src, LENGTH = RSI_Period1);
def RsiMa = Ma(rsiMaType1, Rsi, RsiSmoothing , alma_offset, alma_sigma);
def AtrRsi = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = Ma(rsiMaType1, AtrRsi, Wilders_Period, alma_offset, alma_sigma);
def dar = Ma(rsiMaType1, MaAtrRsi, Wilders_Period, alma_offset, alma_sigma) * FastQqeFactor;

def longband;# = 0.0
def shortband;# = 0.0
def trendx;# = 0

def DeltaFastAtrRsi = dar;
def RSIndex = RsiMa;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;
longband = if RSIndex[1] > longband[1] and RSIndex > longband[1] then Max(longband[1], newlongband) else newlongband;
shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1] then Min(shortband[1], newshortband) else newshortband;
def cross_1 = Crosses(longband[1], RSIndex);
trendx  = if Crosses(RSIndex, shortband[1]) then 1 else if cross_1 then -1 else nz(trendx[1], 1);
def FastAtrRsiTL = if trendx == 1 then longband else shortband;

#//
#// Find all the QQE Crosses
def QQExlong;# = 0
def QQExshort;# = 0
def QQExlong1  = nz(QQExlong[1]);
def QQExshort1 = nz(QQExshort[1]);
QQExlong   = if FastAtrRsiTL < RSIndex then QQExlong1 + 1 else 0;
QQExshort  = if FastAtrRsiTL > RSIndex then QQExshort1 + 1 else 0;

def hcolor = if RsiMa - 50 > ThreshHold then 1 else
             if RsiMa - 50 < 0 - ThreshHold then -1 else 0;

#//EOF
AssignPriceColor(if !ColorBars then Color.CURRENT else
                 if hcolor > 0 then GlobalColor("blue") else
                 if hcolor < 0 then GlobalColor("red") else GlobalColor("orange"));

def nATR   = ATR(Length = 100);
def orsi   = RSI(PRICE = close, LENGTH = RSI_Period1);
def adjrsi = close + nATR * orsi / 100;

def rma = Ma(rsiMaType2, adjrsi, RSI_Period2);
def rsi100 = rma + nATR * (50 / 10);
def rsi0 = rma - nATR * (50 / 10);
def r100 = rsi100;
def r0 = rsi0;
def rsi90 = rma + nATR * (30 / 10);
def rsi10 = rma - nATR * (30 / 10);
def r90 = rsi90;
def r10 = rsi10;

AddCloud(r100, r90, Color.DARK_RED, Color.DARK_RED, yes);      # 'Overbought'
AddCloud(r10, r0, Color.DARK_GREEN, Color.DARK_GREEN, yes);    # 'Oversold'


plot midBand = rma;
midBand.AssignValueColor(if open>rma then GlobalColor("blue") else if open<rma then Color.RED else GlobalColor("yellow"));
def rsim = rma + nATR * (RsiMa - 50) / 10;

def frsim = rma + nATR * (FastAtrRsiTL - 50) / 10;
def QQE_RSI = if ShowRsiCloud then Ma(rsiMaType1, rsim, RsiSmoothing) else na;
def Fast_RSI = Ma(rsiMaType1, frsim, RsiSmoothing);

AddCloud(QQE_RSI,Fast_RSI,GlobalColor("dgreen"), GlobalColor("dred"));    # 'QQE Trend'

def qqeLong = if QQExlong == 1 then frsim else na;
def qqeShort = if QQExshort == 1 then frsim else na;

AddChartBubble(qqeLong,low, "Long", Color.GREEN, no);
AddChartBubble(qqeShort, high, "Short", Color.RED, yes);


#--- END CODE
Does this code repaint and if so, does it matter if Im using it in the daily timeframe as my main timeframe?
 
Does this code repaint and if so, does it matter if Im using it in the daily timeframe as my main timeframe?
I have not worked with this code.
A casual perusal did not find any obvious repainting code.
As with most indicators the current candle will repaint until closed.

If you're encountering something that's giving you some worries. We need you to give us more information. Could you elaborate on what you're seeing? The more details you can provide, the better we'll be able to assist you.
 
PVJQvKa.png


Creator Message: https://www.tradingview.com/v/X72V8xjH/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © traderharikrishna
#https://www.tradingview.com/v/X72V8xjH/
#indicator("Smart QQE",overlay=true)
#// Credits to Glaz
#// Rescaled for overlay by @traderharikrishna
# Converted by Sam4Cok@Samer800    - 03/2023
input ColorBars = yes;    # 'color bars?'
input ShowRsiCloud = yes;
input src = close;        # 'RSI Source'
input rsiMaType1 = {SMA, default EMA, RMA, WMA, VWMA, DEMA, TEMA, HMA, ALMA, SWMA, PEMA, LSMA};
input RSI_Period1 = 14;   # 'RSI Length'
input rsiMaType2 = {"EMA", "HMA", default "SMA", "WMA", "RMA", "VWMA"};    # 'RSI MA Type'
input RSI_Period2 = 50;   # 'RSI 100 level'
input RsiSmoothing = 5;             # 'RSI Smoothing'
input FastQqeFactor = 4.238;        # 'Fast QQE Factor'
input ThreshHold = 10;    # 'Thresh-hold'
input alma_offset = 0.85; # '* Arnaud Legoux (ALMA) Only - Offset Value'
input alma_sigma = 6;     # '* Arnaud Legoux (ALMA) Only - Sigma Value'


def na = Double.NaN;
#---- Color
DefineGlobalColor("blue"   , CreateColor(7, 196, 243));
DefineGlobalColor("red"    , CreateColor(247, 4, 117));
DefineGlobalColor("orange" , CreateColor(255, 152, 0));
DefineGlobalColor("dgreen" , CreateColor(20, 78, 05));
DefineGlobalColor("dred"   , CreateColor(134, 3, 3));
DefineGlobalColor("yellow" , CreateColor(241,226,14));
#// ] -------------- FUNCTIONS : Moving Avg ------------------ [
script nz {
    input data  = close;
    input repl  = 0;
    def ret_val = if !IsNaN(data) then data else repl;
    plot return = ret_val;
}
#pine_swma(source) =>
script swma {
    input source = close;
    def swma = source[3] * 1 / 6 + source[2] * 2 / 6 +  source[1] * 2 / 6 + source[0] * 1 / 6;
    plot retun = swma;
}
#pine_alma(series, windowsize, offset, sigma) =>
script ALMA {
    input series = close;
    input windowsize = 9;
    input Offset = 0.85;
    input Sigma = 6;
    def m = Offset * (windowsize - 1);
    def s = windowsize / Sigma;
    def norm  = fold z = 0 to windowsize with CW do
         CW + Exp(-(Sqr(z - m)) / (2 * Sqr(s)));
    def sum  = fold y = 0 to windowsize with WS do
         WS + Exp(-(Sqr(y - m)) / (2 * Sqr(s))) * GetValue(series, windowsize - 1 - y);
    plot ALMA = sum  / norm ;
}
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    def v = volume;
    def VWMA = SimpleMovingAvg(src * nz(v, 1), len) / SimpleMovingAvg(nz(v, 1), len);
    plot result = VWMA;
}
#export multiMa(float source, simple int length, string type) =>
script Ma {
    input type = "SMA";
    input source = close;
    input length = 14;
    input alma_offset = 0.85;
    input alma_sigma  = 6;
    def ema1 = ExpAverage(source, length);
    def ema2 = ExpAverage(ema1, length);
    def ema3 = ExpAverage(ema2, length);
    def ema4 = ExpAverage(ema3, length);
    def ema5 = ExpAverage(ema4, length);
    def ema6 = ExpAverage(ema5, length);
    def ema7 = ExpAverage(ema6, length);
    def ema8 = ExpAverage(ema7, length);
    def pema = 8 * ema1 - 28 * ema2 + 56 * ema3 - 70 * ema4 + 56 * ema5 - 28 * ema6 + 8 * ema7 - ema8;
    def multiMa =
        if type == "SMA"  then SimpleMovingAvg(source, length) else
        if type == "EMA"  then ExpAverage(source, length) else
        if type == "RMA"  then WildersAverage(source, length) else
        if type == "WMA"  then WMA(source, length) else
        if type == "VWMA" then vwma(source, length) else
        if type == "DEMA" then DEMA(source, length) else
        if type == "TEMA" then TEMA(source, length) else
        if type == "LSMA" then Inertia(source, length) else
        if type == "PEMA" then pema else
        if type == "ALMA" then ALMA(source, length, alma_offset, alma_sigma) else
        if type == "SWMA" then SWMA(source) else
        if type == "HMA"  then HullMovingAvg(source, length) else Double.NaN;
    plot return = multiMa;
}
def Wilders_Period = RSI_Period1 * 2 - 1;
def Rsi = RSI(PRICE = src, LENGTH = RSI_Period1);
def RsiMa = Ma(rsiMaType1, Rsi, RsiSmoothing , alma_offset, alma_sigma);
def AtrRsi = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = Ma(rsiMaType1, AtrRsi, Wilders_Period, alma_offset, alma_sigma);
def dar = Ma(rsiMaType1, MaAtrRsi, Wilders_Period, alma_offset, alma_sigma) * FastQqeFactor;

def longband;# = 0.0
def shortband;# = 0.0
def trendx;# = 0

def DeltaFastAtrRsi = dar;
def RSIndex = RsiMa;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;
longband = if RSIndex[1] > longband[1] and RSIndex > longband[1] then Max(longband[1], newlongband) else newlongband;
shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1] then Min(shortband[1], newshortband) else newshortband;
def cross_1 = Crosses(longband[1], RSIndex);
trendx  = if Crosses(RSIndex, shortband[1]) then 1 else if cross_1 then -1 else nz(trendx[1], 1);
def FastAtrRsiTL = if trendx == 1 then longband else shortband;

#//
#// Find all the QQE Crosses
def QQExlong;# = 0
def QQExshort;# = 0
def QQExlong1  = nz(QQExlong[1]);
def QQExshort1 = nz(QQExshort[1]);
QQExlong   = if FastAtrRsiTL < RSIndex then QQExlong1 + 1 else 0;
QQExshort  = if FastAtrRsiTL > RSIndex then QQExshort1 + 1 else 0;

def hcolor = if RsiMa - 50 > ThreshHold then 1 else
             if RsiMa - 50 < 0 - ThreshHold then -1 else 0;

#//EOF
AssignPriceColor(if !ColorBars then Color.CURRENT else
                 if hcolor > 0 then GlobalColor("blue") else
                 if hcolor < 0 then GlobalColor("red") else GlobalColor("orange"));

def nATR   = ATR(Length = 100);
def orsi   = RSI(PRICE = close, LENGTH = RSI_Period1);
def adjrsi = close + nATR * orsi / 100;

def rma = Ma(rsiMaType2, adjrsi, RSI_Period2);
def rsi100 = rma + nATR * (50 / 10);
def rsi0 = rma - nATR * (50 / 10);
def r100 = rsi100;
def r0 = rsi0;
def rsi90 = rma + nATR * (30 / 10);
def rsi10 = rma - nATR * (30 / 10);
def r90 = rsi90;
def r10 = rsi10;

AddCloud(r100, r90, Color.DARK_RED, Color.DARK_RED, yes);      # 'Overbought'
AddCloud(r10, r0, Color.DARK_GREEN, Color.DARK_GREEN, yes);    # 'Oversold'


plot midBand = rma;
midBand.AssignValueColor(if open>rma then GlobalColor("blue") else if open<rma then Color.RED else GlobalColor("yellow"));
def rsim = rma + nATR * (RsiMa - 50) / 10;

def frsim = rma + nATR * (FastAtrRsiTL - 50) / 10;
def QQE_RSI = if ShowRsiCloud then Ma(rsiMaType1, rsim, RsiSmoothing) else na;
def Fast_RSI = Ma(rsiMaType1, frsim, RsiSmoothing);

AddCloud(QQE_RSI,Fast_RSI,GlobalColor("dgreen"), GlobalColor("dred"));    # 'QQE Trend'

def qqeLong = if QQExlong == 1 then frsim else na;
def qqeShort = if QQExshort == 1 then frsim else na;

AddChartBubble(qqeLong,low, "Long", Color.GREEN, no);
AddChartBubble(qqeShort, high, "Short", Color.RED, yes);


#--- END CODE
This script was converted from Tradingview. You can find out more at the below link:


If you are asking how to turn this script into a strategy for backtesting, add the following to the end of your script:
Ruby:
AddOrder(OrderType.BUY_TO_OPEN, qqeLong);
AddOrder(OrderType.SELL_TO_CLOSE, qqeShort);

OR
You can change your ordertype:

https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/OrderType


The indicator was posted on this forum just this past Thursday, so the answer is probably, no.
I'm not too sharp in the tech world. I was having problems installing the QQE. Two questions please:
1. In TOS, I tried to type in just the last chartacters
PVJQvKa.png


Creator Message: https://www.tradingview.com/v/X72V8xjH/

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © traderharikrishna
#https://www.tradingview.com/v/X72V8xjH/
#indicator("Smart QQE",overlay=true)
#// Credits to Glaz
#// Rescaled for overlay by @traderharikrishna
# Converted by Sam4Cok@Samer800    - 03/2023
input ColorBars = yes;    # 'color bars?'
input ShowRsiCloud = yes;
input src = close;        # 'RSI Source'
input rsiMaType1 = {SMA, default EMA, RMA, WMA, VWMA, DEMA, TEMA, HMA, ALMA, SWMA, PEMA, LSMA};
input RSI_Period1 = 14;   # 'RSI Length'
input rsiMaType2 = {"EMA", "HMA", default "SMA", "WMA", "RMA", "VWMA"};    # 'RSI MA Type'
input RSI_Period2 = 50;   # 'RSI 100 level'
input RsiSmoothing = 5;             # 'RSI Smoothing'
input FastQqeFactor = 4.238;        # 'Fast QQE Factor'
input ThreshHold = 10;    # 'Thresh-hold'
input alma_offset = 0.85; # '* Arnaud Legoux (ALMA) Only - Offset Value'
input alma_sigma = 6;     # '* Arnaud Legoux (ALMA) Only - Sigma Value'


def na = Double.NaN;
#---- Color
DefineGlobalColor("blue"   , CreateColor(7, 196, 243));
DefineGlobalColor("red"    , CreateColor(247, 4, 117));
DefineGlobalColor("orange" , CreateColor(255, 152, 0));
DefineGlobalColor("dgreen" , CreateColor(20, 78, 05));
DefineGlobalColor("dred"   , CreateColor(134, 3, 3));
DefineGlobalColor("yellow" , CreateColor(241,226,14));
#// ] -------------- FUNCTIONS : Moving Avg ------------------ [
script nz {
    input data  = close;
    input repl  = 0;
    def ret_val = if !IsNaN(data) then data else repl;
    plot return = ret_val;
}
#pine_swma(source) =>
script swma {
    input source = close;
    def swma = source[3] * 1 / 6 + source[2] * 2 / 6 +  source[1] * 2 / 6 + source[0] * 1 / 6;
    plot retun = swma;
}
#pine_alma(series, windowsize, offset, sigma) =>
script ALMA {
    input series = close;
    input windowsize = 9;
    input Offset = 0.85;
    input Sigma = 6;
    def m = Offset * (windowsize - 1);
    def s = windowsize / Sigma;
    def norm  = fold z = 0 to windowsize with CW do
         CW + Exp(-(Sqr(z - m)) / (2 * Sqr(s)));
    def sum  = fold y = 0 to windowsize with WS do
         WS + Exp(-(Sqr(y - m)) / (2 * Sqr(s))) * GetValue(series, windowsize - 1 - y);
    plot ALMA = sum  / norm ;
}
#vwma(source, length)
script VWMA {
    input src = close;
    input len = 15;
    def v = volume;
    def VWMA = SimpleMovingAvg(src * nz(v, 1), len) / SimpleMovingAvg(nz(v, 1), len);
    plot result = VWMA;
}
#export multiMa(float source, simple int length, string type) =>
script Ma {
    input type = "SMA";
    input source = close;
    input length = 14;
    input alma_offset = 0.85;
    input alma_sigma  = 6;
    def ema1 = ExpAverage(source, length);
    def ema2 = ExpAverage(ema1, length);
    def ema3 = ExpAverage(ema2, length);
    def ema4 = ExpAverage(ema3, length);
    def ema5 = ExpAverage(ema4, length);
    def ema6 = ExpAverage(ema5, length);
    def ema7 = ExpAverage(ema6, length);
    def ema8 = ExpAverage(ema7, length);
    def pema = 8 * ema1 - 28 * ema2 + 56 * ema3 - 70 * ema4 + 56 * ema5 - 28 * ema6 + 8 * ema7 - ema8;
    def multiMa =
        if type == "SMA"  then SimpleMovingAvg(source, length) else
        if type == "EMA"  then ExpAverage(source, length) else
        if type == "RMA"  then WildersAverage(source, length) else
        if type == "WMA"  then WMA(source, length) else
        if type == "VWMA" then vwma(source, length) else
        if type == "DEMA" then DEMA(source, length) else
        if type == "TEMA" then TEMA(source, length) else
        if type == "LSMA" then Inertia(source, length) else
        if type == "PEMA" then pema else
        if type == "ALMA" then ALMA(source, length, alma_offset, alma_sigma) else
        if type == "SWMA" then SWMA(source) else
        if type == "HMA"  then HullMovingAvg(source, length) else Double.NaN;
    plot return = multiMa;
}
def Wilders_Period = RSI_Period1 * 2 - 1;
def Rsi = RSI(PRICE = src, LENGTH = RSI_Period1);
def RsiMa = Ma(rsiMaType1, Rsi, RsiSmoothing , alma_offset, alma_sigma);
def AtrRsi = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = Ma(rsiMaType1, AtrRsi, Wilders_Period, alma_offset, alma_sigma);
def dar = Ma(rsiMaType1, MaAtrRsi, Wilders_Period, alma_offset, alma_sigma) * FastQqeFactor;

def longband;# = 0.0
def shortband;# = 0.0
def trendx;# = 0

def DeltaFastAtrRsi = dar;
def RSIndex = RsiMa;
def newshortband = RSIndex + DeltaFastAtrRsi;
def newlongband = RSIndex - DeltaFastAtrRsi;
longband = if RSIndex[1] > longband[1] and RSIndex > longband[1] then Max(longband[1], newlongband) else newlongband;
shortband = if RSIndex[1] < shortband[1] and RSIndex < shortband[1] then Min(shortband[1], newshortband) else newshortband;
def cross_1 = Crosses(longband[1], RSIndex);
trendx  = if Crosses(RSIndex, shortband[1]) then 1 else if cross_1 then -1 else nz(trendx[1], 1);
def FastAtrRsiTL = if trendx == 1 then longband else shortband;

#//
#// Find all the QQE Crosses
def QQExlong;# = 0
def QQExshort;# = 0
def QQExlong1  = nz(QQExlong[1]);
def QQExshort1 = nz(QQExshort[1]);
QQExlong   = if FastAtrRsiTL < RSIndex then QQExlong1 + 1 else 0;
QQExshort  = if FastAtrRsiTL > RSIndex then QQExshort1 + 1 else 0;

def hcolor = if RsiMa - 50 > ThreshHold then 1 else
             if RsiMa - 50 < 0 - ThreshHold then -1 else 0;

#//EOF
AssignPriceColor(if !ColorBars then Color.CURRENT else
                 if hcolor > 0 then GlobalColor("blue") else
                 if hcolor < 0 then GlobalColor("red") else GlobalColor("orange"));

def nATR   = ATR(Length = 100);
def orsi   = RSI(PRICE = close, LENGTH = RSI_Period1);
def adjrsi = close + nATR * orsi / 100;

def rma = Ma(rsiMaType2, adjrsi, RSI_Period2);
def rsi100 = rma + nATR * (50 / 10);
def rsi0 = rma - nATR * (50 / 10);
def r100 = rsi100;
def r0 = rsi0;
def rsi90 = rma + nATR * (30 / 10);
def rsi10 = rma - nATR * (30 / 10);
def r90 = rsi90;
def r10 = rsi10;

AddCloud(r100, r90, Color.DARK_RED, Color.DARK_RED, yes);      # 'Overbought'
AddCloud(r10, r0, Color.DARK_GREEN, Color.DARK_GREEN, yes);    # 'Oversold'


plot midBand = rma;
midBand.AssignValueColor(if open>rma then GlobalColor("blue") else if open<rma then Color.RED else GlobalColor("yellow"));
def rsim = rma + nATR * (RsiMa - 50) / 10;

def frsim = rma + nATR * (FastAtrRsiTL - 50) / 10;
def QQE_RSI = if ShowRsiCloud then Ma(rsiMaType1, rsim, RsiSmoothing) else na;
def Fast_RSI = Ma(rsiMaType1, frsim, RsiSmoothing);

AddCloud(QQE_RSI,Fast_RSI,GlobalColor("dgreen"), GlobalColor("dred"));    # 'QQE Trend'

def qqeLong = if QQExlong == 1 then frsim else na;
def qqeShort = if QQExshort == 1 then frsim else na;

AddChartBubble(qqeLong,low, "Long", Color.GREEN, no);
AddChartBubble(qqeShort, high, "Short", Color.RED, yes);


#--- END CODE
I am not the strongest in Tech World. I was trying to install the QQE in to TOS but could not. Two questions please;
1. In "open shared item", I tried to type in just the last characters of the creator's message above, but it wouldn't take. I also tried to paste the whole URL, but that didn't work. So I am stopped there.
2. In installing one of your indicators (which I was able to in the past), is there a way to restrict where it goes to just one location? On the recent RSM and KNN, it was installed on all my different styles where I didn't want it. I had to go thru all and selectively delete. Thanks so much

Perhaps I discovered my first error.... I guess I didn't catch "Trading View"... Is this available in TOS? My second question still applies I guess.


thanks

"B"
 
Last edited by a moderator:
I'm not too sharp in the tech world. I was having problems installing the QQE. Two questions please:
1. In TOS, I tried to type in just the last chartacters

I am not the strongest in Tech World. I was trying to install the QQE in to TOS but could not. Two questions please;
1. In "open shared item", I tried to type in just the last characters of the creator's message above, but it wouldn't take. I also tried to paste the whole URL, but that didn't work. So I am stopped there.
2. In installing one of your indicators (which I was able to in the past), is there a way to restrict where it goes to just one location? On the recent RSM and KNN, it was installed on all my different styles where I didn't want it. I had to go thru all and selectively delete. Thanks so much

Perhaps I discovered my first error.... I guess I didn't catch "Trading View"... Is this available in TOS? My second question still applies I guess.


thanks

"B"
If you are asking if the code in the top post is for use in the ToS app?
The answer is yes. It is a ThinkOrSwim study that was converted from Tradingview.

If you are asking how to cut and paste the code from the top post into the ToS app?
https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/

If you are asking the easiest way to load shared links?
https://usethinkscript.com/threads/...ed-item-error-in-thinkorswim.5098/#post-57930

If you are asking if a ToS indicator will be "installed on all your different styles"?
The answer is no. The only way an indicator can be incorporated into your different styles is if you saved those indicators into those styles at some point after you added them to your chart.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
129 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