Support and Resistance Levels with Breaks [LUX] For ThinkOrSwim

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

Hello, I found this script on TradingView for support/resistance, and it seems very useful, I haven't seen one like it on TOS.
Does anyone here know how to convert it to Think Script?
Any help is greatly appreciated.
Thank you.
https://www.tradingview.com/script/JDFoWQbL-Support-and-Resistance-Levels-with-Breaks-LUX/
_____________________________________________

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version = 4
study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks", overlay = true , max_bars_back=1000)
//
toggleBreaks = input(true, title = "Show Breaks" )
leftBars = input(15, title = "Left Bars ")
rightBars = input(15, title = "Right Bars")
volumeThresh = input(20, title = "Volume Threshold")
//
highUsePivot = fixnan(pivothigh(leftBars, rightBars)[1])
lowUsePivot = fixnan(pivotlow(leftBars, rightBars)[1])
r1 = plot(highUsePivot, color=change(highUsePivot) ? na : #FF0000, linewidth=3, offset=-(rightBars+1), title="Resistance")
s1 = plot(lowUsePivot, color=change(lowUsePivot) ? na : #233dee, linewidth=3, offset=-(rightBars+1), title="Support")

//Volume %
short = ema(volume, 5)
long = ema(volume, 10)
osc = 100 * (short - long) / long


//For breaks with volume
plotshape(toggleBreaks and crossunder(close,lowUsePivot) and not (open - close < high - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny)
plotshape(toggleBreaks and crossover(close,highUsePivot ) and not(open - low > close - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny)

//For bull / bear wicks
plotshape(toggleBreaks and crossover(close,highUsePivot ) and open - low > close - open , title = "Break", text = 'Bull Wick', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny)
plotshape(toggleBreaks and crossunder(close,lowUsePivot) and open - close < high - open , title = "Break", text = 'Bear Wick', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny)


alertcondition(crossunder(close,lowUsePivot) and osc > volumeThresh , title = "Support Broken" , message = "Support Broken")
alertcondition(crossover(close,highUsePivot) and osc > volumeThresh, title = "Resistance Broken" , message = "Resistance Broken")
find below. pls test.
CSS:
#/ This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]"
# converted by Sam4Cok@Samer800 - 11/2022
declare upper;
input Signal   = {Default Arrows , Bubbles, None};
input rightBars   = 15;
input leftBars    = 15;
input volumeThresh  = 20;    # "Volume Threshold"
input hhLines     = yes;
input llLines     = yes;
input lhLines     = yes;
input hlLines     = yes;
input NoOfBreakoutBars = 1;
input hhBubble    = yes;
input llBubble    = yes;
input lhBubble    = yes;
input hlBubble    = yes;

def Sig  = if Signal==Signal.Arrows then 1 else
           if Signal==Signal.Bubbles then -1 else 0;
def na = Double.NaN;      # non-numeric values
def _H   = high;            # high price
def _L   = low;             # low price
def _C   = close;           # close price
def _O   = open;            # open price
#def _LL  = Lowestall(_L);   # lowest _L price
#def _HH  = highestall(_H);  # highest _H price

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph =  findpivots(_H, 1, leftBars, rightBars);
def pl =  findpivots(_L, -1, leftBars, rightBars);

def ph_1 = if !isnan(ph) then ph else ph_1[1];
def pl_1 = if !isnan(pl) then pl else pl_1[1];

def hh = if !isnan(ph) and ph > ph_1[1] then ph else na;
def ll = if !isnan(pl) and pl < pl_1[1] then pl else na;
def hl = if pl_1 > pl_1[1] then pl_1 else na;
def lh = if ph_1 < ph_1[1] then ph_1 else na;

#--------------------------------------------------------------
def hhPv = CompoundValue(1, if ph_1!=ph_1[1] then hhPv[1] else ph_1[1], ph_1[1]);
def llPv = CompoundValue(1, if pl_1!=pl_1[1] then llPv[1] else pl_1[1], pl_1[1]);

plot hhLine =  hhPv ;
plot llLine =  llPv;

hhLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hhLine.AssignValueColor(Color.RED);
llLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llLine.AssignValueColor(Color.GREEN);


addchartbubble(llBubble and ll, ll, "LL", color.RED, no);
addchartbubble(hhBubble and hh, hh, "HH", color.GREEN, yes);
addchartbubble(hlBubble and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(lhBubble and lh, lh, "LH", color.DARK_RED, yes);

# Breakuot
#/Volume %
def short = ExpAverage(volume, 5);
def long = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;


def hhValue = hh;
def llValue = ll;
def hhCount = if _C>hhPv then hhCount[1]+1 else 0;
def llCount = if _C<llPv then llCount[1]+1 else 0;

def BreakDn = llCount==NoOfBreakoutBars and !(open - close < high - open) and osc > volumeThresh;
def BreakUp = hhCount==NoOfBreakoutBars and !(open - low > close - open) and osc > volumeThresh;

plot SigDn = if sig>0 then if BreakDn then _H else na else na;
plot SigUp = if sig>0 then if BreakUp then _L else na else na;
SigDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SigUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SigDn.SetLineWeight(2);
SigDn.SetLineWeight(1);
SigUp.SetDefaultColor(Color.WHITE);
SigDn.SetDefaultColor(Color.YELLOW);

addchartbubble(sig<0 and BreakUp, low, "B", color.GREEN, no);
addchartbubble(sig<0 and BreakDn, high, "B", color.RED, yes);
 
Thanks Samer for converting the script, i did notice the HH/HL are not plotted dynamically, so there is a lag and have to refresh the charts to see them periodically, would you be able to take a look.. Thanks in advance
 
Thanks Samer for converting the script, i did notice the HH/HL are not plotted dynamically, so there is a lag and have to refresh the charts to see them periodically, would you be able to take a look.. Thanks in advance
i just mod the script slighlty. Not sure if can help since not used "range all" function. pls try if this help

CSS:
#/ This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]"
# converted by Sam4Cok@Samer800 - 11/2022
# Update - minor code change and option to extend the lines and show today only options.
declare upper;
input ShowTodayOnly = no;
input Signal   = {Arrows ,Default Bubbles, None};
input rightBars   = 15;
input leftBars    = 15;
input ExtendLines = no;
input volumeThresh  = 20;    # "Volume Threshold"
input hhLines     = yes;
input llLines     = yes;
input lhLines     = yes;
input hlLines     = yes;
input NoOfBreakoutBars = 1;
input hhBubble    = yes;
input llBubble    = yes;
input lhBubble    = yes;
input hlBubble    = yes;

def na = Double.NaN;      # non-numeric values
def Sig  = if Signal==Signal.Arrows then 1 else
           if Signal==Signal.Bubbles then -1 else
           if Signal==Signal.None then 0 else Sig[1];
def ExtLines = if !ExtendLines then isNaN(close) else
               if ExtendLines then 0 else ExtLines[1];
def today =  ShowTodayOnly and GetDay()!=GetLastDay();

def _H   = high;          # high price
def _L   = low;           # low price
def _C   = close;         # close price
def _O   = open;          # open price
def _V   = volume;
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 15;    # default Pivot Lookback Left
    input lbR  = 15;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph =  findpivots(_H, 1, leftBars, rightBars);
def pl =  findpivots(_L, -1, leftBars, rightBars);

def ph_1 = if !isnan(ph) then ph else ph_1[1];
def pl_1 = if !isnan(pl) then pl else pl_1[1];

def hh = if !isnan(ph) and ph > ph_1[1] then ph else na;
def ll = if !isnan(pl) and pl < pl_1[1] then pl else na;
def hl = if pl_1 > pl_1[1] then pl_1 else na;
def lh = if ph_1 < ph_1[1] then ph_1 else na;

#--------------------------------------------------------------
def hhPv = CompoundValue(1, if ph_1!=ph_1[1] then hhPv[1] else ph_1[1], ph_1[1]);
def llPv = CompoundValue(1, if pl_1!=pl_1[1] then llPv[1] else pl_1[1], pl_1[1]);

plot hhLine =  if hhPv==0 or ExtLines or today then na else hhPv[-1] ;
plot llLine =  if llPv==0 or ExtLines or today then na else llPv[-1];

hhLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hhLine.AssignValueColor(Color.RED);
llLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llLine.AssignValueColor(Color.GREEN);


addchartbubble(!today and llBubble and ll, ll, "LL", color.RED, no);
addchartbubble(!today and hhBubble and hh, hh, "HH", color.GREEN, yes);
addchartbubble(!today and hlBubble and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(!today and lhBubble and lh, lh, "LH", color.DARK_RED, yes);

# Breakuot
#/Volume %
def short = ExpAverage(_V, 5);
def long = ExpAverage(_V, 10);
def osc = 100 * (short - long) / long;


def hhValue = hh;
def llValue = ll;
def hhCount = if _C>hhPv then hhCount[1]+1 else 0;
def llCount = if _C<llPv then llCount[1]+1 else 0;
def up = (_O - _C) < (_H - _O);
def Dn = (_O - _L) > (_C - _O);

def BreakDn = llCount==NoOfBreakoutBars and !up and osc > volumeThresh;
def BreakUp = hhCount==NoOfBreakoutBars and !Dn and osc > volumeThresh;

plot SigDn = if sig>0 then if BreakDn then _H else na else na;
plot SigUp = if sig>0 then if BreakUp then _L else na else na;
SigDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SigUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SigDn.SetLineWeight(2);
SigDn.SetLineWeight(1);
SigUp.SetDefaultColor(Color.WHITE);
SigDn.SetDefaultColor(Color.YELLOW);

addchartbubble(!today and sig<0 and BreakUp, _L, "B", color.CYAN, no);
addchartbubble(!today and sig<0 and BreakDn, _H, "B", color.MAGENTA, yes);

#--- END CODE
 
  • Like
Reactions: IPA
i just mod the script slighlty. Not sure if can help since not used "range all" function. pls try if this help

CSS:
#/ This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]"
# converted by Sam4Cok@Samer800 - 11/2022
# Update - minor code change and option to extend the lines and show today only options.
declare upper;
input ShowTodayOnly = no;
input Signal   = {Arrows ,Default Bubbles, None};
input rightBars   = 15;
input leftBars    = 15;
input ExtendLines = no;
input volumeThresh  = 20;    # "Volume Threshold"
input hhLines     = yes;
input llLines     = yes;
input lhLines     = yes;
input hlLines     = yes;
input NoOfBreakoutBars = 1;
input hhBubble    = yes;
input llBubble    = yes;
input lhBubble    = yes;
input hlBubble    = yes;

def na = Double.NaN;      # non-numeric values
def Sig  = if Signal==Signal.Arrows then 1 else
           if Signal==Signal.Bubbles then -1 else
           if Signal==Signal.None then 0 else Sig[1];
def ExtLines = if !ExtendLines then isNaN(close) else
               if ExtendLines then 0 else ExtLines[1];
def today =  ShowTodayOnly and GetDay()!=GetLastDay();

def _H   = high;          # high price
def _L   = low;           # low price
def _C   = close;         # close price
def _O   = open;          # open price
def _V   = volume;
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 15;    # default Pivot Lookback Left
    input lbR  = 15;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph =  findpivots(_H, 1, leftBars, rightBars);
def pl =  findpivots(_L, -1, leftBars, rightBars);

def ph_1 = if !isnan(ph) then ph else ph_1[1];
def pl_1 = if !isnan(pl) then pl else pl_1[1];

def hh = if !isnan(ph) and ph > ph_1[1] then ph else na;
def ll = if !isnan(pl) and pl < pl_1[1] then pl else na;
def hl = if pl_1 > pl_1[1] then pl_1 else na;
def lh = if ph_1 < ph_1[1] then ph_1 else na;

#--------------------------------------------------------------
def hhPv = CompoundValue(1, if ph_1!=ph_1[1] then hhPv[1] else ph_1[1], ph_1[1]);
def llPv = CompoundValue(1, if pl_1!=pl_1[1] then llPv[1] else pl_1[1], pl_1[1]);

plot hhLine =  if hhPv==0 or ExtLines or today then na else hhPv[-1] ;
plot llLine =  if llPv==0 or ExtLines or today then na else llPv[-1];

hhLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hhLine.AssignValueColor(Color.RED);
llLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llLine.AssignValueColor(Color.GREEN);


addchartbubble(!today and llBubble and ll, ll, "LL", color.RED, no);
addchartbubble(!today and hhBubble and hh, hh, "HH", color.GREEN, yes);
addchartbubble(!today and hlBubble and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(!today and lhBubble and lh, lh, "LH", color.DARK_RED, yes);

# Breakuot
#/Volume %
def short = ExpAverage(_V, 5);
def long = ExpAverage(_V, 10);
def osc = 100 * (short - long) / long;


def hhValue = hh;
def llValue = ll;
def hhCount = if _C>hhPv then hhCount[1]+1 else 0;
def llCount = if _C<llPv then llCount[1]+1 else 0;
def up = (_O - _C) < (_H - _O);
def Dn = (_O - _L) > (_C - _O);

def BreakDn = llCount==NoOfBreakoutBars and !up and osc > volumeThresh;
def BreakUp = hhCount==NoOfBreakoutBars and !Dn and osc > volumeThresh;

plot SigDn = if sig>0 then if BreakDn then _H else na else na;
plot SigUp = if sig>0 then if BreakUp then _L else na else na;
SigDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SigUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SigDn.SetLineWeight(2);
SigDn.SetLineWeight(1);
SigUp.SetDefaultColor(Color.WHITE);
SigDn.SetDefaultColor(Color.YELLOW);

addchartbubble(!today and sig<0 and BreakUp, _L, "B", color.CYAN, no);
addchartbubble(!today and sig<0 and BreakDn, _H, "B", color.MAGENTA, yes);

#--- END CODE
Thanks Samer for working on this, i still find some lag in plotting the bubbles, i missed capturing the snapshot but will do it next trading day. Thanks again for looking into this
 
Thanks Samer for working on this, i still find some lag in plotting the bubbles, i missed capturing the snapshot but will do it next trading day. Thanks again for looking into this
this is last try for me :), pls check.
CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]", overlay = true ,  max_bars_back=1000)
# Converted and mod by Sam4Cok@Samer800   - 01/2023
input ShowBreaks  = yes; # title = "Show Breaks" )
input ShowHhLlLabel = no;
input src = hl2;
input rightBars  = 24;#, title = "Right Bars")
input leftBars  = 20;#(15, title = "Left Bars ")
input volumeThreshold  = 20;# title = "Volume Threshold")
#//
def na = Double.NaN;

script fixnan {
    input source = close;
    def fix = if !IsNaN(source) then source else fix[1];
    plot result = fix;
}
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL = 5;    # default Pivot Lookback Left
    input lbR = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph = FindPivots(high, 1 , leftBars, rightBars);
def pl = FindPivots(low, -1, leftBars, rightBars);
def highUsePivot = fixnan(ph);
def lowUsePivot  = fixnan(pl);
plot r1 = if isNaN(src) or highUsePivot==0 then na else highUsePivot;
r1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r1.SetDefaultColor(Color.MAGENTA);
plot s1 = if isNaN(src) or lowUsePivot==0 then na else lowUsePivot;
s1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s1.SetDefaultColor(Color.CYAN);

#//Volume %
def short = ExpAverage(volume, 5);
def long  = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;

#//For breaks with volume
def up = (open - close) < (high - open);
def Dn = (open - low)   > (close - open);
def CrossUp = ShowBreaks and src Crosses above highUsePivot;
def CrossDn = ShowBreaks and src Crosses below lowUsePivot;
def VolThresh = osc > volumeThreshold;

def volDn = CrossDn and !up and VolThresh;
def volUp = CrossUp and !Dn and VolThresh;

#//For bull / bear wicks
def BearWicks = CrossDn and up and VolThresh;
def BullWicks = CrossUp and Dn and VolThresh;
# Support Result breaks
def sBreakDn = CrossDn and up and !VolThresh;
def rBreakUp = CrossUp and Dn and !VolThresh;

#------ Strength
def strgUp = volUp*3 + BullWicks*2 + rBreakUp;
def StrgDn = volDn*3 + BearWicks*2 + sBreakDn;

AddChartBubble(StrgDn>2 ,high,"Strong", Color.RED, yes);
AddChartBubble(strgUp>2 , low,"Strong", Color.GREEN, no);
AddChartBubble(StrgDn>1 and StrgDn<=2 ,high,"Normal", Color.DARK_RED, yes);
AddChartBubble(strgUp>1 and strgUp<=2 ,low,"Normal", Color.DARK_GREEN, no);
AddChartBubble(StrgDn>0 and StrgDn<=1 ,high,"Weak", Color.LIGHT_RED, yes);
AddChartBubble(strgUp>0 and strgUp<=1 ,low,"Weak", Color.LIGHT_GREEN, no);
#--- HH/LL label

def hh = if highUsePivot > highUsePivot[1] then highUsePivot else na;
def ll = if lowUsePivot  < lowUsePivot[1]  then lowUsePivot else na;
def hl = if lowUsePivot  > lowUsePivot[1]  then lowUsePivot else na;
def lh = if highUsePivot < highUsePivot[1] then highUsePivot else na;

addchartbubble(ShowHhLlLabel and ll, ll, "LL", color.RED, no);
addchartbubble(ShowHhLlLabel and hh, hh, "HH", color.GREEN, yes);
addchartbubble(ShowHhLlLabel and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(ShowHhLlLabel and lh, lh, "LH", color.DARK_RED, yes);

#---- END
 
Hey @SleepyZ, Need your help if you can help resolving issues with below code (the lag in plotting HH/HL's dynamically and i have to refresh the charts periodically), i could have used the other scripts but i really like this script the way it plots the HH/HL's along with Support/Resistances. Thanks in Advance

https://usethinkscript.com/threads/...breaks-lux-for-thinkorswim.11556/#post-115680
@samer800 Already answered your question. ToS disabled rangeALL functions from updating in real time.

read more:
https://usethinkscript.com/threads/...-range-lagging-issues-due-to-tos-update.8794/
 
Last edited:
find below. pls test.
CSS:
#/ This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]"
# converted by Sam4Cok@Samer800 - 11/2022
declare upper;
input Signal   = {Default Arrows , Bubbles, None};
input rightBars   = 15;
input leftBars    = 15;
input volumeThresh  = 20;    # "Volume Threshold"
input hhLines     = yes;
input llLines     = yes;
input lhLines     = yes;
input hlLines     = yes;
input NoOfBreakoutBars = 1;
input hhBubble    = yes;
input llBubble    = yes;
input lhBubble    = yes;
input hlBubble    = yes;

def Sig  = if Signal==Signal.Arrows then 1 else
           if Signal==Signal.Bubbles then -1 else 0;
def na = Double.NaN;      # non-numeric values
def _H   = high;            # high price
def _L   = low;             # low price
def _C   = close;           # close price
def _O   = open;            # open price
#def _LL  = Lowestall(_L);   # lowest _L price
#def _HH  = highestall(_H);  # highest _H price

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph =  findpivots(_H, 1, leftBars, rightBars);
def pl =  findpivots(_L, -1, leftBars, rightBars);

def ph_1 = if !isnan(ph) then ph else ph_1[1];
def pl_1 = if !isnan(pl) then pl else pl_1[1];

def hh = if !isnan(ph) and ph > ph_1[1] then ph else na;
def ll = if !isnan(pl) and pl < pl_1[1] then pl else na;
def hl = if pl_1 > pl_1[1] then pl_1 else na;
def lh = if ph_1 < ph_1[1] then ph_1 else na;

#--------------------------------------------------------------
def hhPv = CompoundValue(1, if ph_1!=ph_1[1] then hhPv[1] else ph_1[1], ph_1[1]);
def llPv = CompoundValue(1, if pl_1!=pl_1[1] then llPv[1] else pl_1[1], pl_1[1]);

plot hhLine =  hhPv ;
plot llLine =  llPv;

hhLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hhLine.AssignValueColor(Color.RED);
llLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llLine.AssignValueColor(Color.GREEN);


addchartbubble(llBubble and ll, ll, "LL", color.RED, no);
addchartbubble(hhBubble and hh, hh, "HH", color.GREEN, yes);
addchartbubble(hlBubble and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(lhBubble and lh, lh, "LH", color.DARK_RED, yes);

# Breakuot
#/Volume %
def short = ExpAverage(volume, 5);
def long = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;


def hhValue = hh;
def llValue = ll;
def hhCount = if _C>hhPv then hhCount[1]+1 else 0;
def llCount = if _C<llPv then llCount[1]+1 else 0;

def BreakDn = llCount==NoOfBreakoutBars and !(open - close < high - open) and osc > volumeThresh;
def BreakUp = hhCount==NoOfBreakoutBars and !(open - low > close - open) and osc > volumeThresh;

plot SigDn = if sig>0 then if BreakDn then _H else na else na;
plot SigUp = if sig>0 then if BreakUp then _L else na else na;
SigDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SigUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SigDn.SetLineWeight(2);
SigDn.SetLineWeight(1);
SigUp.SetDefaultColor(Color.WHITE);
SigDn.SetDefaultColor(Color.YELLOW);

addchartbubble(sig<0 and BreakUp, low, "B", color.GREEN, no);
addchartbubble(sig<0 and BreakDn, high, "B", color.RED, yes);
Love this script,
this is last try for me :), pls check.
CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]", overlay = true ,  max_bars_back=1000)
# Converted and mod by Sam4Cok@Samer800   - 01/2023
input ShowBreaks  = yes; # title = "Show Breaks" )
input ShowHhLlLabel = no;
input src = hl2;
input rightBars  = 24;#, title = "Right Bars")
input leftBars  = 20;#(15, title = "Left Bars ")
input volumeThreshold  = 20;# title = "Volume Threshold")
#//
def na = Double.NaN;

script fixnan {
    input source = close;
    def fix = if !IsNaN(source) then source else fix[1];
    plot result = fix;
}
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL = 5;    # default Pivot Lookback Left
    input lbR = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph = FindPivots(high, 1 , leftBars, rightBars);
def pl = FindPivots(low, -1, leftBars, rightBars);
def highUsePivot = fixnan(ph);
def lowUsePivot  = fixnan(pl);
plot r1 = if isNaN(src) or highUsePivot==0 then na else highUsePivot;
r1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r1.SetDefaultColor(Color.MAGENTA);
plot s1 = if isNaN(src) or lowUsePivot==0 then na else lowUsePivot;
s1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s1.SetDefaultColor(Color.CYAN);

#//Volume %
def short = ExpAverage(volume, 5);
def long  = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;

#//For breaks with volume
def up = (open - close) < (high - open);
def Dn = (open - low)   > (close - open);
def CrossUp = ShowBreaks and src Crosses above highUsePivot;
def CrossDn = ShowBreaks and src Crosses below lowUsePivot;
def VolThresh = osc > volumeThreshold;

def volDn = CrossDn and !up and VolThresh;
def volUp = CrossUp and !Dn and VolThresh;

#//For bull / bear wicks
def BearWicks = CrossDn and up and VolThresh;
def BullWicks = CrossUp and Dn and VolThresh;
# Support Result breaks
def sBreakDn = CrossDn and up and !VolThresh;
def rBreakUp = CrossUp and Dn and !VolThresh;

#------ Strength
def strgUp = volUp*3 + BullWicks*2 + rBreakUp;
def StrgDn = volDn*3 + BearWicks*2 + sBreakDn;

AddChartBubble(StrgDn>2 ,high,"Strong", Color.RED, yes);
AddChartBubble(strgUp>2 , low,"Strong", Color.GREEN, no);
AddChartBubble(StrgDn>1 and StrgDn<=2 ,high,"Normal", Color.DARK_RED, yes);
AddChartBubble(strgUp>1 and strgUp<=2 ,low,"Normal", Color.DARK_GREEN, no);
AddChartBubble(StrgDn>0 and StrgDn<=1 ,high,"Weak", Color.LIGHT_RED, yes);
AddChartBubble(strgUp>0 and strgUp<=1 ,low,"Weak", Color.LIGHT_GREEN, no);
#--- HH/LL label

def hh = if highUsePivot > highUsePivot[1] then highUsePivot else na;
def ll = if lowUsePivot  < lowUsePivot[1]  then lowUsePivot else na;
def hl = if lowUsePivot  > lowUsePivot[1]  then lowUsePivot else na;
def lh = if highUsePivot < highUsePivot[1] then highUsePivot else na;

addchartbubble(ShowHhLlLabel and ll, ll, "LL", color.RED, no);
addchartbubble(ShowHhLlLabel and hh, hh, "HH", color.GREEN, yes);
addchartbubble(ShowHhLlLabel and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(ShowHhLlLabel and lh, lh, "LH", color.DARK_RED, yes);

#---- END
@samer800 love this script, is there anyway to change the color of the lines for each level? What I am referring to is, you change the color of each bubble level HH, HL, LL, HL but there are only two options for Highs and Lows. Can you add lines of script to change the color of the lines for all levels HH, HL, LL, HL?
 
I've been searching for a good support/resistance pivot study similar to LuxAlgo's (https://www.tradingview.com/script/JDFoWQbL-Support-and-Resistance-Levels-with-Breaks-LuxAlgo/). The closest I see is the Mobius Trend Pivots. However, I'd like more pivots around past pivot points. I tried to add multiple instances of the same study but still can't quite get it to recognize more intermediate support/resistance levels.

Are there any studies that can identify support/resistance levels?

Thank you
 
I've been searching for a good support/resistance pivot study similar to LuxAlgo's (https://www.tradingview.com/script/JDFoWQbL-Support-and-Resistance-Levels-with-Breaks-LuxAlgo/). The closest I see is the Mobius Trend Pivots. However, I'd like more pivots around past pivot points. I tried to add multiple instances of the same study but still can't quite get it to recognize more intermediate support/resistance levels.

Are there any studies that can identify support/resistance levels?

Thank you

LuxAlgo's support/resistance pivot study:
https://usethinkscript.com/threads/...levels-with-breaks-lux-for-thinkorswim.11556/

All other Support & Resistance studies available on the forum sorted by all-time popularity:
https://usethinkscript.com/search/1304261/?q=supportxresistance&t=post&c[title_only]=1&o=replies&g=1

And yet another sort: here are the Support & Resistance Indicators sorted by newest and trending:
https://usethinkscript.com/search/1304583/?q=supportxresistance&t=post&c[title_only]=1&o=date
 
Last edited:
Can one of you gurus code a Fib 50% to 61.8% cloud after each HL to HH, HL to HH, etc is formed
in this script?
https://usethinkscript.com/threads/...levels-with-breaks-lux-for-thinkorswim.11556/

I have tried to get CHAT GPT to create a cloud that will form once one of the HH to LL, HL to HH, LH to LL (you get it) but I think I broke Chat GPT. I am not sure what would be the most simple type of code to use as a base. I am putting in the one I use that shows these levels.
Code:
#/ This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]"
# converted by Sam4Cok@Samer800 - 11/2022
declare upper;
input Signal   = {Default Arrows , Bubbles, None};
input rightBars   = 15;
input leftBars    = 15;
input volumeThresh  = 20;    # "Volume Threshold"
input hhLines     = yes;
input llLines     = yes;
input lhLines     = yes;
input hlLines     = yes;
input NoOfBreakoutBars = 1;
input hhBubble    = yes;
input llBubble    = yes;
input lhBubble    = yes;
input hlBubble    = yes;

def Sig  = if Signal==Signal.Arrows then 1 else
           if Signal==Signal.Bubbles then -1 else 0;
def na = Double.NaN;      # non-numeric values
def _H   = high;            # high price
def _L   = low;             # low price
def _C   = close;           # close price
def _O   = open;            # open price
#def _LL  = Lowestall(_L);   # lowest _L price
#def _HH  = highestall(_H);  # highest _H price

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph =  findpivots(_H, 1, leftBars, rightBars);
def pl =  findpivots(_L, -1, leftBars, rightBars);

def ph_1 = if !isnan(ph) then ph else ph_1[1];
def pl_1 = if !isnan(pl) then pl else pl_1[1];

def hh = if !isnan(ph) and ph > ph_1[1] then ph else na;
def ll = if !isnan(pl) and pl < pl_1[1] then pl else na;
def hl = if pl_1 > pl_1[1] then pl_1 else na;
def lh = if ph_1 < ph_1[1] then ph_1 else na;

#--------------------------------------------------------------
def hhPv = CompoundValue(1, if ph_1!=ph_1[1] then hhPv[1] else ph_1[1], ph_1[1]);
def llPv = CompoundValue(1, if pl_1!=pl_1[1] then llPv[1] else pl_1[1], pl_1[1]);

plot hhLine =  hhPv ;
plot llLine =  llPv;

hhLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hhLine.AssignValueColor(Color.RED);
llLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llLine.AssignValueColor(Color.GREEN);


addchartbubble(llBubble and ll, ll, "LL", color.RED, no);
addchartbubble(hhBubble and hh, hh, "HH", color.GREEN, yes);
addchartbubble(hlBubble and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(lhBubble and lh, lh, "LH", color.DARK_RED, yes);

# Breakuot
#/Volume %
def short = ExpAverage(volume, 5);
def long = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;


def hhValue = hh;
def llValue = ll;
def hhCount = if _C>hhPv then hhCount[1]+1 else 0;
def llCount = if _C<llPv then llCount[1]+1 else 0;

def BreakDn = llCount==NoOfBreakoutBars and !(open - close < high - open) and osc > volumeThresh;
def BreakUp = hhCount==NoOfBreakoutBars and !(open - low > close - open) and osc > volumeThresh;

plot SigDn = if sig>0 then if BreakDn then _H else na else na;
plot SigUp = if sig>0 then if BreakUp then _L else na else na;
SigDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SigUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SigDn.SetLineWeight(2);
SigDn.SetLineWeight(1);
SigUp.SetDefaultColor(Color.WHITE);
SigDn.SetDefaultColor(Color.YELLOW);

addchartbubble(sig<0 and BreakUp, low, "B", color.GREEN, no);
addchartbubble(sig<0 and BreakDn, high, "B", color.RED, yes);

Here is what I am looking for. Is this possible? It doesn't really need the lines. If it is doable, may want to have the lines as an option.

Can one of you gurus code a Fib 50% to 61.8% cloud after each HL to HH, HL to HH, etc is formed
in this script?
https://usethinkscript.com/threads/...levels-with-breaks-lux-for-thinkorswim.11556/

I have tried to get CHAT GPT to create a cloud that will form once one of the HH to LL, HL to HH, LH to LL (you get it) but I think I broke Chat GPT. I am not sure what would be the most simple type of code to use as a base. I am putting in the one I use that shows these levels.
Code:
#/ This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]"
# converted by Sam4Cok@Samer800 - 11/2022
declare upper;
input Signal   = {Default Arrows , Bubbles, None};
input rightBars   = 15;
input leftBars    = 15;
input volumeThresh  = 20;    # "Volume Threshold"
input hhLines     = yes;
input llLines     = yes;
input lhLines     = yes;
input hlLines     = yes;
input NoOfBreakoutBars = 1;
input hhBubble    = yes;
input llBubble    = yes;
input lhBubble    = yes;
input hlBubble    = yes;

def Sig  = if Signal==Signal.Arrows then 1 else
           if Signal==Signal.Bubbles then -1 else 0;
def na = Double.NaN;      # non-numeric values
def _H   = high;            # high price
def _L   = low;             # low price
def _C   = close;           # close price
def _O   = open;            # open price
#def _LL  = Lowestall(_L);   # lowest _L price
#def _HH  = highestall(_H);  # highest _H price

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL+1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL+1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph =  findpivots(_H, 1, leftBars, rightBars);
def pl =  findpivots(_L, -1, leftBars, rightBars);

def ph_1 = if !isnan(ph) then ph else ph_1[1];
def pl_1 = if !isnan(pl) then pl else pl_1[1];

def hh = if !isnan(ph) and ph > ph_1[1] then ph else na;
def ll = if !isnan(pl) and pl < pl_1[1] then pl else na;
def hl = if pl_1 > pl_1[1] then pl_1 else na;
def lh = if ph_1 < ph_1[1] then ph_1 else na;

#--------------------------------------------------------------
def hhPv = CompoundValue(1, if ph_1!=ph_1[1] then hhPv[1] else ph_1[1], ph_1[1]);
def llPv = CompoundValue(1, if pl_1!=pl_1[1] then llPv[1] else pl_1[1], pl_1[1]);

plot hhLine =  hhPv ;
plot llLine =  llPv;

hhLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hhLine.AssignValueColor(Color.RED);
llLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
llLine.AssignValueColor(Color.GREEN);


addchartbubble(llBubble and ll, ll, "LL", color.RED, no);
addchartbubble(hhBubble and hh, hh, "HH", color.GREEN, yes);
addchartbubble(hlBubble and hl, hl, "HL", color.DARK_GREEN, no);
addchartbubble(lhBubble and lh, lh, "LH", color.DARK_RED, yes);

# Breakuot
#/Volume %
def short = ExpAverage(volume, 5);
def long = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;


def hhValue = hh;
def llValue = ll;
def hhCount = if _C>hhPv then hhCount[1]+1 else 0;
def llCount = if _C<llPv then llCount[1]+1 else 0;

def BreakDn = llCount==NoOfBreakoutBars and !(open - close < high - open) and osc > volumeThresh;
def BreakUp = hhCount==NoOfBreakoutBars and !(open - low > close - open) and osc > volumeThresh;

plot SigDn = if sig>0 then if BreakDn then _H else na else na;
plot SigUp = if sig>0 then if BreakUp then _L else na else na;
SigDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SigUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SigDn.SetLineWeight(2);
SigDn.SetLineWeight(1);
SigUp.SetDefaultColor(Color.WHITE);
SigDn.SetDefaultColor(Color.YELLOW);

addchartbubble(sig<0 and BreakUp, low, "B", color.GREEN, no);
addchartbubble(sig<0 and BreakDn, high, "B", color.RED, yes);

Here is what I am looking for. Is this possible? It doesn't really need the lines. If it is doable, may want to have the lines as an option.
@samer800 @halcyonguy @SleepyZ @Wiinii Is what I am asking possible? If so Can one of you help me out with this?
 

Attachments

  • HHLL-FIBS.jpg
    HHLL-FIBS.jpg
    160.4 KB · Views: 459
Last edited by a moderator:
@samer800 @halcyonguy @SleepyZ @Wiinii Is what I am asking possible? If so Can one of you help me out with this?
add this at the end of the code and see if this is what you want.

CSS:
input showFiboLines = yes;
input showZigZagLine = yes;
DefineGlobalColor("786", CreateColor(244,67,54));
DefineGlobalColor("618", CreateColor(129,199,132));
DefineGlobalColor("500", CreateColor(76,175,80));
DefineGlobalColor("382", CreateColor(0,150,136));
DefineGlobalColor("236", CreateColor(100,181,246));
DefineGlobalColor("000", CreateColor(95,95,95));

def bar = AbsValue(BarNumber());
def naPh = !isNaN(ph);
def naPl = !isNaN(pl);
def phPvt = highUsePivot;
def plPvt = lowUsePivot;
def phBar = if naPh then bar else phBar[1];
def plBar = if naPl then bar else plBar[1];
def max = max(phBar, plBar);
def maxBar = highestAll(max);
def plotCond = bar < maxBar or last[5] or !showFiboLines;
def ZigCond =  bar > maxBar - leftBars and showZigZagLine;
def upBar = phBar > plBar;

def fib1 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.236 else
                           plPvt + (phPvt - plPvt) * 0.236;
def fib2 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.382 else
                           plPvt + (phPvt - plPvt) * 0.382;
def fib3 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.500 else
                           plPvt + (phPvt - plPvt) * 0.500;
def fib4 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.618 else
                           plPvt + (phPvt - plPvt) * 0.618;
def fib5 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.786 else
                           plPvt + (phPvt - plPvt) * 0.786;
def fib6 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 1.000 else
                           plPvt + (phPvt - plPvt) * 1.000;
def zig = if naPh then high else
          if naPl then low else na;

plot fibo1 = fib1;
plot fibo2 = fib2;
plot fibo3 = fib3;
plot fibo4 = fib4;
plot fibo5 = fib5;
plot fibo6 = fib6;
plot ZigZag = if ZigCond then zig else na;
ZigZag.EnableApproximation();
ZigZag.SetStyle(Curve.SHORT_DASH);
fibo1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

ZigZag.SetDefaultColor(Color.YELLOW);
fibo1.SetDefaultColor(GlobalColor("000"));
fibo2.SetDefaultColor(GlobalColor("236"));
fibo3.SetDefaultColor(GlobalColor("382"));
fibo4.SetDefaultColor(GlobalColor("500"));
fibo5.SetDefaultColor(GlobalColor("618"));
fibo6.SetDefaultColor(GlobalColor("786"));
 
add this at the end of the code and see if this is what you want.

CSS:
input showFiboLines = yes;
input showZigZagLine = yes;
DefineGlobalColor("786", CreateColor(244,67,54));
DefineGlobalColor("618", CreateColor(129,199,132));
DefineGlobalColor("500", CreateColor(76,175,80));
DefineGlobalColor("382", CreateColor(0,150,136));
DefineGlobalColor("236", CreateColor(100,181,246));
DefineGlobalColor("000", CreateColor(95,95,95));

def bar = AbsValue(BarNumber());
def naPh = !isNaN(ph);
def naPl = !isNaN(pl);
def phPvt = highUsePivot;
def plPvt = lowUsePivot;
def phBar = if naPh then bar else phBar[1];
def plBar = if naPl then bar else plBar[1];
def max = max(phBar, plBar);
def maxBar = highestAll(max);
def plotCond = bar < maxBar or last[5] or !showFiboLines;
def ZigCond =  bar > maxBar - leftBars and showZigZagLine;
def upBar = phBar > plBar;

def fib1 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.236 else
                           plPvt + (phPvt - plPvt) * 0.236;
def fib2 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.382 else
                           plPvt + (phPvt - plPvt) * 0.382;
def fib3 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.500 else
                           plPvt + (phPvt - plPvt) * 0.500;
def fib4 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.618 else
                           plPvt + (phPvt - plPvt) * 0.618;
def fib5 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.786 else
                           plPvt + (phPvt - plPvt) * 0.786;
def fib6 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 1.000 else
                           plPvt + (phPvt - plPvt) * 1.000;
def zig = if naPh then high else
          if naPl then low else na;

plot fibo1 = fib1;
plot fibo2 = fib2;
plot fibo3 = fib3;
plot fibo4 = fib4;
plot fibo5 = fib5;
plot fibo6 = fib6;
plot ZigZag = if ZigCond then zig else na;
ZigZag.EnableApproximation();
ZigZag.SetStyle(Curve.SHORT_DASH);
fibo1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

ZigZag.SetDefaultColor(Color.YELLOW);
fibo1.SetDefaultColor(GlobalColor("000"));
fibo2.SetDefaultColor(GlobalColor("236"));
fibo3.SetDefaultColor(GlobalColor("382"));
fibo4.SetDefaultColor(GlobalColor("500"));
fibo5.SetDefaultColor(GlobalColor("618"));
fibo6.SetDefaultColor(GlobalColor("786"));
Thanks SAMER...I got this error:
Expected double at 124:5
Expected double at 125:5
Expected double
No such variable: highUsePivot at 124:13
No such variable: lowUsePivot at 125:13
No such variable: last at 130:32
Expected double at 124:5
Expected double at 125:5
No such variable: highUsePivot at 124:13
No such variable: lowUsePivot at 125:13
No such variable: last at 130:32
 
Thanks SAMER...I got this error:
Expected double at 124:5
Expected double at 125:5
Expected double
No such variable: highUsePivot at 124:13
No such variable: lowUsePivot at 125:13
No such variable: last at 130:32
Expected double at 124:5
Expected double at 125:5
No such variable: highUsePivot at 124:13
No such variable: lowUsePivot at 125:13
No such variable: last at 130:32
not sure which code you are referring to. Check this complete code.

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]", overlay = true ,  max_bars_back=1000)
# Converted and mod by Sam4Cok@Samer800   - 01/2023
# Update Added Fibo LEvel - 09/2023
#input ShowBreaks  = yes; # title = "Show Breaks" )
input ShowHhLlLabel = yes;
input src = hl2;
input breakout = {"Volume", "Price",Default "None"};
input RepaintingType   = {default "On", "Off: Candle Confirmation", "Off: High & Low"};# 'Repainting'
input rightBars  = 24;#, title = "Right Bars")
input leftBars  = 20;#(15, title = "Left Bars ")
input volumeThreshold  = 20;# title = "Volume Threshold")

#//
def na = Double.NaN;
def last = isNaN(close);
def VolBreak = breakout==breakout."Volume";
def PriceBreak = breakout==breakout."Price";

#def rTon = input_repType == input_repType."On";
#def rTcc = input_repType == input_repType."Off: Candle Confirmation";
#def rThv = input_repType == input_repType."Off: High & Low";
#---- Colors
DefineGlobalColor("green" , CreateColor(8, 153, 129));
DefineGlobalColor("red"   , CreateColor(255, 82, 82));

script fixnan {
    input source = close;
    def fix = if !IsNaN(source) then source else fix[1];
    plot result = fix;
}
#drawBox(condition, y1, y2, color) =>
script drawBox {
    input condition = yes;
    input y1        = high;
    input y2        = low;
    def boxHi = if condition then y1 else boxHi[1];
    def boxLo = if condition then y2 else boxLo[1];
    plot ph = if !IsNaN(close[5]) then if !boxHi then high else boxHi else Double.NaN;
    plot pl = if !IsNaN(close[5]) then if !boxLo then low else boxLo else Double.NaN;
}
#repaint(c1, c2, c3) =>
script repaint {
    input type = "On";
    input c1 = no;
    input c2 = no;
    input c3 = no;
    def rTon = type == "On";
    def rTcc = type == "Off: Candle Confirmation";
    def rThv = type == "Off: High & Low";
    def repaint = if rTon then c1 else if rThv then c2 else if rTcc then c3 else Double.NaN;
    plot out = repaint;
}
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL = 5;    # default Pivot Lookback Left
    input lbR = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph = FindPivots(high, 1 , leftBars, rightBars);
def pl = FindPivots(low, -1, leftBars, rightBars);
def highUsePivot = fixnan(ph);
def lowUsePivot  = fixnan(pl);
#// Box Height
def s_yLoc = if low[1]  > low[-1]  then low[-1] else low[1];
def r_yLoc = if high[1] > high[-1] then high[1] else high[-1];

plot r1 = drawBox((highUsePivot - highUsePivot[1]), highUsePivot, r_yLoc).ph;
plot r2 = drawBox((highUsePivot - highUsePivot[1]), highUsePivot, r_yLoc).pl;

plot s1 = drawBox((lowUsePivot - lowUsePivot[1]), s_yLoc, lowUsePivot).ph;
plot s2 = drawBox((lowUsePivot - lowUsePivot[1]), s_yLoc, lowUsePivot).pl;

#plot r1 = if IsNaN(src) or highUsePivot == 0 then na else highUsePivot;
r1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r1.SetDefaultColor(GlobalColor("green"));
r2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r2.SetDefaultColor(GlobalColor("green"));
#plot s1 = if IsNaN(src) or lowUsePivot == 0 then na else lowUsePivot;
s1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s1.SetDefaultColor(GlobalColor("red"));
s2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s2.SetDefaultColor(GlobalColor("red"));

#//Volume %
def short = ExpAverage(volume, 5);
def long  = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;

#//For breaks with volume
def up = (open - close) < (high - open);
def Dn = (open - low)   > (close - open);
def u11 = (VolBreak and close crosses below s2);
def u22 = (VolBreak and low crosses below s2);
def u33 = (VolBreak and close crosses below s2) and !isNaN(close[1]);
def o11 = (VolBreak and close crosses above r1);
def o22 = (VolBreak and high crosses above r1);
def o33 = (VolBreak and close crosses above r1) and !isNaN(close[1]);
def CrossUp = repaint(RepaintingType, u11, u22, u33);
def CrossDn = repaint(RepaintingType, o11, o22, o33);
#def CrossUp = VolBreak and src crosses above highUsePivot;
#def CrossDn = VolBreak and src crosses below lowUsePivot;
def VolThresh = osc > volumeThreshold;

def volDn = CrossDn and !up and VolThresh;
def volUp = CrossUp and !Dn and VolThresh;

#//For bull / bear wicks
def BearWicks = CrossDn and up and VolThresh;
def BullWicks = CrossUp and Dn and VolThresh;
# Support Result breaks
def sBreakDn = CrossDn and up and !VolThresh;
def rBreakUp = CrossUp and Dn and !VolThresh;

#------ Strength
def strgUp = volUp * 3 + BullWicks * 2 + rBreakUp;
def StrgDn = volDn * 3 + BearWicks * 2 + sBreakDn;

AddChartBubble(StrgDn > 2 , low, "Strong", Color.GREEN, no);
AddChartBubble(strgUp > 2 , high, "Strong", Color.RED, yes);
AddChartBubble(StrgDn > 1 and StrgDn <= 2 , low, "Normal", Color.DARK_GREEN, no);
AddChartBubble(strgUp > 1 and strgUp <= 2 , high, "Normal", Color.DARK_RED, yes);
AddChartBubble(StrgDn > 0 and StrgDn <= 1 , low, "Weak", Color.LIGHT_GREEN, no);
AddChartBubble(strgUp > 0 and strgUp <= 1 , high, "Weak", Color.PINK, yes);
#--- HH/LL label

def hh = if highUsePivot > highUsePivot[1] then highUsePivot else na;
def ll = if lowUsePivot  < lowUsePivot[1]  then lowUsePivot else na;
def hl = if lowUsePivot  > lowUsePivot[1]  then lowUsePivot else na;
def lh = if highUsePivot < highUsePivot[1] then highUsePivot else na;

AddChartBubble(ShowHhLlLabel and ll, ll, "LL", Color.RED, no);
AddChartBubble(ShowHhLlLabel and hh, hh, "HH", Color.GREEN, yes);
AddChartBubble(ShowHhLlLabel and hl, hl, "HL", Color.DARK_GREEN, no);
AddChartBubble(ShowHhLlLabel and lh, lh, "LH", Color.DARK_RED, yes);

#// Breakout Event
def sBreak;# = na
def rBreak;# = na
def sLabel;#
def rLabel;
def u1 = (close crosses below s2);
def u2 = (low crosses below s2);
def u3 = (close crosses below s2) and !isNaN(close);
def o1 = (close crosses above r1);
def o2 = (high crosses above r1);
def o3 = (close crosses above r1) and !isNaN(close);
def cu = repaint(RepaintingType, u1, u2, u3);
def co = repaint(RepaintingType, o1, o2, o3);

if cu and isNaN(sBreak[1]) {
        sBreak = yes;
        rBreak = na;
        sLabel = if PriceBreak then s2 else na;
        rLabel = na;
    } else
if co and isNaN(rBreak[1]) {
        sBreak = na;
        rBreak = yes;
        sLabel = na;
        rLabel = if PriceBreak then r1 else na;
    } else {
        sBreak = na;
        rBreak = na;
        sLabel = na;
        rLabel = na;
}

AddChartBubble(!isNaN(sLabel), sLabel, "break", Color.RED, yes);
AddChartBubble(!isNaN(rLabel), rLabel, "break", Color.GREEN, no);

#---- END
input showFiboLines = yes;
input showZigZagLine = yes;
DefineGlobalColor("786", CreateColor(244,67,54));
DefineGlobalColor("618", CreateColor(129,199,132));
DefineGlobalColor("500", CreateColor(76,175,80));
DefineGlobalColor("382", CreateColor(0,150,136));
DefineGlobalColor("236", CreateColor(100,181,246));
DefineGlobalColor("000", CreateColor(95,95,95));

def bar = AbsValue(BarNumber());
def naPh = !isNaN(ph);
def naPl = !isNaN(pl);
def phPvt = highUsePivot;
def plPvt = lowUsePivot;
def phBar = if naPh then bar else phBar[1];
def plBar = if naPl then bar else plBar[1];
def max = max(phBar, plBar);
def maxBar = highestAll(max);
def plotCond = bar < maxBar or last[5] or !showFiboLines;
def ZigCond =  bar > maxBar - leftBars and showZigZagLine;
def upBar = phBar > plBar;

def fib1 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.236 else
                           plPvt + (phPvt - plPvt) * 0.236;
def fib2 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.382 else
                           plPvt + (phPvt - plPvt) * 0.382;
def fib3 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.500 else
                           plPvt + (phPvt - plPvt) * 0.500;
def fib4 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.618 else
                           plPvt + (phPvt - plPvt) * 0.618;
def fib5 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.786 else
                           plPvt + (phPvt - plPvt) * 0.786;
def fib6 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 1.000 else
                           plPvt + (phPvt - plPvt) * 1.000;
def zig = if naPh then high else
          if naPl then low else na;

plot fibo1 = fib1;
plot fibo2 = fib2;
plot fibo3 = fib3;
plot fibo4 = fib4;
plot fibo5 = fib5;
plot fibo6 = fib6;
plot ZigZag = if ZigCond then zig else na;
ZigZag.EnableApproximation();
ZigZag.SetStyle(Curve.SHORT_DASH);
fibo1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

ZigZag.SetDefaultColor(Color.YELLOW);
fibo1.SetDefaultColor(GlobalColor("000"));
fibo2.SetDefaultColor(GlobalColor("236"));
fibo3.SetDefaultColor(GlobalColor("382"));
fibo4.SetDefaultColor(GlobalColor("500"));
fibo5.SetDefaultColor(GlobalColor("618"));
fibo6.SetDefaultColor(GlobalColor("786"));



#-- END of CODe
 
not sure which code you are referring to. Check this complete code.

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
#// © LuxAlgo
#study(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks [LuxAlgo]", overlay = true ,  max_bars_back=1000)
# Converted and mod by Sam4Cok@Samer800   - 01/2023
# Update Added Fibo LEvel - 09/2023
#input ShowBreaks  = yes; # title = "Show Breaks" )
input ShowHhLlLabel = yes;
input src = hl2;
input breakout = {"Volume", "Price",Default "None"};
input RepaintingType   = {default "On", "Off: Candle Confirmation", "Off: High & Low"};# 'Repainting'
input rightBars  = 24;#, title = "Right Bars")
input leftBars  = 20;#(15, title = "Left Bars ")
input volumeThreshold  = 20;# title = "Volume Threshold")

#//
def na = Double.NaN;
def last = isNaN(close);
def VolBreak = breakout==breakout."Volume";
def PriceBreak = breakout==breakout."Price";

#def rTon = input_repType == input_repType."On";
#def rTcc = input_repType == input_repType."Off: Candle Confirmation";
#def rThv = input_repType == input_repType."Off: High & Low";
#---- Colors
DefineGlobalColor("green" , CreateColor(8, 153, 129));
DefineGlobalColor("red"   , CreateColor(255, 82, 82));

script fixnan {
    input source = close;
    def fix = if !IsNaN(source) then source else fix[1];
    plot result = fix;
}
#drawBox(condition, y1, y2, color) =>
script drawBox {
    input condition = yes;
    input y1        = high;
    input y2        = low;
    def boxHi = if condition then y1 else boxHi[1];
    def boxLo = if condition then y2 else boxLo[1];
    plot ph = if !IsNaN(close[5]) then if !boxHi then high else boxHi else Double.NaN;
    plot pl = if !IsNaN(close[5]) then if !boxLo then low else boxLo else Double.NaN;
}
#repaint(c1, c2, c3) =>
script repaint {
    input type = "On";
    input c1 = no;
    input c2 = no;
    input c3 = no;
    def rTon = type == "On";
    def rTcc = type == "Off: Candle Confirmation";
    def rThv = type == "Off: High & Low";
    def repaint = if rTon then c1 else if rThv then c2 else if rTcc then c3 else Double.NaN;
    plot out = repaint;
}
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL = 5;    # default Pivot Lookback Left
    input lbR = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
def ph = FindPivots(high, 1 , leftBars, rightBars);
def pl = FindPivots(low, -1, leftBars, rightBars);
def highUsePivot = fixnan(ph);
def lowUsePivot  = fixnan(pl);
#// Box Height
def s_yLoc = if low[1]  > low[-1]  then low[-1] else low[1];
def r_yLoc = if high[1] > high[-1] then high[1] else high[-1];

plot r1 = drawBox((highUsePivot - highUsePivot[1]), highUsePivot, r_yLoc).ph;
plot r2 = drawBox((highUsePivot - highUsePivot[1]), highUsePivot, r_yLoc).pl;

plot s1 = drawBox((lowUsePivot - lowUsePivot[1]), s_yLoc, lowUsePivot).ph;
plot s2 = drawBox((lowUsePivot - lowUsePivot[1]), s_yLoc, lowUsePivot).pl;

#plot r1 = if IsNaN(src) or highUsePivot == 0 then na else highUsePivot;
r1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r1.SetDefaultColor(GlobalColor("green"));
r2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
r2.SetDefaultColor(GlobalColor("green"));
#plot s1 = if IsNaN(src) or lowUsePivot == 0 then na else lowUsePivot;
s1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s1.SetDefaultColor(GlobalColor("red"));
s2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
s2.SetDefaultColor(GlobalColor("red"));

#//Volume %
def short = ExpAverage(volume, 5);
def long  = ExpAverage(volume, 10);
def osc = 100 * (short - long) / long;

#//For breaks with volume
def up = (open - close) < (high - open);
def Dn = (open - low)   > (close - open);
def u11 = (VolBreak and close crosses below s2);
def u22 = (VolBreak and low crosses below s2);
def u33 = (VolBreak and close crosses below s2) and !isNaN(close[1]);
def o11 = (VolBreak and close crosses above r1);
def o22 = (VolBreak and high crosses above r1);
def o33 = (VolBreak and close crosses above r1) and !isNaN(close[1]);
def CrossUp = repaint(RepaintingType, u11, u22, u33);
def CrossDn = repaint(RepaintingType, o11, o22, o33);
#def CrossUp = VolBreak and src crosses above highUsePivot;
#def CrossDn = VolBreak and src crosses below lowUsePivot;
def VolThresh = osc > volumeThreshold;

def volDn = CrossDn and !up and VolThresh;
def volUp = CrossUp and !Dn and VolThresh;

#//For bull / bear wicks
def BearWicks = CrossDn and up and VolThresh;
def BullWicks = CrossUp and Dn and VolThresh;
# Support Result breaks
def sBreakDn = CrossDn and up and !VolThresh;
def rBreakUp = CrossUp and Dn and !VolThresh;

#------ Strength
def strgUp = volUp * 3 + BullWicks * 2 + rBreakUp;
def StrgDn = volDn * 3 + BearWicks * 2 + sBreakDn;

AddChartBubble(StrgDn > 2 , low, "Strong", Color.GREEN, no);
AddChartBubble(strgUp > 2 , high, "Strong", Color.RED, yes);
AddChartBubble(StrgDn > 1 and StrgDn <= 2 , low, "Normal", Color.DARK_GREEN, no);
AddChartBubble(strgUp > 1 and strgUp <= 2 , high, "Normal", Color.DARK_RED, yes);
AddChartBubble(StrgDn > 0 and StrgDn <= 1 , low, "Weak", Color.LIGHT_GREEN, no);
AddChartBubble(strgUp > 0 and strgUp <= 1 , high, "Weak", Color.PINK, yes);
#--- HH/LL label

def hh = if highUsePivot > highUsePivot[1] then highUsePivot else na;
def ll = if lowUsePivot  < lowUsePivot[1]  then lowUsePivot else na;
def hl = if lowUsePivot  > lowUsePivot[1]  then lowUsePivot else na;
def lh = if highUsePivot < highUsePivot[1] then highUsePivot else na;

AddChartBubble(ShowHhLlLabel and ll, ll, "LL", Color.RED, no);
AddChartBubble(ShowHhLlLabel and hh, hh, "HH", Color.GREEN, yes);
AddChartBubble(ShowHhLlLabel and hl, hl, "HL", Color.DARK_GREEN, no);
AddChartBubble(ShowHhLlLabel and lh, lh, "LH", Color.DARK_RED, yes);

#// Breakout Event
def sBreak;# = na
def rBreak;# = na
def sLabel;#
def rLabel;
def u1 = (close crosses below s2);
def u2 = (low crosses below s2);
def u3 = (close crosses below s2) and !isNaN(close);
def o1 = (close crosses above r1);
def o2 = (high crosses above r1);
def o3 = (close crosses above r1) and !isNaN(close);
def cu = repaint(RepaintingType, u1, u2, u3);
def co = repaint(RepaintingType, o1, o2, o3);

if cu and isNaN(sBreak[1]) {
        sBreak = yes;
        rBreak = na;
        sLabel = if PriceBreak then s2 else na;
        rLabel = na;
    } else
if co and isNaN(rBreak[1]) {
        sBreak = na;
        rBreak = yes;
        sLabel = na;
        rLabel = if PriceBreak then r1 else na;
    } else {
        sBreak = na;
        rBreak = na;
        sLabel = na;
        rLabel = na;
}

AddChartBubble(!isNaN(sLabel), sLabel, "break", Color.RED, yes);
AddChartBubble(!isNaN(rLabel), rLabel, "break", Color.GREEN, no);

#---- END
input showFiboLines = yes;
input showZigZagLine = yes;
DefineGlobalColor("786", CreateColor(244,67,54));
DefineGlobalColor("618", CreateColor(129,199,132));
DefineGlobalColor("500", CreateColor(76,175,80));
DefineGlobalColor("382", CreateColor(0,150,136));
DefineGlobalColor("236", CreateColor(100,181,246));
DefineGlobalColor("000", CreateColor(95,95,95));

def bar = AbsValue(BarNumber());
def naPh = !isNaN(ph);
def naPl = !isNaN(pl);
def phPvt = highUsePivot;
def plPvt = lowUsePivot;
def phBar = if naPh then bar else phBar[1];
def plBar = if naPl then bar else plBar[1];
def max = max(phBar, plBar);
def maxBar = highestAll(max);
def plotCond = bar < maxBar or last[5] or !showFiboLines;
def ZigCond =  bar > maxBar - leftBars and showZigZagLine;
def upBar = phBar > plBar;

def fib1 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.236 else
                           plPvt + (phPvt - plPvt) * 0.236;
def fib2 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.382 else
                           plPvt + (phPvt - plPvt) * 0.382;
def fib3 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.500 else
                           plPvt + (phPvt - plPvt) * 0.500;
def fib4 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.618 else
                           plPvt + (phPvt - plPvt) * 0.618;
def fib5 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 0.786 else
                           plPvt + (phPvt - plPvt) * 0.786;
def fib6 = if plotCond then na else
             if upBar then phPvt - (phPvt - plPvt) * 1.000 else
                           plPvt + (phPvt - plPvt) * 1.000;
def zig = if naPh then high else
          if naPl then low else na;

plot fibo1 = fib1;
plot fibo2 = fib2;
plot fibo3 = fib3;
plot fibo4 = fib4;
plot fibo5 = fib5;
plot fibo6 = fib6;
plot ZigZag = if ZigCond then zig else na;
ZigZag.EnableApproximation();
ZigZag.SetStyle(Curve.SHORT_DASH);
fibo1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
fibo6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

ZigZag.SetDefaultColor(Color.YELLOW);
fibo1.SetDefaultColor(GlobalColor("000"));
fibo2.SetDefaultColor(GlobalColor("236"));
fibo3.SetDefaultColor(GlobalColor("382"));
fibo4.SetDefaultColor(GlobalColor("500"));
fibo5.SetDefaultColor(GlobalColor("618"));
fibo6.SetDefaultColor(GlobalColor("786"));



#-- END of CODe
Sorry about that. Not sure what I did wrong. I did just paste it under the original code. Are you getting the 61.8$ and 50% cloud when you test? I am not getting a cloud. Thank you for you time on this by the way. You really are a selfless person! You have assisted a lot of ppl.
Don't really need a cloud but would love to have an option to show only a cloud between the 61.8% and the 50%. Otherwise this is perfect! Thanks!
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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