QQE Signals

APOT

New member
Platform
  1. Thinkorswim
  2. TradingView
Anyone able to convert this into TOS. Thank you!

Code:
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © colinmck

study("QQE signals", overlay=true)

RSI_Period = input(14, title='RSI Length')
SF = input(5, title='RSI Smoothing')
QQE = input(4.238, title='Fast QQE Factor')
ThreshHold = input(10, title="Thresh-hold")

src = close
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

// Find all the QQE Crosses

QQExlong = 0
QQExlong := nz(QQExlong[1])
QQExshort = 0
QQExshort := nz(QQExshort[1])
QQExlong := FastAtrRsiTL < RSIndex ? QQExlong + 1 : 0
QQExshort := FastAtrRsiTL > RSIndex ? QQExshort + 1 : 0

//Conditions

qqeLong = QQExlong == 1 ? FastAtrRsiTL[1] - 50 : na
qqeShort = QQExshort == 1 ? FastAtrRsiTL[1] - 50 : na

// Plotting

plotshape(qqeLong, title="QQE long", text="Long", textcolor=color.white, style=shape.labelup, location=location.belowbar, color=color.green, transp=0, size=size.tiny)
plotshape(qqeShort, title="QQE short", text="Short", textcolor=color.white, style=shape.labeldown, location=location.abovebar, color=color.red, transp=0, size=size.tiny)

// Alerts

alertcondition(qqeLong, title="Long", message="Long")
alertcondition(qqeShort, title="Short", message="Short")
 
Last edited by a moderator:

barbaros

Administrator
Staff member
Try this.

Code:
# QQE Signals
# Original: https://www.tradingview.com/script/7R6ZxyZu-QQE-signals/
# Converted for https://b4indicators.com/threads/qqe-signals.232/
# barbaros

input RSI_Period = 14;
input RSI_Smoothing = 5;
input Fast_QQE_Factor = 4.238;
input Threshold = 10;

script nz {
    input val = close;
    plot result = if isNaN(val) then 0 else val;
}

def src = close;
def Wilders_period = RSI_Period * 2 - 1;

def Rsi = RSI(price = src, length = RSI_Period);
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;

# Find all the QQE Crosses
def QQExlong = if FastAtrRsiTL < RSIndex then QQExlong[1] + 1 else 0;
def QQExshort = if FastAtrRsiTL > RSIndex then QQExshort[1] + 1 else 0;

# Conditions
def qqeLong = if QQExlong == 1 then FastAtrRsiTL[1] - 50 else Double.NaN;
def qqeShort = if QQExshort == 1 then FastAtrRsiTL[1] - 50 else Double.NaN;

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

# Alerts
Alert(qqeLong, "QQE Long", Alert.BAR, Sound.DING);
Alert(qqeShort, "QQE Short", Alert.BAR, Sound.DING);
 

sam4cok

Member
and here the lower study :)

29hySDD.png


CSS:
#//By Glaz
#//Modifications:
#// Added Columns to show when signal is outside of Thresh Hold Channnel.
#// Set default Parameters to match QQE Cross Alert indicator.
#study("QQE MT4 Glaz-modified by JustUncleL")
# Converted by Sam4Cok @ Samer800 07/2022
declare lower;
input RSI_Period = 14;       # 'RSI Length'
input RSISmooth  = 5;        # 'RSI Smoothing'
input QQE        = 4.238;    # 'Fast QQE Factor'
input ThreshHold = 10;       # 'Thresh-hold'
input RSICrossQQE    = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input RSICrossZero   = no;   # 'Show Smooth RSI Zero crosses'
input RSICrossThresh = no;   # 'Show Smooth RSI Thresh Hold Channel Exits'
input src = close;           # 'RSI Source'

def na = Double.NaN;
script nz {
    input data         = 1;
    input replacement  = 0;
      def ret_val = if IsNaN(data) then replacement else data;
    plot return = ret_val;
}
###############
def Wilders_Period = RSI_Period * 2 - 1;
def Rsi      = RSI(Price = src, Length = RSI_Period);
def RsiMa    = ExpAverage(Rsi, RSISmooth);
def AtrRsi   = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = ExpAverage(AtrRsi, Wilders_Period);
def dar      = ExpAverage(MaAtrRsi, Wilders_Period) * QQE;

def longband;
def shortband;
def trend;

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;
        trend = if Crosses(RSIndex, shortband[1]) then 1 else
                if Crosses(longband[1], RSIndex) then -1 else nz(trend[1], 1);
def FastAtrRsiTL = if trend == 1 then longband else shortband;

#// Find all the QQE Crosses
def QQExlong  = if RSICrossQQE then if FastAtrRsiTL crosses above RSIndex then nz(QQExlong[1]) + 1  else 0 else 0;
def QQExshort = if RSICrossQQE then if FastAtrRsiTL crosses below RSIndex then nz(QQExshort[1]) + 1 else 0 else 0;

#// Zero cross
def QQEzlong  = if RSICrossZero then if RSIndex crosses above 50 then nz(QQEzlong[1]) + 1 else 0 else 0;
def QQEzshort = if RSICrossZero then if RSIndex crosses below 50 then nz(QQEzshort[1]) + 1 else 0 else 0;

#// Thresh Hold channel Crosses give the BUY/SELL alerts.
def QQEclong  = if RSICrossThresh then if RSIndex crosses  above (50 + ThreshHold) then nz(QQEclong[1]) + 1 else 0 else 0;
def QQEcshort = if RSICrossThresh then if RSIndex crosses below (50 - ThreshHold) then nz(QQEcshort[1]) + 1 else 0 else 0;

#// QQE exit from Thresh Hold Channel
plot QQEOver = if RSICrossThresh then if QQEclong == 1 then RsiMa - 50 else na else na;#"QQE XC Over Channel",
QQEOver.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEOver.SetDefaultColor(Color.GREEN);
QQEOver.SetLineWeight(5);

plot QQEUnder = if RSICrossThresh then if QQEcshort == 1 then RsiMa - 50 else na else na; #"QQE XC Under Channel",
QQEUnder.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEUnder.SetDefaultColor(Color.RED);
QQEUnder.SetLineWeight(5);

#// QQE crosses
plot QQE_CrossUP = if RSICrossQQE then if QQExlong==1 then FastAtrRsiTL[1]-50 else na else na;# "QQE XQ Cross Over"
QQE_CrossUP.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
QQE_CrossUP.SetDefaultColor(Color.RED);
QQE_CrossUP.SetLineWeight(3);

plot QQE_CrossDN = if RSICrossQQE then if QQExshort==1 then FastAtrRsiTL[1]-50 else na else na; # "QQE XQ Cross Under"
QQE_CrossDN.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
QQE_CrossDN.SetDefaultColor(Color.GREEN);
QQE_CrossDN.SetLineWeight(3);

#// Signal crosses zero line
plot QQE_ZeroUP = if RSICrossZero then if QQEzlong==1 then RsiMa-50 else na else na;# "QQE XZ Zero Cross Over"
QQE_ZeroUP.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroUP.SetDefaultColor(Color.CYAN);
QQE_ZeroUP.SetLineWeight(5);

plot QQE_ZeroDN = if RSICrossZero then if QQEzshort==1 then RsiMa-50 else na else na; #, title="QQE XZ Zero Cross Under", style=shape.square, location=location.absolute, color=fuchsia, transp=0, size=size.small,offset=0)
QQE_ZeroDN.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroDN.SetDefaultColor(Color.MAGENTA);
QQE_ZeroDN.SetLineWeight(5);

############################################################################
plot hZero = 0;
hZero.SetDefaultColor(Color.GRAY);
plot hUpper= ThreshHold;
hUpper.SetStyle(Curve.SHORT_DASH);
hUpper.SetDefaultColor(Color.GREEN);
plot hLower= 0-ThreshHold;#,color=red,linestyle=dashed,linewidth=2)
hLower.SetStyle(Curve.SHORT_DASH);
hLower.SetDefaultColor(Color.RED);

##################################################################
def color = if (RsiMa-50) > ThreshHold then 1 else if (RsiMa-50) < 0-ThreshHold then -1 else 0;

plot p2 = RsiMa-50;
p2.SetDefaultColor(Color.Orange);
p2.SetLineWeight(3);

plot p1 = RsiMa-50;
p1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
p1.AssignValueColor(if Color > 0 then Color.DARK_GREEN else
                    if Color < 0 then Color.RED else CreateColor(255,127,0));
p1.SetLineWeight(4);

plot ATRLine = FastAtrRsiTL-50;
ATRLine.SetDefaultColor(CreateColor(0, 101, 255));
ATRLine.SetLineWeight(3);


addCloud(hUpper,hLower,color.DARK_GRAY);

#### END//EOF
 
and here the lower study :)

29hySDD.png


CSS:
#//By Glaz
#//Modifications:
#// Added Columns to show when signal is outside of Thresh Hold Channnel.
#// Set default Parameters to match QQE Cross Alert indicator.
#study("QQE MT4 Glaz-modified by JustUncleL")
# Converted by Sam4Cok @ Samer800 07/2022
declare lower;
input RSI_Period = 14;       # 'RSI Length'
input RSISmooth  = 5;        # 'RSI Smoothing'
input QQE        = 4.238;    # 'Fast QQE Factor'
input ThreshHold = 10;       # 'Thresh-hold'
input RSICrossQQE    = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input RSICrossZero   = no;   # 'Show Smooth RSI Zero crosses'
input RSICrossThresh = no;   # 'Show Smooth RSI Thresh Hold Channel Exits'
input src = close;           # 'RSI Source'

def na = Double.NaN;
script nz {
    input data         = 1;
    input replacement  = 0;
      def ret_val = if IsNaN(data) then replacement else data;
    plot return = ret_val;
}
###############
def Wilders_Period = RSI_Period * 2 - 1;
def Rsi      = RSI(Price = src, Length = RSI_Period);
def RsiMa    = ExpAverage(Rsi, RSISmooth);
def AtrRsi   = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = ExpAverage(AtrRsi, Wilders_Period);
def dar      = ExpAverage(MaAtrRsi, Wilders_Period) * QQE;

def longband;
def shortband;
def trend;

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;
        trend = if Crosses(RSIndex, shortband[1]) then 1 else
                if Crosses(longband[1], RSIndex) then -1 else nz(trend[1], 1);
def FastAtrRsiTL = if trend == 1 then longband else shortband;

#// Find all the QQE Crosses
def QQExlong  = if RSICrossQQE then if FastAtrRsiTL crosses above RSIndex then nz(QQExlong[1]) + 1  else 0 else 0;
def QQExshort = if RSICrossQQE then if FastAtrRsiTL crosses below RSIndex then nz(QQExshort[1]) + 1 else 0 else 0;

#// Zero cross
def QQEzlong  = if RSICrossZero then if RSIndex crosses above 50 then nz(QQEzlong[1]) + 1 else 0 else 0;
def QQEzshort = if RSICrossZero then if RSIndex crosses below 50 then nz(QQEzshort[1]) + 1 else 0 else 0;

#// Thresh Hold channel Crosses give the BUY/SELL alerts.
def QQEclong  = if RSICrossThresh then if RSIndex crosses  above (50 + ThreshHold) then nz(QQEclong[1]) + 1 else 0 else 0;
def QQEcshort = if RSICrossThresh then if RSIndex crosses below (50 - ThreshHold) then nz(QQEcshort[1]) + 1 else 0 else 0;

#// QQE exit from Thresh Hold Channel
plot QQEOver = if RSICrossThresh then if QQEclong == 1 then RsiMa - 50 else na else na;#"QQE XC Over Channel",
QQEOver.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEOver.SetDefaultColor(Color.GREEN);
QQEOver.SetLineWeight(5);

plot QQEUnder = if RSICrossThresh then if QQEcshort == 1 then RsiMa - 50 else na else na; #"QQE XC Under Channel",
QQEUnder.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEUnder.SetDefaultColor(Color.RED);
QQEUnder.SetLineWeight(5);

#// QQE crosses
plot QQE_CrossUP = if RSICrossQQE then if QQExlong==1 then FastAtrRsiTL[1]-50 else na else na;# "QQE XQ Cross Over"
QQE_CrossUP.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
QQE_CrossUP.SetDefaultColor(Color.RED);
QQE_CrossUP.SetLineWeight(3);

plot QQE_CrossDN = if RSICrossQQE then if QQExshort==1 then FastAtrRsiTL[1]-50 else na else na; # "QQE XQ Cross Under"
QQE_CrossDN.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
QQE_CrossDN.SetDefaultColor(Color.GREEN);
QQE_CrossDN.SetLineWeight(3);

#// Signal crosses zero line
plot QQE_ZeroUP = if RSICrossZero then if QQEzlong==1 then RsiMa-50 else na else na;# "QQE XZ Zero Cross Over"
QQE_ZeroUP.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroUP.SetDefaultColor(Color.CYAN);
QQE_ZeroUP.SetLineWeight(5);

plot QQE_ZeroDN = if RSICrossZero then if QQEzshort==1 then RsiMa-50 else na else na; #, title="QQE XZ Zero Cross Under", style=shape.square, location=location.absolute, color=fuchsia, transp=0, size=size.small,offset=0)
QQE_ZeroDN.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroDN.SetDefaultColor(Color.MAGENTA);
QQE_ZeroDN.SetLineWeight(5);

############################################################################
plot hZero = 0;
hZero.SetDefaultColor(Color.GRAY);
plot hUpper= ThreshHold;
hUpper.SetStyle(Curve.SHORT_DASH);
hUpper.SetDefaultColor(Color.GREEN);
plot hLower= 0-ThreshHold;#,color=red,linestyle=dashed,linewidth=2)
hLower.SetStyle(Curve.SHORT_DASH);
hLower.SetDefaultColor(Color.RED);

##################################################################
def color = if (RsiMa-50) > ThreshHold then 1 else if (RsiMa-50) < 0-ThreshHold then -1 else 0;

plot p2 = RsiMa-50;
p2.SetDefaultColor(Color.Orange);
p2.SetLineWeight(3);

plot p1 = RsiMa-50;
p1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
p1.AssignValueColor(if Color > 0 then Color.DARK_GREEN else
                    if Color < 0 then Color.RED else CreateColor(255,127,0));
p1.SetLineWeight(4);

plot ATRLine = FastAtrRsiTL-50;
ATRLine.SetDefaultColor(CreateColor(0, 101, 255));
ATRLine.SetLineWeight(3);


addCloud(hUpper,hLower,color.DARK_GRAY);

#### END//EOF[/CODE
[/QUOTE]

and here the lower study :)

29hySDD.png


CSS:
#//By Glaz
#//Modifications:
#// Added Columns to show when signal is outside of Thresh Hold Channnel.
#// Set default Parameters to match QQE Cross Alert indicator.
#study("QQE MT4 Glaz-modified by JustUncleL")
# Converted by Sam4Cok @ Samer800 07/2022
declare lower;
input RSI_Period = 14;       # 'RSI Length'
input RSISmooth  = 5;        # 'RSI Smoothing'
input QQE        = 4.238;    # 'Fast QQE Factor'
input ThreshHold = 10;       # 'Thresh-hold'
input RSICrossQQE    = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input RSICrossZero   = no;   # 'Show Smooth RSI Zero crosses'
input RSICrossThresh = no;   # 'Show Smooth RSI Thresh Hold Channel Exits'
input src = close;           # 'RSI Source'

def na = Double.NaN;
script nz {
    input data         = 1;
    input replacement  = 0;
      def ret_val = if IsNaN(data) then replacement else data;
    plot return = ret_val;
}
###############
def Wilders_Period = RSI_Period * 2 - 1;
def Rsi      = RSI(Price = src, Length = RSI_Period);
def RsiMa    = ExpAverage(Rsi, RSISmooth);
def AtrRsi   = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = ExpAverage(AtrRsi, Wilders_Period);
def dar      = ExpAverage(MaAtrRsi, Wilders_Period) * QQE;

def longband;
def shortband;
def trend;

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;
        trend = if Crosses(RSIndex, shortband[1]) then 1 else
                if Crosses(longband[1], RSIndex) then -1 else nz(trend[1], 1);
def FastAtrRsiTL = if trend == 1 then longband else shortband;

#// Find all the QQE Crosses
def QQExlong  = if RSICrossQQE then if FastAtrRsiTL crosses above RSIndex then nz(QQExlong[1]) + 1  else 0 else 0;
def QQExshort = if RSICrossQQE then if FastAtrRsiTL crosses below RSIndex then nz(QQExshort[1]) + 1 else 0 else 0;

#// Zero cross
def QQEzlong  = if RSICrossZero then if RSIndex crosses above 50 then nz(QQEzlong[1]) + 1 else 0 else 0;
def QQEzshort = if RSICrossZero then if RSIndex crosses below 50 then nz(QQEzshort[1]) + 1 else 0 else 0;

#// Thresh Hold channel Crosses give the BUY/SELL alerts.
def QQEclong  = if RSICrossThresh then if RSIndex crosses  above (50 + ThreshHold) then nz(QQEclong[1]) + 1 else 0 else 0;
def QQEcshort = if RSICrossThresh then if RSIndex crosses below (50 - ThreshHold) then nz(QQEcshort[1]) + 1 else 0 else 0;

#// QQE exit from Thresh Hold Channel
plot QQEOver = if RSICrossThresh then if QQEclong == 1 then RsiMa - 50 else na else na;#"QQE XC Over Channel",
QQEOver.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEOver.SetDefaultColor(Color.GREEN);
QQEOver.SetLineWeight(5);

plot QQEUnder = if RSICrossThresh then if QQEcshort == 1 then RsiMa - 50 else na else na; #"QQE XC Under Channel",
QQEUnder.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEUnder.SetDefaultColor(Color.RED);
QQEUnder.SetLineWeight(5);

#// QQE crosses
plot QQE_CrossUP = if RSICrossQQE then if QQExlong==1 then FastAtrRsiTL[1]-50 else na else na;# "QQE XQ Cross Over"
QQE_CrossUP.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
QQE_CrossUP.SetDefaultColor(Color.RED);
QQE_CrossUP.SetLineWeight(3);

plot QQE_CrossDN = if RSICrossQQE then if QQExshort==1 then FastAtrRsiTL[1]-50 else na else na; # "QQE XQ Cross Under"
QQE_CrossDN.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
QQE_CrossDN.SetDefaultColor(Color.GREEN);
QQE_CrossDN.SetLineWeight(3);

#// Signal crosses zero line
plot QQE_ZeroUP = if RSICrossZero then if QQEzlong==1 then RsiMa-50 else na else na;# "QQE XZ Zero Cross Over"
QQE_ZeroUP.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroUP.SetDefaultColor(Color.CYAN);
QQE_ZeroUP.SetLineWeight(5);

plot QQE_ZeroDN = if RSICrossZero then if QQEzshort==1 then RsiMa-50 else na else na; #, title="QQE XZ Zero Cross Under", style=shape.square, location=location.absolute, color=fuchsia, transp=0, size=size.small,offset=0)
QQE_ZeroDN.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroDN.SetDefaultColor(Color.MAGENTA);
QQE_ZeroDN.SetLineWeight(5);

############################################################################
plot hZero = 0;
hZero.SetDefaultColor(Color.GRAY);
plot hUpper= ThreshHold;
hUpper.SetStyle(Curve.SHORT_DASH);
hUpper.SetDefaultColor(Color.GREEN);
plot hLower= 0-ThreshHold;#,color=red,linestyle=dashed,linewidth=2)
hLower.SetStyle(Curve.SHORT_DASH);
hLower.SetDefaultColor(Color.RED);

##################################################################
def color = if (RsiMa-50) > ThreshHold then 1 else if (RsiMa-50) < 0-ThreshHold then -1 else 0;

plot p2 = RsiMa-50;
p2.SetDefaultColor(Color.Orange);
p2.SetLineWeight(3);

plot p1 = RsiMa-50;
p1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
p1.AssignValueColor(if Color > 0 then Color.DARK_GREEN else
                    if Color < 0 then Color.RED else CreateColor(255,127,0));
p1.SetLineWeight(4);

plot ATRLine = FastAtrRsiTL-50;
ATRLine.SetDefaultColor(CreateColor(0, 101, 255));
ATRLine.SetLineWeight(3);


addCloud(hUpper,hLower,color.DARK_GRAY);

#### END//EOF
wow perfect.. thank you some much @sam4cok . i'm sorry to bother you for one more thing. do you think it is possible to color the candles with signal? thank you in advance
 

barbaros

Administrator
Staff member
per request, Barbaros Can you add arrows to the QQE indicators, Mobile don't display bubbles
Here you go.
Code:
# QQE Signals - Arrows
# Original: https://www.tradingview.com/script/7R6ZxyZu-QQE-signals/
# Converted for https://b4indicators.com/threads/qqe-signals.232/
# barbaros

input RSI_Period = 14;
input RSI_Smoothing = 5;
input Fast_QQE_Factor = 4.238;
input Threshold = 10;

script nz {
    input val = close;
    plot result = if isNaN(val) then 0 else val;
}

def src = close;
def Wilders_period = RSI_Period * 2 - 1;

def Rsi = RSI(price = src, length = RSI_Period);
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;

# Find all the QQE Crosses
def QQExlong = if FastAtrRsiTL < RSIndex then QQExlong[1] + 1 else 0;
def QQExshort = if FastAtrRsiTL > RSIndex then QQExshort[1] + 1 else 0;

# Conditions and Plotting
plot qqeLong = QQExlong == 1;
qqeLong.SetDefaultColor(Color.GREEN);
qqeLong.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

plot qqeShort = QQExshort == 1;
qqeShort.SetDefaultColor(Color.RED);
qqeShort.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

# Alerts
Alert(qqeLong, "QQE Long", Alert.BAR, Sound.DING);
Alert(qqeShort, "QQE Short", Alert.BAR, Sound.DING);
 

sam4cok

Member
wow perfect.. thank you some much @sam4cok . i'm sorry to bother you for one more thing. do you think it is possible to color the candles with signal? thank you in advance
find below as requested.

CSS:
#//By Glaz
#//Modifications:
#// Added Columns to show when signal is outside of Thresh Hold Channnel.
#// Set default Parameters to match QQE Cross Alert indicator.
#study("QQE MT4 Glaz-modified by JustUncleL")
# Converted by Sam4Cok @ Samer800 07/2022
#Ver 1.1 added Bar Color -
declare lower;
input RSI_Period = 14;       # 'RSI Length'
input RSISmooth  = 5;        # 'RSI Smoothing'
input QQE        = 4.238;    # 'Fast QQE Factor'
input ThreshHold = 10;       # 'Thresh-hold'
input BarColor       = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input SignalBar      = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input RSICrossQQE    = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input RSICrossZero   = no;   # 'Show Smooth RSI Zero crosses'
input RSICrossThresh = no;   # 'Show Smooth RSI Thresh Hold Channel Exits'
input src = close;           # 'RSI Source'

def na = Double.NaN;
script nz {
    input data         = 1;
    input replacement  = 0;
      def ret_val = if IsNaN(data) then replacement else data;
    plot return = ret_val;
}
###############
def Wilders_Period = RSI_Period * 2 - 1;
def Rsi      = RSI(Price = src, Length = RSI_Period);
def RsiMa    = ExpAverage(Rsi, RSISmooth);
def AtrRsi   = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = ExpAverage(AtrRsi, Wilders_Period);
def dar      = ExpAverage(MaAtrRsi, Wilders_Period) * QQE;

def longband;
def shortband;
def trend;

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;
        trend = if Crosses(RSIndex, shortband[1]) then 1 else
                if Crosses(longband[1], RSIndex) then -1 else nz(trend[1], 1);
def FastAtrRsiTL = if trend == 1 then longband else shortband;

#// Find all the QQE Crosses
def QQExlong  = if RSICrossQQE then if FastAtrRsiTL crosses above RSIndex then nz(QQExlong[1]) + 1  else 0 else 0;
def QQExshort = if RSICrossQQE then if FastAtrRsiTL crosses below RSIndex then nz(QQExshort[1]) + 1 else 0 else 0;

#// Zero cross
def QQEzlong  = if RSICrossZero then if RSIndex crosses above 50 then nz(QQEzlong[1]) + 1 else 0 else 0;
def QQEzshort = if RSICrossZero then if RSIndex crosses below 50 then nz(QQEzshort[1]) + 1 else 0 else 0;

#// Thresh Hold channel Crosses give the BUY/SELL alerts.
def QQEclong  = if RSICrossThresh then if RSIndex crosses  above (50 + ThreshHold) then nz(QQEclong[1]) + 1 else 0 else 0;
def QQEcshort = if RSICrossThresh then if RSIndex crosses below (50 - ThreshHold) then nz(QQEcshort[1]) + 1 else 0 else 0;

#// QQE exit from Thresh Hold Channel
plot QQEOver = if RSICrossThresh then if QQEclong == 1 then RsiMa - 50 else na else na;#"QQE XC Over Channel",
QQEOver.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEOver.SetDefaultColor(Color.GREEN);
QQEOver.SetLineWeight(5);

plot QQEUnder = if RSICrossThresh then if QQEcshort == 1 then RsiMa - 50 else na else na; #"QQE XC Under Channel",
QQEUnder.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEUnder.SetDefaultColor(Color.RED);
QQEUnder.SetLineWeight(5);

#// QQE crosses
plot QQE_CrossUP = if RSICrossQQE then if QQExlong==1 then FastAtrRsiTL[1]-50 else na else na;# "QQE XQ Cross Over"
QQE_CrossUP.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
QQE_CrossUP.SetDefaultColor(Color.RED);
QQE_CrossUP.SetLineWeight(3);

plot QQE_CrossDN = if RSICrossQQE then if QQExshort==1 then FastAtrRsiTL[1]-50 else na else na; # "QQE XQ Cross Under"
QQE_CrossDN.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
QQE_CrossDN.SetDefaultColor(Color.GREEN);
QQE_CrossDN.SetLineWeight(3);

#// Signal crosses zero line
plot QQE_ZeroUP = if RSICrossZero then if QQEzlong==1 then RsiMa-50 else na else na;# "QQE XZ Zero Cross Over"
QQE_ZeroUP.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroUP.SetDefaultColor(Color.CYAN);
QQE_ZeroUP.SetLineWeight(5);

plot QQE_ZeroDN = if RSICrossZero then if QQEzshort==1 then RsiMa-50 else na else na; #, title="QQE XZ Zero Cross Under", style=shape.square, location=location.absolute, color=fuchsia, transp=0, size=size.small,offset=0)
QQE_ZeroDN.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroDN.SetDefaultColor(Color.MAGENTA);
QQE_ZeroDN.SetLineWeight(5);

############################################################################
plot hZero = 0;
hZero.SetDefaultColor(Color.GRAY);
plot hUpper= ThreshHold;
hUpper.SetStyle(Curve.SHORT_DASH);
hUpper.SetDefaultColor(Color.GREEN);
plot hLower= 0-ThreshHold;#,color=red,linestyle=dashed,linewidth=2)
hLower.SetStyle(Curve.SHORT_DASH);
hLower.SetDefaultColor(Color.RED);

##################################################################
def color = if (RsiMa-50) > ThreshHold then 1 else if (RsiMa-50) < 0-ThreshHold then -1 else 0;

plot p2 = RsiMa-50;
p2.SetDefaultColor(Color.Orange);
p2.SetLineWeight(3);

plot p1 = RsiMa-50;
p1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
p1.AssignValueColor(if Color > 0 then Color.DARK_GREEN else
                    if Color < 0 then Color.RED else CreateColor(255,127,0));
p1.SetLineWeight(4);

plot ATRLine = FastAtrRsiTL-50;
ATRLine.SetDefaultColor(CreateColor(0, 101, 255));
ATRLine.SetLineWeight(3);

addCloud(hUpper,hLower,color.DARK_GRAY);

AssignPriceColor(
if BarColor and SignalBar then if QQExlong==1 then color.MAGENTA else
                               if QQExshort==1 then color.BLUE else
                               if Color > 0 and p1 >= p1[1] then Color.GREEN else
                 if Color > 0 and p1 < p1[1] then Color.DARK_GREEN else
                 if Color < 0 and p1 <= p1[1] then Color.RED else
                 if Color < 0 and p1 > p1[1] then Color.DARK_RED else CreateColor(255,127,0) else
if BarColor and !SignalBar then if Color > 0 and p1 >= p1[1] then Color.GREEN else
                 if Color > 0 and p1 < p1[1] then Color.DARK_GREEN else
                 if Color < 0 and p1 <= p1[1] then Color.RED else
                 if Color < 0 and p1 > p1[1] then Color.DARK_RED else CreateColor(255,127,0) else
if SignalBar then if QQExlong==1 then color.MAGENTA else
                 if QQExshort==1 then color.BLUE else color.CURRENT else Color.CURRENT);

#### END//EOF
 
find below as requested.

CSS:
#//By Glaz
#//Modifications:
#// Added Columns to show when signal is outside of Thresh Hold Channnel.
#// Set default Parameters to match QQE Cross Alert indicator.
#study("QQE MT4 Glaz-modified by JustUncleL")
# Converted by Sam4Cok @ Samer800 07/2022
#Ver 1.1 added Bar Color -
declare lower;
input RSI_Period = 14;       # 'RSI Length'
input RSISmooth  = 5;        # 'RSI Smoothing'
input QQE        = 4.238;    # 'Fast QQE Factor'
input ThreshHold = 10;       # 'Thresh-hold'
input BarColor       = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input SignalBar      = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input RSICrossQQE    = yes;  # 'Show Smooth RSI, QQE Signal crosses'
input RSICrossZero   = no;   # 'Show Smooth RSI Zero crosses'
input RSICrossThresh = no;   # 'Show Smooth RSI Thresh Hold Channel Exits'
input src = close;           # 'RSI Source'

def na = Double.NaN;
script nz {
    input data         = 1;
    input replacement  = 0;
      def ret_val = if IsNaN(data) then replacement else data;
    plot return = ret_val;
}
###############
def Wilders_Period = RSI_Period * 2 - 1;
def Rsi      = RSI(Price = src, Length = RSI_Period);
def RsiMa    = ExpAverage(Rsi, RSISmooth);
def AtrRsi   = AbsValue(RsiMa[1] - RsiMa);
def MaAtrRsi = ExpAverage(AtrRsi, Wilders_Period);
def dar      = ExpAverage(MaAtrRsi, Wilders_Period) * QQE;

def longband;
def shortband;
def trend;

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;
        trend = if Crosses(RSIndex, shortband[1]) then 1 else
                if Crosses(longband[1], RSIndex) then -1 else nz(trend[1], 1);
def FastAtrRsiTL = if trend == 1 then longband else shortband;

#// Find all the QQE Crosses
def QQExlong  = if RSICrossQQE then if FastAtrRsiTL crosses above RSIndex then nz(QQExlong[1]) + 1  else 0 else 0;
def QQExshort = if RSICrossQQE then if FastAtrRsiTL crosses below RSIndex then nz(QQExshort[1]) + 1 else 0 else 0;

#// Zero cross
def QQEzlong  = if RSICrossZero then if RSIndex crosses above 50 then nz(QQEzlong[1]) + 1 else 0 else 0;
def QQEzshort = if RSICrossZero then if RSIndex crosses below 50 then nz(QQEzshort[1]) + 1 else 0 else 0;

#// Thresh Hold channel Crosses give the BUY/SELL alerts.
def QQEclong  = if RSICrossThresh then if RSIndex crosses  above (50 + ThreshHold) then nz(QQEclong[1]) + 1 else 0 else 0;
def QQEcshort = if RSICrossThresh then if RSIndex crosses below (50 - ThreshHold) then nz(QQEcshort[1]) + 1 else 0 else 0;

#// QQE exit from Thresh Hold Channel
plot QQEOver = if RSICrossThresh then if QQEclong == 1 then RsiMa - 50 else na else na;#"QQE XC Over Channel",
QQEOver.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEOver.SetDefaultColor(Color.GREEN);
QQEOver.SetLineWeight(5);

plot QQEUnder = if RSICrossThresh then if QQEcshort == 1 then RsiMa - 50 else na else na; #"QQE XC Under Channel",
QQEUnder.SetPaintingStrategy(PaintingStrategy.POINTS);
QQEUnder.SetDefaultColor(Color.RED);
QQEUnder.SetLineWeight(5);

#// QQE crosses
plot QQE_CrossUP = if RSICrossQQE then if QQExlong==1 then FastAtrRsiTL[1]-50 else na else na;# "QQE XQ Cross Over"
QQE_CrossUP.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
QQE_CrossUP.SetDefaultColor(Color.RED);
QQE_CrossUP.SetLineWeight(3);

plot QQE_CrossDN = if RSICrossQQE then if QQExshort==1 then FastAtrRsiTL[1]-50 else na else na; # "QQE XQ Cross Under"
QQE_CrossDN.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
QQE_CrossDN.SetDefaultColor(Color.GREEN);
QQE_CrossDN.SetLineWeight(3);

#// Signal crosses zero line
plot QQE_ZeroUP = if RSICrossZero then if QQEzlong==1 then RsiMa-50 else na else na;# "QQE XZ Zero Cross Over"
QQE_ZeroUP.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroUP.SetDefaultColor(Color.CYAN);
QQE_ZeroUP.SetLineWeight(5);

plot QQE_ZeroDN = if RSICrossZero then if QQEzshort==1 then RsiMa-50 else na else na; #, title="QQE XZ Zero Cross Under", style=shape.square, location=location.absolute, color=fuchsia, transp=0, size=size.small,offset=0)
QQE_ZeroDN.SetPaintingStrategy(PaintingStrategy.SQUARES);
QQE_ZeroDN.SetDefaultColor(Color.MAGENTA);
QQE_ZeroDN.SetLineWeight(5);

############################################################################
plot hZero = 0;
hZero.SetDefaultColor(Color.GRAY);
plot hUpper= ThreshHold;
hUpper.SetStyle(Curve.SHORT_DASH);
hUpper.SetDefaultColor(Color.GREEN);
plot hLower= 0-ThreshHold;#,color=red,linestyle=dashed,linewidth=2)
hLower.SetStyle(Curve.SHORT_DASH);
hLower.SetDefaultColor(Color.RED);

##################################################################
def color = if (RsiMa-50) > ThreshHold then 1 else if (RsiMa-50) < 0-ThreshHold then -1 else 0;

plot p2 = RsiMa-50;
p2.SetDefaultColor(Color.Orange);
p2.SetLineWeight(3);

plot p1 = RsiMa-50;
p1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
p1.AssignValueColor(if Color > 0 then Color.DARK_GREEN else
                    if Color < 0 then Color.RED else CreateColor(255,127,0));
p1.SetLineWeight(4);

plot ATRLine = FastAtrRsiTL-50;
ATRLine.SetDefaultColor(CreateColor(0, 101, 255));
ATRLine.SetLineWeight(3);

addCloud(hUpper,hLower,color.DARK_GRAY);

AssignPriceColor(
if BarColor and SignalBar then if QQExlong==1 then color.MAGENTA else
                               if QQExshort==1 then color.BLUE else
                               if Color > 0 and p1 >= p1[1] then Color.GREEN else
                 if Color > 0 and p1 < p1[1] then Color.DARK_GREEN else
                 if Color < 0 and p1 <= p1[1] then Color.RED else
                 if Color < 0 and p1 > p1[1] then Color.DARK_RED else CreateColor(255,127,0) else
if BarColor and !SignalBar then if Color > 0 and p1 >= p1[1] then Color.GREEN else
                 if Color > 0 and p1 < p1[1] then Color.DARK_GREEN else
                 if Color < 0 and p1 <= p1[1] then Color.RED else
                 if Color < 0 and p1 > p1[1] then Color.DARK_RED else CreateColor(255,127,0) else
if SignalBar then if QQExlong==1 then color.MAGENTA else
                 if QQExshort==1 then color.BLUE else color.CURRENT else Color.CURRENT);

#### END//EOF
thank you very much @sam4cok
 
Top