Reversal Signals [LuxAlgo] for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
LEgfuwz.png

Author Message:
he Reversal Signals indicator is a technical analysis tool that aims to identify when a trend is fading and potentially starting to reverse.

As a counter-trend tool, the Reversal Signals indicator aims to solve the problem of several technical analysis indicators that perform well during trending markets but struggle in ranging markets. By understanding the key concepts and applications of the tool, traders can enhance their market timing and improve their trading strategies.

Note: It's important to explore the settings of the indicator to customize to your own usage & display as there are various options available as covered below.
More Details : https://www.tradingview.com/v/qTWl7ZOy/

CODE:
CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
#https://www.tradingview.com/v/qTWl7ZOy/
#// © LuxAlgo
#indicator("Reversal Signals [LuxAlgo]", "LuxAlgo - Reversal Signals"
# Converted by Sam4Cok@Samer800    - 06/2023

input MomentumPhase  = {default Completed, Detailed, None};#, 'Display Phases'
input SupportAndResistanceLevels = {Circles, "Step Line", default "Step Line w/ Diamonds", "Don't Show Sup/Res Levels"};
input MomentumPhaseRiskLevels = {Circles, "Step Line",default "Don't Show Mom Phase Risk Levels"};
input TrendExhaustionPhase  = {default Completed, Detailed, None};    #"Display Phases'
input DisplayTrendExhaustionPhaseRiskLevels  = no;       # 'Trend Exhaustion Phase Risk Levels'
input DisplayTrendExhaustionPhaseTargetLevels  = no;     # 'Trend Exhaustion Phase Target Levels'
input PhaseSpecificTradeSetupOptions = {Momentum, Exhaustion, Qualified, default None};
input PriceFlipsAgainstThePhaseSpecificTradeSetups = no; # 'Price Flips against the Phase Specific Trade Setups'

def na = Double.NaN;
def natr = ATR(Length = 1) / 3;
def Diamonds = SupportAndResistanceLevels == SupportAndResistanceLevels."Step Line w/ Diamonds";
def srL = SupportAndResistanceLevels!=SupportAndResistanceLevels."Don't Show Sup/Res Levels";
def rsB = MomentumPhaseRiskLevels!=MomentumPhaseRiskLevels."Don't Show Mom Phase Risk Levels";
def rsE = DisplayTrendExhaustionPhaseRiskLevels;
def ttE = DisplayTrendExhaustionPhaseTargetLevels;
def war = PriceFlipsAgainstThePhaseSpecificTradeSetups;
#--- Colors
DefineGlobalColor("noC", Color.BLACK);
DefineGlobalColor("rdC", CreateColor(242, 54, 69));
DefineGlobalColor("DrdC", CreateColor(94, 6, 13));
DefineGlobalColor("gnC", CreateColor(8, 153, 129));
DefineGlobalColor("DgnC", CreateColor(4, 78, 66));
DefineGlobalColor("whC", Color.WHITE);
DefineGlobalColor("blC", CreateColor(41, 98, 255));
DefineGlobalColor("grC", CreateColor(120, 123, 134));
DefineGlobalColor("bgC", CreateColor(0, 188, 212));

#// General Calculations
#def BnoShw = false
def Bcmpltd    = MomentumPhase == MomentumPhase.Completed;
def BnoShw     = if MomentumPhase == MomentumPhase.None then no else yes;

#var noShw = false
def cmpltd    = TrendExhaustionPhase == TrendExhaustionPhase.Completed;
def noShw     = if TrendExhaustionPhase == TrendExhaustionPhase.None then no else yes;

#// User Defined Types

#type bar
def o = open;
def h = high;
def l = low;
def c = close;
def i = AbsValue(CompoundValue(1, BarNumber(), 0));

#// Functions / Methods
#f_xLX(_p, _l) =>
script f_xLX {
    input _p = close;
    input _l = low;
    def f_xLX = (_l > _p and _l < _p[1]) or (_l < _p and _l > _p[1]);
    plot out = f_xLX;
}
#// Calculations

def ptLB = SupportAndResistanceLevels == SupportAndResistanceLevels.Circles;
def ptRS = MomentumPhaseRiskLevels == MomentumPhaseRiskLevels.Circles;

#/ Momentum Phase

def con = c < c[4];
def SbSC;
def SsSC;
if con {
    SbSC = if SbSC[1] == 9 then 1 else SbSC[1] + 1;
    SsSC = 0;
} else {
    SsSC = if SsSC[1] == 9 then 1 else SsSC[1] + 1;
    SbSC = 0;
}

def pbS = (l <= l[3] and l <= l[2]) or (l[1] <= l[3] and l[1] <= l[2]);

plot "1" = if BnoShw and !Bcmpltd and SbSC == 1 then SbSC else na;
plot "2" = if BnoShw and !Bcmpltd and SbSC == 2 then SbSC else na;
plot "3" = if BnoShw and !Bcmpltd and SbSC == 3 then SbSC else na;
plot "4" = if BnoShw and !Bcmpltd and SbSC == 4 then SbSC else na;
plot "5" = if BnoShw and !Bcmpltd and SbSC == 5 then SbSC else na;
plot "6" = if BnoShw and !Bcmpltd and SbSC == 6 then SbSC else na;
plot "7" = if BnoShw and !Bcmpltd and SbSC == 7 then SbSC else na;
plot "8" = if BnoShw and !Bcmpltd and SbSC == 8 and !pbS then SbSC else na;
plot "9" = if BnoShw and SbSC == 9 and !pbS then l - natr else na;#, 'Bullish Momentum Phases'
plot "9_" = if BnoShw and SbSC[1] == 8 and SsSC == 1 then l - natr else na;#, 'Bullish Momentum Phases'

AddChartBubble(BnoShw and !Bcmpltd and SbSC == 8 and pbS, h + natr, "P\n8", GlobalColor("DgnC"), yes);
AddChartBubble(BnoShw and SbSC == 9 and pbS, l - natr, "P", GlobalColor("gnC"), no);# Perfect Bullish Momentum Phases'

"9".SetLineWeight(2);
"9_".SetLineWeight(2);

"1".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"2".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"3".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"4".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"5".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"6".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"7".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"8".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"9".SetPaintingStrategy(PaintingStrategy.SQUARES);
"9_".SetPaintingStrategy(PaintingStrategy.SQUARES);

"1".SetDefaultColor(GlobalColor("gnC"));
"2".SetDefaultColor(GlobalColor("gnC"));
"3".SetDefaultColor(GlobalColor("gnC"));
"4".SetDefaultColor(GlobalColor("gnC"));
"5".SetDefaultColor(GlobalColor("gnC"));
"6".SetDefaultColor(GlobalColor("gnC"));
"7".SetDefaultColor(GlobalColor("gnC"));
"8".SetDefaultColor(GlobalColor("gnC"));
"9".SetDefaultColor(Color.CYAN);
"9_".SetDefaultColor(Color.CYAN);

def bC8  = SbSC[1] == 8 and SsSC == 1;
def sR   = Highest(h, 9);
#bSR  = 0.0
def bSR = CompoundValue(1, if SbSC == 9 or bC8 then sR else if c > bSR[1] then 0 else bSR[1], 0);
plot ResLevels = if (srL and bSR) > 0 then bSR else na;#, "Resistance Levels", color.new(rdC, 50), 2, ptLB)
plot diamond = if srL and bSR > 0 and bSR != bSR[1] and Diamonds then bSR else na;

diamond.SetLineWeight(2);
diamond.SetDefaultColor(GlobalColor("rdC"));
diamond.SetPaintingStrategy(PaintingStrategy.POINTS);
ResLevels.SetDefaultColor(GlobalColor("rdC"));
ResLevels.SetPaintingStrategy(if ptLB then PaintingStrategy.POINTS else PaintingStrategy.LINE);

def SbSL;
def SbSH;
if SbSC == 1 {
    SbSL = l;
    SbSH = SbSH[1];
} else
if SbSC > 0 {
    SbSL = if !Min(l, SbSL[1]) then l else Min(l, SbSL[1]);
    SbSH = if l == SbSL then h else SbSH[1];
} else {
    SbSL = SbSL[1];
    SbSH = SbSH[1];
}
def bSD_ = 2 * SbSL - SbSH;
def bSD = CompoundValue(1, if SbSC == 9 then bSD_ else if c < bSD[1] or SsSC == 9 then 0 else bSD[1], 0);

plot BullMom = if (rsB and bSD) > 0 then bSD else na;#, "Bullish Momentum Risk Levels"
BullMom.SetPaintingStrategy(if ptRS then PaintingStrategy.POINTS else PaintingStrategy.LINE);
BullMom.SetDefaultColor(GlobalColor("blC"));

def psS = (h >= h[3] and h >= h[2]) or (h[1] >= h[3] and h[1] >= h[2]);

plot "n1" = if BnoShw and !Bcmpltd and SsSC == 1 then SsSC else na;
plot "n2" = if BnoShw and !Bcmpltd and SsSC == 2 then SsSC else na;
plot "n3" = if BnoShw and !Bcmpltd and SsSC == 3 then SsSC else na;
plot "n4" = if BnoShw and !Bcmpltd and SsSC == 4 then SsSC else na;
plot "n5" = if BnoShw and !Bcmpltd and SsSC == 5 then SsSC else na;
plot "n6" = if BnoShw and !Bcmpltd and SsSC == 6 then SsSC else na;
plot "n7" = if BnoShw and !Bcmpltd and SsSC == 7 then SsSC else na;
plot "n8" = if BnoShw and !Bcmpltd and SsSC == 8 and !psS then SsSC else na;
plot "n9" = if BnoShw and SsSC == 9 and !psS then h + natr else na; #'Completed Bearish Momentum Phases'
plot "n9_" = if BnoShw and SsSC[1] == 8 and SbSC == 1 then h + natr else na; #'Early Bearish Momentum Phases'

AddChartBubble(BnoShw and !Bcmpltd and SsSC == 8 and  psS, h + natr, "P\n8", GlobalColor("DrdC"), yes);
AddChartBubble(BnoShw and SsSC == 9 and psS, h + natr, "P", GlobalColor("rdC"), yes);#'Perfect Bearish Momentum Phases'

"n9".SetLineWeight(2);
"n9_".SetLineWeight(2);
"n1".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n2".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n3".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n4".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n5".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n6".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n7".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n8".SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
"n9".SetPaintingStrategy(PaintingStrategy.SQUARES);
"n9_".SetPaintingStrategy(PaintingStrategy.SQUARES);

"n1".SetDefaultColor(GlobalColor("rdC"));
"n2".SetDefaultColor(GlobalColor("rdC"));
"n3".SetDefaultColor(GlobalColor("rdC"));
"n4".SetDefaultColor(GlobalColor("rdC"));
"n5".SetDefaultColor(GlobalColor("rdC"));
"n6".SetDefaultColor(GlobalColor("rdC"));
"n7".SetDefaultColor(GlobalColor("rdC"));
"n8".SetDefaultColor(GlobalColor("rdC"));
"n9".SetDefaultColor(Color.MAGENTA);
"n9_".SetDefaultColor(Color.MAGENTA);

def sC8  = SsSC[1] == 8 and SbSC == 1;
def sS   = Lowest(low, 9);
def sSS = CompoundValue(1, if SsSC == 9 or sC8 then sS else if c < sSS[1] then 0 else sSS[1], 0);

plot SupLevels = if (srL and sSS) > 0 then sSS else na;# "Support Levels"
plot SupDiamonds = if (srL and sSS) > 0 and sSS != sSS[1] and Diamonds then sSS else na;
#SupLevels.SetLineWeight(2);
SupLevels.SetDefaultColor(GlobalColor("gnC"));
SupLevels.SetPaintingStrategy(if ptLB then PaintingStrategy.POINTS else PaintingStrategy.LINE);
SupDiamonds.SetLineWeight(2);
SupDiamonds.SetDefaultColor(GlobalColor("gnC"));
SupDiamonds.SetPaintingStrategy(PaintingStrategy.SQUARES);

def SsSH;
def SsSL;
if SsSC == 1 {
    SsSH = h;
    SsSL = SsSL[1];
} else
if SsSC > 0 {
    SsSH = Max(h, SsSH[1]);
    SsSL = if h == SsSH then l else SsSL[1];
} else {
    SsSH = SsSH[1];
    SsSL = SsSL[1];
}

def sSD = CompoundValue(1, if SsSC == 9 then 2 * SsSH - SsSL else if c > sSD[1] or SbSC == 9 then 0 else sSD[1], 0);
plot BearMom = if (rsB and sSD) > 0 then sSD else na; # "Bearish Momentum Risk Levels"
BearMom.SetPaintingStrategy(if ptRS then PaintingStrategy.POINTS else PaintingStrategy.LINE);
BearMom.SetDefaultColor(GlobalColor("blC"));

#// Trend Exhaustion Phase
def CbC8;
def CbCC;
def C_bCC;
def bCC = c <= l[2];
def b13 = c <= l[2] and l >= CbC8[1];
#def sbC;# = false
def sbC = if SbSC == 9 and CbCC[1] == 0 and (pbS or pbS[1]) then yes else
          if SsSC == 9 or CbCC[1] == 13 or c > bSR then no else sbC[1];

C_bCC = if sbC then
        if SbSC == 9 then
        if bCC then 1 else 0 else
        if bCC then CbCC[1] + 1 else CbCC[1] else 0;
CbCC = if C_bCC == 13 and b13 then C_bCC - 1 else C_bCC;

CbC8 = if CbCC == 8 and CbCC != CbCC[1] then c else CbC8[1];

def shwBC = noShw and !cmpltd and sbC and CbCC != CbCC[1];

plot "01" = if shwBC and CbCC == 1  then CbCC else na;
plot "02" = if shwBC and CbCC == 2  then CbCC else na;
plot "03" = if shwBC and CbCC == 3  then CbCC else na;
plot "04" = if shwBC and CbCC == 4  then CbCC else na;
plot "05" = if shwBC and CbCC == 5  then CbCC else na;
plot "06" = if shwBC and CbCC == 6  then CbCC else na;
plot "07" = if shwBC and CbCC == 7  then CbCC else na;
plot "08" = if shwBC and CbCC == 8  then CbCC else na;
plot "09" = if shwBC and CbCC == 9  then CbCC else na;
plot "10" = if shwBC and CbCC == 10  then CbCC else na;
plot "11" = if shwBC and CbCC == 11  then CbCC else na;
plot "12" = if shwBC and CbCC == 12  then CbCC else na;
plot "+" = if noShw and !cmpltd and sbC and CbCC == CbCC[1] and CbCC == 12 and b13 then l - natr else na;
AddChartBubble(noShw and sbC and CbCC != CbCC[1] and CbCC == 13, l - natr, "E", GlobalColor("DgnC"), no);# 'Completed Bullish Exhaustions'

"+".SetLineWeight(2);

"01".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"02".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"03".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"04".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"05".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"06".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"07".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"08".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"09".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"10".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"11".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"12".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"+".SetPaintingStrategy(PaintingStrategy.TRIANGLES);

"01".SetDefaultColor(GlobalColor("gnC"));
"02".SetDefaultColor(GlobalColor("gnC"));
"03".SetDefaultColor(GlobalColor("gnC"));
"04".SetDefaultColor(GlobalColor("gnC"));
"05".SetDefaultColor(GlobalColor("gnC"));
"06".SetDefaultColor(GlobalColor("gnC"));
"07".SetDefaultColor(GlobalColor("gnC"));
"08".SetDefaultColor(GlobalColor("gnC"));
"09".SetDefaultColor(GlobalColor("gnC"));
"10".SetDefaultColor(GlobalColor("gnC"));
"11".SetDefaultColor(GlobalColor("gnC"));
"12".SetDefaultColor(GlobalColor("gnC"));
"+".SetDefaultColor(GlobalColor("gnC"));

def CbCLt;
def CbCHt;
def CbCL;
def CbCH;
if CbCC == 1 {
    CbCLt = l;
    CbCHt = h;
    CbCL  = CbCL[1];
    CbCH  = CbCH[1];
} else
if sbC {
    CbCHt = Max(h, CbCHt[1]);
    CbCLt = if !Min(l, CbCLt[1]) then l else Min(l, CbCLt[1]);
    CbCL  = if h == CbCHt then l else CbCL[1];
    CbCH  = if l == CbCLt then h else CbCH[1];
} else {
    CbCLt = CbCLt[1];
    CbCHt = CbCHt[1];
    CbCL  = CbCL[1];
    CbCH  = CbCH[1];
}
def CbCD;
def CsCC;
def CsC8;
def bCT_ = 2 * CbCHt - CbCL;
def bCT = CompoundValue(1, if CbCC == 13 then bCT_ else
          if c > bCT[1] or (CbCD[1] == 0 and CsCC == 13) then 0 else bCT[1], 0);

plot BullExhTarget = if (ttE and bCT) > 0 then bCT else na;#, "Bullish Exhaustion Target Levels"
BullExhTarget.SetPaintingStrategy(PaintingStrategy.POINTS);
BullExhTarget.SetDefaultColor(GlobalColor("grC"));

def bCD_ = 2 * CbCLt - CbCH;
def bCD = CompoundValue(1, if CbCC == 13 then bCD_ else
          if c < bCD[1] or (bCT == 0 and CsCC == 13) then 0 else bCD[1], 0);

CbCD = bCD;
plot BullExhRisk = if (rsE and bCD) > 0 then bCD else na;#, "Bullish Exhaustion Risk Levels"
BullExhRisk.SetPaintingStrategy(PaintingStrategy.POINTS);
BullExhRisk.SetDefaultColor(GlobalColor("bgC"));

def sCC = c >= h[2];
def s13 = c >= h[2] and h <= CsC8[1];

#var ssC = false
def ssC = if SsSC == 9 and CsCC[1] == 0 and (psS or psS[1]) then yes else
          if SbSC == 9 or CsCC[1] == 13 or c < sSS then no else ssC[1];

def C_sCC = if ssC then if SsSC == 9 then if sCC then 1 else 0 else
            if sCC then CsCC[1] + 1 else CsCC[1] else 0;
CsCC = if C_sCC == 13 and s13 then C_sCC - 1 else C_sCC;

CsC8 = if CsCC == 8 and CsCC != CsCC[1] then c else CsC8[1];

def shwSC = noShw and !cmpltd and ssC and CsCC != CsCC[1];

plot "n01" = if shwSC and CsCC == 1 then CsCC else na;# , '', shpD, locB, noC, 0, '?' , rdC, dspN)
plot "n02" = if shwSC and CsCC == 2 then CsCC else na;
plot "n03" = if shwSC and CsCC == 3 then CsCC else na;
plot "n04" = if shwSC and CsCC == 4 then CsCC else na;
plot "n05" = if shwSC and CsCC == 5 then CsCC else na;
plot "n06" = if shwSC and CsCC == 6 then CsCC else na;
plot "n07" = if shwSC and CsCC == 7 then CsCC else na;
plot "n08" = if shwSC and CsCC == 8 then CsCC else na;
plot "n09" = if shwSC and CsCC == 9 then CsCC else na;
plot "n10" = if shwSC and CsCC == 10 then CsCC else na;
plot "n11" = if shwSC and CsCC == 11 then CsCC else na;
plot "n12" = if shwSC and CsCC == 12 then CsCC else na;
plot "n+" = if noShw and !cmpltd and ssC and CsCC == CsCC[1] and CsCC == 12 and s13 then l - natr else na;
AddChartBubble(noShw and ssC and CsCC != CsCC[1] and CsCC == 13, h + natr, "E", GlobalColor("DrdC"), yes);

"n+".SetLineWeight(2);

"n01".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n02".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n03".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n04".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n05".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n06".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n07".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n08".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n09".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n10".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n11".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n12".SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
"n+".SetPaintingStrategy(PaintingStrategy.TRIANGLES);

"n01".SetDefaultColor(GlobalColor("rdC"));
"n02".SetDefaultColor(GlobalColor("rdC"));
"n03".SetDefaultColor(GlobalColor("rdC"));
"n04".SetDefaultColor(GlobalColor("rdC"));
"n05".SetDefaultColor(GlobalColor("rdC"));
"n06".SetDefaultColor(GlobalColor("rdC"));
"n07".SetDefaultColor(GlobalColor("rdC"));
"n08".SetDefaultColor(GlobalColor("rdC"));
"n09".SetDefaultColor(GlobalColor("rdC"));
"n10".SetDefaultColor(GlobalColor("rdC"));
"n11".SetDefaultColor(GlobalColor("rdC"));
"n12".SetDefaultColor(GlobalColor("rdC"));
"n+".SetDefaultColor(GlobalColor("rdC"));

def CsCLt;
def CsCHt;
def CsCL;
def CsCH;
def CsCT;
if CsCC == 1 {
    CsCLt = l;
    CsCHt = h;
    CsCL = CsCL[1];
    CsCH = CsCH[1];
} else
if ssC {
    CsCHt = Max(h, CsCHt[1]);
    CsCLt = if ! Min(l, CsCLt[1]) then l else Min(l, CsCLt[1]);
    CsCL = if h == CsCHt then l else CsCL[1];
    CsCH = if l == CsCLt then h else CsCH[1];
} else {
    CsCLt = CsCLt[1];
    CsCHt = CsCHt[1];
    CsCL = CsCL[1];
    CsCH = CsCH[1];
}

def sCD_ = 2 * CsCHt - CsCL;
def sCD = CompoundValue(1, if CsCC == 13 then sCD_ else
                           if c > sCD[1] or (CsCT[1] == 0 and CbCC == 13) then 0 else sCD[1], 0);
plot BearExhRisk = if (rsE and sCD) > 0 then sCD else na;    # "Bearish Exhaustion Risk Levels"
BearExhRisk.SetPaintingStrategy(PaintingStrategy.POINTS);
BearExhRisk.SetDefaultColor(GlobalColor("bgC"));

def sCT_ = 2 * CsCLt - CsCH;
def sCT  = CompoundValue(1, if CsCC == 13 then sCT_ else
                            if c < sCT[1] or (sCD == 0 and CbCC == 13) then 0 else sCT[1], 0);
CsCT = sCT;
plot BearExhTarget = if (ttE and sCT) > 0 then sCT else na;   # "Bearish Exhaustion Target Levels"
BearExhTarget.SetPaintingStrategy(PaintingStrategy.POINTS);
BearExhTarget.SetDefaultColor(GlobalColor("grC"));

#// Trade Setups
def bPFc;
def sPFc;
def lTrd;
def sTrd;
def bubS;
def lblS;
def bubL;
def lblL;
def lTrd1;
def sTrd1;

def bBl9 = if SbSC == 9 then i else bBl9[1];
def bBp9 = if bBl9 != bBl9[1] then bBl9[1] else bBp9[1];
def bB13 = if CbCC == 13 then i else bB13[1];

def sBl9 = if SsSC == 9 then i else sBl9[1];
def sBp9 = if sBl9 != sBl9[1] then sBl9[1] else sBp9[1];
def sB13 = if CsCC == 13 then i else sB13[1];

def trdS = PhaseSpecificTradeSetupOptions != PhaseSpecificTradeSetupOptions.None;
def trdMom = PhaseSpecificTradeSetupOptions == PhaseSpecificTradeSetupOptions.Momentum;
def trdExh = PhaseSpecificTradeSetupOptions == PhaseSpecificTradeSetupOptions.Exhaustion;

def sQC  = (sBl9 > sB13) and (sB13 > sBp9) and (sBp9 > bBl9);
def sPFO = if trdMom then (SsSC == 9 or sC8) else
           if trdExh then CsCC[5] == 13 else (SsSC == 9 and sQC);

def ssPF = if sPFO then yes else if sPFc[1] then no else ssPF[1];
    sPFc = ssPF and c < c[4] and c[1] > c[5];

def bQC  = (bBl9 > bB13) and (bB13 > bBp9) and (bBp9 > sBl9);
def bPFO = if trdMom then (SbSC == 9 or bC8) else
           if trdExh then CbCC[5] == 13 else SbSC == 9 and bQC;

def sbPF = if bPFO then yes else if bPFc[1] then no else sbPF[1];
    bPFc = sbPF and c > c[4] and c[1] < c[5];

if sPFc and trdS {
    bubS = 1;
    lblS = 1;
    sTrd = yes;
    lTrd = no;
    } else
if war and sTrd1[1] and o < c and SsSC == 2 and !lTrd1[1] {
    bubS = 2;
    lblS = no;
    sTrd = no;
    lTrd = lTrd[1];
    } else
if war and sTrd1[1] and o < c and ((sSD[1] != 0 and c > sSD[1]) or (sCD[1] != 0 and c > sCD[1])) {
    bubS = 3;
    lblS = no;
    sTrd = no;
    lTrd = lTrd[1];
    } else {
    bubS = no;
    lblS = no;
    sTrd = sTrd1[1];
    lTrd = lTrd1[1];
}

if bPFc and trdS {
    bubL = 1;
    lblL = 1;
    sTrd1 = no;
    lTrd1 = yes;
    } else
if war and lTrd and o > c and SbSC == 2 and !sTrd {
    bubL = 2;
    lblL = no;
    sTrd1 = sTrd1[1];
    lTrd1 = no;
    } else
if war and lTrd and o > c and (c < bSD[1] or c < bCD[1]) {
    bubL = 3;
    lblL = no;
    sTrd1 = sTrd1[1];
    lTrd1 = no;
    } else {
    bubL = 0;
    lblL = 0;
    sTrd1 = sTrd;
    lTrd1 = lTrd;
}
AddChartBubble(bubS==1, h, "S", Color.YELLOW, yes);
AddChartBubble(bubS==2, l, "!!", Color.YELLOW, no);
AddChartBubble(bubS==3, l, "!!", Color.YELLOW, no);

AddChartBubble(bubL==1, l, "L", Color.CYAN, no);
AddChartBubble(bubL==2, h, "!!", Color.CYAN, yes);
AddChartBubble(bubL==3, h, "!!", Color.CYAN, yes);

#-- END
 
Anyone trading this and, does it repaint?

I don't see any cause of repainting, but you may check it live trading.

To master reading this indicator, dive right in and experiment. Add the indicator to your chart and observe how it interacts with other indicators. Hands-on experience is key.

Adjustments may be needed based on the market, ticker, and timeframe. Try different settings aligned with your trading strategy.

To assess an indicator's value, evaluate its performance across various timeframes and instruments. Analyze its historical performance.

Most importantly, come back and relay your experience.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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