#//@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)
#Converted and collected by Sam4COK@Samer800 08/2022
input Label = yes;
input SignalType = {"RSI", "MACD Signal", default "QQE RSI", "QQE RSX", "VJ - Killer"};
input RSI_Period = 14; # 'RSI Length'
input RSISmooth = 5; # 'RSI Smoothing'
input RSI_Src = close; # 'RSI Source'
input QQE = 4.238; # 'Fast QQE Factor'
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 = RSI_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 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(RSIndex, shortband[1]);
def cross_2 = Crosses(longband[1], RSIndex);
def trend = if cross_1 then 1 else
if cross_2 then -1 else nz(trend[1], 1);
def FastAtrRsiTL = if trend == 1 then longband else shortband;
#// Find all the QQE Crosses
def QQExlong = if FastAtrRsiTL < RSIndex then nz(QQExlong[1]) + 1 else 0;
def QQExshort = if FastAtrRsiTL > RSIndex then nz(QQExshort[1]) + 1 else 0;
#//Conditions
def QQELong = if QQExlong == 1 then FastAtrRsiTL[1] - 50 else na;
def QQEShort = if QQExshort == 1 then FastAtrRsiTL[1] - 50 else na;
#// Plotting
AddChartBubble(SignalType == SignalType."QQE RSI" and QQELong , low - 10 * TickSize(), "QQE RSI", Color.GREEN, no);
AddChartBubble(SignalType == SignalType."QQE RSI" and QQEShort, high + 10 * TickSize(), "QQE RSI", Color.RED, yes);
#### RSX RSI
def f8 = 100 * hlc3;
def f10 = nz(f8[1]);
def v8 = f8 - f10;
def f18 = 3 / (RSI_Period + 2);
def f20 = 1 - f18;
def f28 = f20 * nz(f28[1]) + f18 * v8;
def f30 = f18 * f28 + f20 * nz(f30[1]);
def vC = f28 * 1.5 - f30 * 0.5;
def f38 = f20 * nz(f38[1]) + f18 * vC;
def f40 = f18 * f38 + f20 * nz(f40[1]);
def v10 = f38 * 1.5 - f40 * 0.5;
def f48 = f20 * nz(f48[1]) + f18 * v10;
def f50 = f18 * f48 + f20 * nz(f50[1]);
def v14 = f48 * 1.5 - f50 * 0.5;
def f58 = f20 * nz(f58[1]) + f18 * AbsValue(v8);
def f60 = f18 * f58 + f20 * nz(f60[1]);
def v18 = f58 * 1.5 - f60 * 0.5;
def f68 = f20 * nz(f68[1]) + f18 * v18;
def f70 = f18 * f68 + f20 * nz(f70[1]);
def v1C = f68 * 1.5 - f70 * 0.5;
def f78 = f20 * nz(f78[1]) + f18 * v1C;
def f80 = f18 * f78 + f20 * nz(f80[1]);
def v20 = f78 * 1.5 - f80 * 0.5;
def f88;
def f90_ = if nz(f90_[1]) == 0 then 1 else if nz(f88[1]) <= nz(f90_[1]) then nz(f88[1]) + 1 else nz(f90_[1]) + 1;
f88 = if nz(f90_[1]) == 0 and (RSI_Period - 1 >= 5) then RSI_Period - 1 else 5;
def f0 = if f88 >= f90_ and f8 != f10 then 1 else 0;
def f90 = if f88 == f90_ and f0 == 0 then 0 else f90_;
def v4_ = if f88 < f90 and v20 > 0 then (v14 / v20 + 1) * 50 else 50;
def rsx = if v4_ > 100 then 100 else if v4_ < 0 then 0 else v4_;
def RsxMa = ExpAverage(rsx, RSISmooth);
def AtrRsx = AbsValue(RsxMa[1] - RsxMa);
def MaAtrRsx = ExpAverage(AtrRsx, Wilders_Period);
def darRsx = ExpAverage(MaAtrRsx, Wilders_Period) * QQE;
def DeltaFastAtrRsx = darRsx;
def RSXndex = RsxMa;
def RSXnewshortband = RSXndex + DeltaFastAtrRsx;
def RSXnewlongband = RSXndex - DeltaFastAtrRsx;
def RSXlongband = if (RSXndex[1] > RSXlongband[1]) and (RSXndex > RSXlongband[1]) then
Max(RSXlongband[1], RSXnewlongband) else RSXnewlongband;
def RSXshortband = if RSXndex[1] < RSXshortband[1] and RSXndex < RSXshortband[1]
then Min(RSXshortband[1], RSXnewshortband) else RSXnewshortband;
def RSXcross_1 = Crosses(RSXndex, RSXshortband[1]);
def RSXcross_2 = Crosses(RSXlongband[1], RSXndex);
def RSXtrend = if RSXcross_1 then 1 else
if RSXcross_2 then -1 else nz(RSXtrend[1], 1);
def RSXFastAtrRsiTL = if RSXtrend == 1 then RSXlongband else RSXshortband;
#// Find all the QQE Crosses
def RsxQQExlong = if RsxFastAtrRsiTL < RSxndex then nz(RsxQQExlong[1]) + 1 else 0;
def RsxQQExshort = if RsxFastAtrRsiTL > RSxndex then nz(RsxQQExshort[1]) + 1 else 0;
#//Conditions
def RsxQQELong = if RsxQQExlong == 1 then RsxFastAtrRsiTL[1] - 50 else na;
def RsxQQEShort = if RsxQQExshort == 1 then RsxFastAtrRsiTL[1] - 50 else na;
#// Plotting
AddChartBubble(SignalType == SignalType."QQE RSX" and RsxQQELong , low - 10 * TickSize(), "QQE RSX", Color.GREEN, no);
AddChartBubble(SignalType == SignalType."QQE RSX" and RsxQQEShort, high + 10 * TickSize(), "QQE RSX", Color.RED, yes);
####################
#// This source code is subject to the terms of the Mozilla Public License 2.0 at #https://mozilla.org/MPL/2.0/
#// © blackcat1402
#//@version=4
#study('[blackcat] L2 Reversal Labels','LLA', overlay=true, max_bars_back=5000, max_labels_count=500)
#Converted by Sam4COK@Samer800 08/2022
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
#barssince(Condition) =>
script barssince {
input Condition = 0;
def barssince = if Condition then 1 else barssince[1] + 1;
plot return = barssince;
}
def fast_ma = ExpAverage(close, fastLength);
def slow_ma = ExpAverage(close, slowLength);
def diff = fast_ma - slow_ma;
def dea = ExpAverage(diff, MACDLength);
def CrosUp = diff[1] > dea[1] and diff[2] < dea[2];
def CrosDn = diff[1] < dea[1] and diff[2] > dea[2];
def CrossUp = diff > dea and diff[1] < dea[1];
def CrossDn = diff < dea and diff[1] > dea[1];
def a1 = barssince(CrosUp[1]);
def a2 = barssince(CrosDn[1]);
def bottom_zone = (GetValue(close, a1 + 1) > close) and (diff > GetValue(diff, a1 + 1)) and CrossUp;
def top_zone = (GetValue(close, a2 + 1) < close) and (GetValue(diff, a2 + 1) > diff) and CrossDn;
AddChartBubble(if SignalType == SignalType."MACD Signal" then top_zone else na, high + 10 * TickSize(), "MACD", Color.RED, yes);
AddChartBubble(if SignalType == SignalType."MACD Signal" then bottom_zone else na, low - 10 * TickSize(), "MACD", Color.GREEN, no);
##########
#//@version=4
#study("RSI Swing Indicator", overlay=true, max_bars_back=1000)
#// RSI Settings for user
input rsiSource = close; # "RSI Source"
input rsiLength = 7; # "RSI Length"
input rsiOverbought = 70;# "RSI Overbought"
input rsiOvesold = 30; # "RSI Oversold"
input ShowLines = no;
DefineGlobalColor("Unconfirmed", Color.DARK_ORANGE);
DefineGlobalColor("Up", Color.UPTICK);
DefineGlobalColor("Down", Color.DOWNTICK);
#// RSI value based on inbuilt RSI
def rsiValue = RSI(Price = rsiSource, Length = rsiLength);
#// Get the current state
def isOverbought = rsiValue >= rsiOverbought;
def isOversold = rsiValue <= rsiOvesold;
def state = {default initialization, overbought, oversold};
def hh;
def ll;
def newMax;
def newMin;
def prevMaxH = GetValue(hh, 1);
def prevMinL = GetValue(ll, 1);
switch (state[1]) {
case initialization:
hh = high;
ll = low;
newMax = yes;
newMin = yes;
state = state.overbought;
case overbought:
if high < prevMaxH and isOversold {
state = state.oversold;
hh = prevMaxH;
ll = low;
newMax = no;
newMin = yes;
} else {
state = state.overbought;
if (isOverbought) {
hh = high;
newMax = yes;
} else {
hh = prevMaxH;
newMax = no;
}
ll = prevMinL;
newMin = no;
}
case oversold:
if low > prevMinL and isOverbought {
state = state.overbought;
hh = high;
ll = prevMinL;
newMax = yes;
newMin = no;
} else {
state = state.oversold;
hh = prevMaxH;
newMax = no;
if (high <= prevMinL and isOversold) {
ll = low;
newMin = yes;
} else {
ll = prevMinL;
newMin = no;
}
}
}
def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(high), 0, barNumber));
def newState = GetValue(state, 0) != GetValue(state, 1);
def offset = barCount - barNumber + 1;
def highPoint = state == state.overbought and high == hh;
def lowPoint = state == state.oversold and low == ll;
def lastH;
if highPoint and offset > 1 {
lastH = fold iH = 1 to offset with tH = high
while !IsNaN(tH) and !GetValue(newState, -iH) do
if GetValue(newMax, -iH) or iH == offset - 1 and GetValue(high, -iH) == tH then na else tH;
} else {
lastH = na;
}
def lastL;
if lowPoint and offset > 1 {
lastL = fold iL = 1 to offset with tL = low
while !IsNaN(tL) and !GetValue(newState, -iL) do
if GetValue(newMin, -iL) or iL == offset - 1 and GetValue(low, -iL) == tL then na else tL;
} else {
lastL = na;
}
def ZZ;
if barNumber == 1 {
ZZ = fold iF = 1 to offset with tP = na while IsNaN(tP) do
if GetValue(state, -iF) == GetValue(state.overbought, 0) then low else
if GetValue(state, -iF) == GetValue(state.oversold, 0) then high else na;
} else if barNumber == barCount {
ZZ = if highPoint or state == state.oversold and low > ll then high else
if lowPoint or state == state.overbought and high < hh then low else na;
} else {
ZZ = if !IsNaN(lastH) then lastH else if !IsNaN(lastL) then lastL else na;
}
def zzSave = if !IsNaN(ZZ) then close else GetValue(zzSave, 1);
def chg = close - GetValue(zzSave, 1);
def isUp = chg >= 0;
def isConf = AbsValue(chg) >= 0 or (IsNaN(GetValue(ZZ, 1)) and GetValue(isConf, 1));
plot ZZLine = nz(ZZ, na);
ZZLine.EnableApproximation();
ZZLine.SetHiding(!ShowLines);
ZZLine.AssignValueColor(if !isConf then GlobalColor("Unconfirmed") else
if isUp then GlobalColor("Up") else GlobalColor("Down"));
AddChartBubble(SignalType == SignalType."RSI" and !IsNaN(ZZ) and barNumber != 1, if isUp then high else low, "RSI", if !isConf then GlobalColor("Unconfirmed") else if isUp then GlobalColor("Down") else GlobalColor("Up"), isUp);
#//@version=3
#study("VJ - Killer BS",overlay=true)
#//======================================================================
#//Jurij
input VJ_left = 10; #input(title="h left"
input VJ_right = 10; #input(title="h right"
def h_left_low = lowest(low, VJ_left);
def h_left_high = highest(high, VJ_left);
def newlow = low <= h_left_low;
def newhigh = high >= h_left_high;
def central_bar_low = low[VJ_right + 1];
def central_bar_high = high[VJ_right + 1];
def full_zone_low = lowest(low, VJ_left + VJ_right + 1);
def full_zone_high = highest(high, VJ_left + VJ_right + 1);
def central_bar_is_highest = central_bar_high >= full_zone_high;
def central_bar_is_lowest = central_bar_low <= full_zone_low;
def CenrtralH = central_bar_is_highest;
def CentralL = central_bar_is_lowest ;
addChartBubble(SignalType == SignalType."VJ - Killer" and CenrtralH[-VJ_right-1], high + 10 * TickSize(), "VJ", Color.RED, Yes);
addChartBubble(SignalType == SignalType."VJ - Killer" and CentralL[-VJ_right-1], low - 10 * TickSize(), "VJ", Color.GREEN, No);
#### Lebel
AddLabel (Label, SignalType, Color.WHITE);
#AddLabel (Label,if SignalType == SignalType."RSI" then SignalType else
# if SignalType == SignalType."QQE RSI" then SignalType else
# if SignalType == SignalType."QQE RSX" then SignalType else
# if SignalType == SignalType."MACD Signal" then SignalType else SignalType, Color.WHITE);
#### END//