A chart that compares relative strength against spy

poopyhead5928

New member
Something similar to this screenshot where you can input 8 tickers and it will compare its' strength against spy.

ST.jpg
 
Solution
Something similar to this screenshot where you can input 8 tickers and it will compare its' strength against spy.


this compares 8 stocks to 1 stock, to calculate the relative strength (a ratio of each pair)
default compare stock , SPY


Code:
# compare_8stocks_rel_str_00

#https://usethinkscript.com/threads/a-chart-that-compares-relative-strength-against-spy.12637/
#UnAnswered A chart that compares relative strength against spy
# Thread starterpoopyhead5928  Start dateSep 12, 2022

#Something similar to this screenshot where you can input 8 tickers and it will compare its' strength against spy.


# copy formulas from  RelativeStrength , TD Ameritrade

declare lower;

input CorrelationWithSecurity = "SPY";
def cls_corr =...

halcyonguy

Well-known member
VIP
Lifetime
Something similar to this screenshot where you can input 8 tickers and it will compare its' strength against spy.


this compares 8 stocks to 1 stock, to calculate the relative strength (a ratio of each pair)
default compare stock , SPY


Code:
# compare_8stocks_rel_str_00

#https://usethinkscript.com/threads/a-chart-that-compares-relative-strength-against-spy.12637/
#UnAnswered A chart that compares relative strength against spy
# Thread starterpoopyhead5928  Start dateSep 12, 2022

#Something similar to this screenshot where you can input 8 tickers and it will compare its' strength against spy.


# copy formulas from  RelativeStrength , TD Ameritrade

declare lower;

input CorrelationWithSecurity = "SPY";
def cls_corr = close(CorrelationWithSecurity);
#plot RS = if close_corr == 0 then 0 else close / close_corr;
#RS.SetDefaultColor(GetColor(6));
#def sr = CompoundValue("historical data" = RS, "visible data" = if IsNaN(sr[1]) then RS else sr[1]);
#plot SRatio =  sr;
#SRatio.SetDefaultColor(GetColor(5));

#----------------

input Symbol1 = "AAPL";
def cls1 = close(Symbol1);
def rs1 = if cls_corr == 0 then 0 else cls1/cls_corr;
plot z1 = rs1;

input Symbol2 = "META";
def cls2 = close(Symbol2);
def rs2 = if cls_corr == 0 then 0 else cls2/cls_corr;
plot z2 = rs2;

input Symbol3 = "PYPL";
def cls3 = close(Symbol3);
def rs3 = if cls_corr == 0 then 0 else cls3/cls_corr;
plot z3 = rs3;

input Symbol4 = "AMD";
def cls4 = close(Symbol4);
def rs4 = if cls_corr == 0 then 0 else cls4/cls_corr;
plot z4 = rs4;

input Symbol5 = "TSLA";
def cls5 = close(Symbol5);
def rs5 = if cls_corr == 0 then 0 else cls5/cls_corr;
plot z5 = rs5;

input Symbol6 = "AMZN";
def cls6 = close(Symbol6);
def rs6 = if cls_corr == 0 then 0 else cls6/cls_corr;
plot z6 = rs6;

input Symbol7 = "MSFT";
def cls7 = close(Symbol7);
def rs7 = if cls_corr == 0 then 0 else cls7/cls_corr;
plot z7 = rs7;

input Symbol8 = "QQQ";
def cls8 = close(Symbol8);
def rs8 = if cls_corr == 0 then 0 else cls8/cls_corr;
plot z8 = rs8;

#------------------------------

# draw bubbles , to the right of last bar, with symbol name
def off = 5;
def x = (!isnan(close[off]) and isnan(close[off-1]) );

addchartbubble(x, rs1[off], Symbol1, z1.TakeValueColor(), yes);
addchartbubble(x, rs2[off], Symbol2, z2.TakeValueColor(), yes);
addchartbubble(x, rs3[off], Symbol3, z3.TakeValueColor(), yes);
addchartbubble(x, rs4[off], Symbol4, z4.TakeValueColor(), yes);
addchartbubble(x, rs5[off], Symbol5, z5.TakeValueColor(), yes);
addchartbubble(x, rs6[off], Symbol6, z6.TakeValueColor(), yes);
addchartbubble(x, rs7[off], Symbol7, z7.TakeValueColor(), yes);
addchartbubble(x, rs8[off], Symbol8, z8.TakeValueColor(), yes);


def offc = off + 24;
def xc = (!isnan(close[offc]) and isnan(close[offc-1]) );
def minc = min(rs1,min(rs2,min(rs3,min(rs4,min(rs5,min(rs6,min(rs7,rs8)))))));
addchartbubble(xc, minc[offc], 
"Compared\n" +
"     to\n" +
"     " + 
CorrelationWithSecurity 
, Color.yellow, yes);
#
#

fL7Ldkh.jpg
 
Solution

halcyonguy

Well-known member
VIP
Lifetime
an updated version, that normalizes the RS's

this calculates the relative strength of a stock compared to another (default, SPY)
the first stock RS sets the size of the plots.
can enter up to 7 more stocks. they are scaled to the first stock.


Code:
# rs_normalize_compare_00

#https://usethinkscript.com/threads/normalized-scale-for-relative-strength-rs.12072/
# How can I normalize the stocks' RS ratios to compare them?

#==========================================

# compare_8stocks_rel_str_00
#https://usethinkscript.com/threads/a-chart-that-compares-relative-strength-against-spy.12637/
#UnAnswered A chart that compares relative strength against spy

declare lower;

def na = double.nan;

#=======================================

script normalizePlot {
  input data = close;
  input newRngMin = 0;
  input newRngMax = 100;
  def HHData = HighestAll(data);
  def LLData = LowestAll(data);
  plot nr = (((newRngMax - newRngMin)*(data - LLData))/(HHData - LLData)) + newRngMin;
}

#def a = normalizePlot(data, newmin, newmax);

#=======================================

input CorrelationWithSecurity = "SPY";
def cls_corr = close(CorrelationWithSecurity);
#plot RS = if close_corr == 0 then 0 else close / close_corr;
#RS.SetDefaultColor(GetColor(6));
#def sr = CompoundValue("historical data" = RS, "visible data" = if IsNaN(sr[1]) then RS else sr[1]);
#plot SRatio =  sr;
#SRatio.SetDefaultColor(GetColor(5));

#----------------

# symbol1 is the main stock.
# all others will be scaled to stock1 data
# use symbol  ZZ  for non entries

input Symbol1_primary = "AAPL";
#hint Symbol1_primary: This stock determines the min and max boundries. the other stocks will be scaled to be within the limits of this stock. This symbol needs to be entered.

def cls1 = close(Symbol1_primary);
def rs1 = if isnan(cls1) then na else if cls_corr == 0 then na else cls1/cls_corr;
def n1 = rs1;
plot z1 = n1;
z1.hidebubble();

def s1hi = highestall(rs1);
def s1lo = lowestall(rs1);
def s1rng = s1hi - s1lo;

input show_upper_lower_lines = yes;
plot s1top = if show_upper_lower_lines and !isnan(close) then s1hi else na;
plot s1bot = if show_upper_lower_lines and !isnan(close) then s1lo else na;
s1top.setdefaultcolor(color.gray);
s1bot.setdefaultcolor(color.gray);
s1top.hidebubble();
s1bot.hidebubble();


#---------------------------
#def a = normalizePlot(data, newmin, newmax);

input Symbol2 = "MSFT";
#hint symbol2: Enter a stock symbol for any of the symbols 2 to 8. \nIf you don't want to enter a stock, use ZZ.
def cls2 = close(Symbol2);
#def rs2 = if cls_corr == 0 then 0 else cls2/cls_corr;
def rs2 = if isnan(cls2) then na else if cls_corr == 0 then na else cls2/cls_corr;
def n2 = normalizePlot(rs2, s1lo, s1hi);
plot z2 = n2;
z2.hidebubble();

input Symbol3 = "WMT";
def cls3 = close(Symbol3);
def rs3 = if isnan(cls3) then na else if cls_corr == 0 then na else cls3/cls_corr;
def n3 = normalizePlot(rs3, s1lo, s1hi);
plot z3 = n3;
z3.hidebubble();

input Symbol4 = "ZZ";
def cls4 = close(Symbol4);
def rs4 = if isnan(cls4) then na else if cls_corr == 0 then na else cls4/cls_corr;
def n4 = normalizePlot(rs4, s1lo, s1hi);
plot z4 = n4;
z4.hidebubble();

input Symbol5 = "ZZ";
def cls5 = close(Symbol5);
def rs5 = if isnan(cls5) then na else if cls_corr == 0 then na else cls5/cls_corr;
def n5 = normalizePlot(rs5, s1lo, s1hi);
plot z5 = n5;
z5.hidebubble();

input Symbol6 = "ZZ";
def cls6 = close(Symbol6);
def rs6 = if isnan(cls6) then na else if cls_corr == 0 then na else cls6/cls_corr;
def n6 = normalizePlot(rs6, s1lo, s1hi);
plot z6 = n6;
z6.hidebubble();

input Symbol7 = "ZZ";
def cls7 = close(Symbol7);
def rs7 = if isnan(cls7) then na else if cls_corr == 0 then na else cls7/cls_corr;
def n7 = normalizePlot(rs7, s1lo, s1hi);
plot z7 = n7;
z7.hidebubble();

input Symbol8 = "ZZ";
def cls8 = close(Symbol8);
def rs8 = if isnan(cls8) then na else if cls_corr == 0 then na else cls8/cls_corr;
def n8 = normalizePlot(rs8, s1lo, s1hi);
plot z8 = n8;
z8.hidebubble();

#------------------------------

# draw bubbles , to the right of last bar, with symbol name
input show_name_bubbles = yes;

def off = 5;
def x = show_name_bubbles and (!isnan(close[off]) and isnan(close[off-1]) );

addchartbubble(x, rs1[off], Symbol1_primary, z1.TakeValueColor(), yes);
addchartbubble(x, n2[off], Symbol2, z2.TakeValueColor(), yes);
addchartbubble(x, n3[off], Symbol3, z3.TakeValueColor(), yes);
addchartbubble(x, n4[off], Symbol4, z4.TakeValueColor(), yes);
addchartbubble(x, n5[off], Symbol5, z5.TakeValueColor(), yes);
addchartbubble(x, n6[off], Symbol6, z6.TakeValueColor(), yes);
addchartbubble(x, n7[off], Symbol7, z7.TakeValueColor(), yes);
addchartbubble(x, n8[off], Symbol8, z8.TakeValueColor(), yes);

#-----------------------------

input show_labels = yes;
addlabel(show_labels, " ", color.black);
addlabel(show_labels and !isnan(rs1), Symbol1_primary, z1.TakeValueColor());
addlabel(show_labels and !isnan(rs2), Symbol2, z2.TakeValueColor());
addlabel(show_labels and !isnan(rs3), Symbol3, z3.TakeValueColor());
addlabel(show_labels and !isnan(rs4), Symbol4, z4.TakeValueColor());
addlabel(show_labels and !isnan(rs5), Symbol5, z5.TakeValueColor());
addlabel(show_labels and !isnan(rs6), Symbol6, z6.TakeValueColor());
addlabel(show_labels and !isnan(rs7), Symbol7, z7.TakeValueColor());
addlabel(show_labels and !isnan(rs8), Symbol8, z8.TakeValueColor());

addlabel(show_labels, " ", color.black);
addlabel(show_labels, "RS of " + CorrelationWithSecurity, color.yellow);


def offc = off + 30;
def xc = (!isnan(close[offc]) and isnan(close[offc-1]) );
#def minc = min(rs1,min(rs2,min(rs3,min(rs4,min(rs5,min(rs6,min(rs7,rs8)))))));
# doesnt work, some values are na, so result is na
#def minc = min(n1,min(n2,min(n3,min(n4,min(n5,min(n6,min(n7,n8)))))));

input show_compare_stock_bubble = yes;
addchartbubble(show_compare_stock_bubble and xc, s1lo,
"Relative\nStrength\nof stocks\ncompared\nto  " + 
CorrelationWithSecurity + "\n" +
"chart is scaled\nto Stock1\n" + Symbol1_primary
, Color.yellow, yes);
#


input shrink_the_plots = yes;
def zoom_per = 0.9;
def ztop = s1hi * ( 1 + (zoom_per/100));
def zbot = s1lo * ( 1 - (zoom_per/100));
plot zzt = if shrink_the_plots then ztop else na;
plot zzb = if shrink_the_plots then zbot else na;
zzt.setdefaultcolor(color.black);
zzb.setdefaultcolor(color.black);
zzt.hidebubble();
zzb.hidebubble();


addchartbubble(0,0,
n1 + "\n" +
n2 + "\n" +
n3 + "\n" +
n4 + "\n" +
n5 + "\n" +
n6 + "\n" +
n7 + "\n" +
n8
, color.yellow, no);
#

IQ1gdlD.jpg
 

poopyhead5928

New member
an updated version, that normalizes the RS's

this calculates the relative strength of a stock compared to another (default, SPY)
the first stock RS sets the size of the plots.
can enter up to 7 more stocks. they are scaled to the first stock.


Code:
# rs_normalize_compare_00

#https://usethinkscript.com/threads/normalized-scale-for-relative-strength-rs.12072/
# How can I normalize the stocks' RS ratios to compare them?

#==========================================

# compare_8stocks_rel_str_00
#https://usethinkscript.com/threads/a-chart-that-compares-relative-strength-against-spy.12637/
#UnAnswered A chart that compares relative strength against spy

declare lower;

def na = double.nan;

#=======================================

script normalizePlot {
  input data = close;
  input newRngMin = 0;
  input newRngMax = 100;
  def HHData = HighestAll(data);
  def LLData = LowestAll(data);
  plot nr = (((newRngMax - newRngMin)*(data - LLData))/(HHData - LLData)) + newRngMin;
}

#def a = normalizePlot(data, newmin, newmax);

#=======================================

input CorrelationWithSecurity = "SPY";
def cls_corr = close(CorrelationWithSecurity);
#plot RS = if close_corr == 0 then 0 else close / close_corr;
#RS.SetDefaultColor(GetColor(6));
#def sr = CompoundValue("historical data" = RS, "visible data" = if IsNaN(sr[1]) then RS else sr[1]);
#plot SRatio =  sr;
#SRatio.SetDefaultColor(GetColor(5));

#----------------

# symbol1 is the main stock.
# all others will be scaled to stock1 data
# use symbol  ZZ  for non entries

input Symbol1_primary = "AAPL";
#hint Symbol1_primary: This stock determines the min and max boundries. the other stocks will be scaled to be within the limits of this stock. This symbol needs to be entered.

def cls1 = close(Symbol1_primary);
def rs1 = if isnan(cls1) then na else if cls_corr == 0 then na else cls1/cls_corr;
def n1 = rs1;
plot z1 = n1;
z1.hidebubble();

def s1hi = highestall(rs1);
def s1lo = lowestall(rs1);
def s1rng = s1hi - s1lo;

input show_upper_lower_lines = yes;
plot s1top = if show_upper_lower_lines and !isnan(close) then s1hi else na;
plot s1bot = if show_upper_lower_lines and !isnan(close) then s1lo else na;
s1top.setdefaultcolor(color.gray);
s1bot.setdefaultcolor(color.gray);
s1top.hidebubble();
s1bot.hidebubble();


#---------------------------
#def a = normalizePlot(data, newmin, newmax);

input Symbol2 = "MSFT";
#hint symbol2: Enter a stock symbol for any of the symbols 2 to 8. \nIf you don't want to enter a stock, use ZZ.
def cls2 = close(Symbol2);
#def rs2 = if cls_corr == 0 then 0 else cls2/cls_corr;
def rs2 = if isnan(cls2) then na else if cls_corr == 0 then na else cls2/cls_corr;
def n2 = normalizePlot(rs2, s1lo, s1hi);
plot z2 = n2;
z2.hidebubble();

input Symbol3 = "WMT";
def cls3 = close(Symbol3);
def rs3 = if isnan(cls3) then na else if cls_corr == 0 then na else cls3/cls_corr;
def n3 = normalizePlot(rs3, s1lo, s1hi);
plot z3 = n3;
z3.hidebubble();

input Symbol4 = "ZZ";
def cls4 = close(Symbol4);
def rs4 = if isnan(cls4) then na else if cls_corr == 0 then na else cls4/cls_corr;
def n4 = normalizePlot(rs4, s1lo, s1hi);
plot z4 = n4;
z4.hidebubble();

input Symbol5 = "ZZ";
def cls5 = close(Symbol5);
def rs5 = if isnan(cls5) then na else if cls_corr == 0 then na else cls5/cls_corr;
def n5 = normalizePlot(rs5, s1lo, s1hi);
plot z5 = n5;
z5.hidebubble();

input Symbol6 = "ZZ";
def cls6 = close(Symbol6);
def rs6 = if isnan(cls6) then na else if cls_corr == 0 then na else cls6/cls_corr;
def n6 = normalizePlot(rs6, s1lo, s1hi);
plot z6 = n6;
z6.hidebubble();

input Symbol7 = "ZZ";
def cls7 = close(Symbol7);
def rs7 = if isnan(cls7) then na else if cls_corr == 0 then na else cls7/cls_corr;
def n7 = normalizePlot(rs7, s1lo, s1hi);
plot z7 = n7;
z7.hidebubble();

input Symbol8 = "ZZ";
def cls8 = close(Symbol8);
def rs8 = if isnan(cls8) then na else if cls_corr == 0 then na else cls8/cls_corr;
def n8 = normalizePlot(rs8, s1lo, s1hi);
plot z8 = n8;
z8.hidebubble();

#------------------------------

# draw bubbles , to the right of last bar, with symbol name
input show_name_bubbles = yes;

def off = 5;
def x = show_name_bubbles and (!isnan(close[off]) and isnan(close[off-1]) );

addchartbubble(x, rs1[off], Symbol1_primary, z1.TakeValueColor(), yes);
addchartbubble(x, n2[off], Symbol2, z2.TakeValueColor(), yes);
addchartbubble(x, n3[off], Symbol3, z3.TakeValueColor(), yes);
addchartbubble(x, n4[off], Symbol4, z4.TakeValueColor(), yes);
addchartbubble(x, n5[off], Symbol5, z5.TakeValueColor(), yes);
addchartbubble(x, n6[off], Symbol6, z6.TakeValueColor(), yes);
addchartbubble(x, n7[off], Symbol7, z7.TakeValueColor(), yes);
addchartbubble(x, n8[off], Symbol8, z8.TakeValueColor(), yes);

#-----------------------------

input show_labels = yes;
addlabel(show_labels, " ", color.black);
addlabel(show_labels and !isnan(rs1), Symbol1_primary, z1.TakeValueColor());
addlabel(show_labels and !isnan(rs2), Symbol2, z2.TakeValueColor());
addlabel(show_labels and !isnan(rs3), Symbol3, z3.TakeValueColor());
addlabel(show_labels and !isnan(rs4), Symbol4, z4.TakeValueColor());
addlabel(show_labels and !isnan(rs5), Symbol5, z5.TakeValueColor());
addlabel(show_labels and !isnan(rs6), Symbol6, z6.TakeValueColor());
addlabel(show_labels and !isnan(rs7), Symbol7, z7.TakeValueColor());
addlabel(show_labels and !isnan(rs8), Symbol8, z8.TakeValueColor());

addlabel(show_labels, " ", color.black);
addlabel(show_labels, "RS of " + CorrelationWithSecurity, color.yellow);


def offc = off + 30;
def xc = (!isnan(close[offc]) and isnan(close[offc-1]) );
#def minc = min(rs1,min(rs2,min(rs3,min(rs4,min(rs5,min(rs6,min(rs7,rs8)))))));
# doesnt work, some values are na, so result is na
#def minc = min(n1,min(n2,min(n3,min(n4,min(n5,min(n6,min(n7,n8)))))));

input show_compare_stock_bubble = yes;
addchartbubble(show_compare_stock_bubble and xc, s1lo,
"Relative\nStrength\nof stocks\ncompared\nto  " +
CorrelationWithSecurity + "\n" +
"chart is scaled\nto Stock1\n" + Symbol1_primary
, Color.yellow, yes);
#


input shrink_the_plots = yes;
def zoom_per = 0.9;
def ztop = s1hi * ( 1 + (zoom_per/100));
def zbot = s1lo * ( 1 - (zoom_per/100));
plot zzt = if shrink_the_plots then ztop else na;
plot zzb = if shrink_the_plots then zbot else na;
zzt.setdefaultcolor(color.black);
zzb.setdefaultcolor(color.black);
zzt.hidebubble();
zzb.hidebubble();


addchartbubble(0,0,
n1 + "\n" +
n2 + "\n" +
n3 + "\n" +
n4 + "\n" +
n5 + "\n" +
n6 + "\n" +
n7 + "\n" +
n8
, color.yellow, no);
#

IQ1gdlD.jpg
Thanks! I'll gave this a try
 

mjlinhle

New member
VIP
Thanks! I'll gave this a try
an updated version, that normalizes the RS's

this calculates the relative strength of a stock compared to another (default, SPY)
the first stock RS sets the size of the plots.
can enter up to 7 more stocks. they are scaled to the first stock.


Code:
# rs_normalize_compare_00

#https://usethinkscript.com/threads/normalized-scale-for-relative-strength-rs.12072/
# How can I normalize the stocks' RS ratios to compare them?

#==========================================

# compare_8stocks_rel_str_00
#https://usethinkscript.com/threads/a-chart-that-compares-relative-strength-against-spy.12637/
#UnAnswered A chart that compares relative strength against spy

declare lower;

def na = double.nan;

#=======================================

script normalizePlot {
  input data = close;
  input newRngMin = 0;
  input newRngMax = 100;
  def HHData = HighestAll(data);
  def LLData = LowestAll(data);
  plot nr = (((newRngMax - newRngMin)*(data - LLData))/(HHData - LLData)) + newRngMin;
}

#def a = normalizePlot(data, newmin, newmax);

#=======================================

input CorrelationWithSecurity = "SPY";
def cls_corr = close(CorrelationWithSecurity);
#plot RS = if close_corr == 0 then 0 else close / close_corr;
#RS.SetDefaultColor(GetColor(6));
#def sr = CompoundValue("historical data" = RS, "visible data" = if IsNaN(sr[1]) then RS else sr[1]);
#plot SRatio =  sr;
#SRatio.SetDefaultColor(GetColor(5));

#----------------

# symbol1 is the main stock.
# all others will be scaled to stock1 data
# use symbol  ZZ  for non entries

input Symbol1_primary = "AAPL";
#hint Symbol1_primary: This stock determines the min and max boundries. the other stocks will be scaled to be within the limits of this stock. This symbol needs to be entered.

def cls1 = close(Symbol1_primary);
def rs1 = if isnan(cls1) then na else if cls_corr == 0 then na else cls1/cls_corr;
def n1 = rs1;
plot z1 = n1;
z1.hidebubble();

def s1hi = highestall(rs1);
def s1lo = lowestall(rs1);
def s1rng = s1hi - s1lo;

input show_upper_lower_lines = yes;
plot s1top = if show_upper_lower_lines and !isnan(close) then s1hi else na;
plot s1bot = if show_upper_lower_lines and !isnan(close) then s1lo else na;
s1top.setdefaultcolor(color.gray);
s1bot.setdefaultcolor(color.gray);
s1top.hidebubble();
s1bot.hidebubble();


#---------------------------
#def a = normalizePlot(data, newmin, newmax);

input Symbol2 = "MSFT";
#hint symbol2: Enter a stock symbol for any of the symbols 2 to 8. \nIf you don't want to enter a stock, use ZZ.
def cls2 = close(Symbol2);
#def rs2 = if cls_corr == 0 then 0 else cls2/cls_corr;
def rs2 = if isnan(cls2) then na else if cls_corr == 0 then na else cls2/cls_corr;
def n2 = normalizePlot(rs2, s1lo, s1hi);
plot z2 = n2;
z2.hidebubble();

input Symbol3 = "WMT";
def cls3 = close(Symbol3);
def rs3 = if isnan(cls3) then na else if cls_corr == 0 then na else cls3/cls_corr;
def n3 = normalizePlot(rs3, s1lo, s1hi);
plot z3 = n3;
z3.hidebubble();

input Symbol4 = "ZZ";
def cls4 = close(Symbol4);
def rs4 = if isnan(cls4) then na else if cls_corr == 0 then na else cls4/cls_corr;
def n4 = normalizePlot(rs4, s1lo, s1hi);
plot z4 = n4;
z4.hidebubble();

input Symbol5 = "ZZ";
def cls5 = close(Symbol5);
def rs5 = if isnan(cls5) then na else if cls_corr == 0 then na else cls5/cls_corr;
def n5 = normalizePlot(rs5, s1lo, s1hi);
plot z5 = n5;
z5.hidebubble();

input Symbol6 = "ZZ";
def cls6 = close(Symbol6);
def rs6 = if isnan(cls6) then na else if cls_corr == 0 then na else cls6/cls_corr;
def n6 = normalizePlot(rs6, s1lo, s1hi);
plot z6 = n6;
z6.hidebubble();

input Symbol7 = "ZZ";
def cls7 = close(Symbol7);
def rs7 = if isnan(cls7) then na else if cls_corr == 0 then na else cls7/cls_corr;
def n7 = normalizePlot(rs7, s1lo, s1hi);
plot z7 = n7;
z7.hidebubble();

input Symbol8 = "ZZ";
def cls8 = close(Symbol8);
def rs8 = if isnan(cls8) then na else if cls_corr == 0 then na else cls8/cls_corr;
def n8 = normalizePlot(rs8, s1lo, s1hi);
plot z8 = n8;
z8.hidebubble();

#------------------------------

# draw bubbles , to the right of last bar, with symbol name
input show_name_bubbles = yes;

def off = 5;
def x = show_name_bubbles and (!isnan(close[off]) and isnan(close[off-1]) );

addchartbubble(x, rs1[off], Symbol1_primary, z1.TakeValueColor(), yes);
addchartbubble(x, n2[off], Symbol2, z2.TakeValueColor(), yes);
addchartbubble(x, n3[off], Symbol3, z3.TakeValueColor(), yes);
addchartbubble(x, n4[off], Symbol4, z4.TakeValueColor(), yes);
addchartbubble(x, n5[off], Symbol5, z5.TakeValueColor(), yes);
addchartbubble(x, n6[off], Symbol6, z6.TakeValueColor(), yes);
addchartbubble(x, n7[off], Symbol7, z7.TakeValueColor(), yes);
addchartbubble(x, n8[off], Symbol8, z8.TakeValueColor(), yes);

#-----------------------------

input show_labels = yes;
addlabel(show_labels, " ", color.black);
addlabel(show_labels and !isnan(rs1), Symbol1_primary, z1.TakeValueColor());
addlabel(show_labels and !isnan(rs2), Symbol2, z2.TakeValueColor());
addlabel(show_labels and !isnan(rs3), Symbol3, z3.TakeValueColor());
addlabel(show_labels and !isnan(rs4), Symbol4, z4.TakeValueColor());
addlabel(show_labels and !isnan(rs5), Symbol5, z5.TakeValueColor());
addlabel(show_labels and !isnan(rs6), Symbol6, z6.TakeValueColor());
addlabel(show_labels and !isnan(rs7), Symbol7, z7.TakeValueColor());
addlabel(show_labels and !isnan(rs8), Symbol8, z8.TakeValueColor());

addlabel(show_labels, " ", color.black);
addlabel(show_labels, "RS of " + CorrelationWithSecurity, color.yellow);


def offc = off + 30;
def xc = (!isnan(close[offc]) and isnan(close[offc-1]) );
#def minc = min(rs1,min(rs2,min(rs3,min(rs4,min(rs5,min(rs6,min(rs7,rs8)))))));
# doesnt work, some values are na, so result is na
#def minc = min(n1,min(n2,min(n3,min(n4,min(n5,min(n6,min(n7,n8)))))));

input show_compare_stock_bubble = yes;
addchartbubble(show_compare_stock_bubble and xc, s1lo,
"Relative\nStrength\nof stocks\ncompared\nto  " +
CorrelationWithSecurity + "\n" +
"chart is scaled\nto Stock1\n" + Symbol1_primary
, Color.yellow, yes);
#


input shrink_the_plots = yes;
def zoom_per = 0.9;
def ztop = s1hi * ( 1 + (zoom_per/100));
def zbot = s1lo * ( 1 - (zoom_per/100));
plot zzt = if shrink_the_plots then ztop else na;
plot zzb = if shrink_the_plots then zbot else na;
zzt.setdefaultcolor(color.black);
zzb.setdefaultcolor(color.black);
zzt.hidebubble();
zzb.hidebubble();


addchartbubble(0,0,
n1 + "\n" +
n2 + "\n" +
n3 + "\n" +
n4 + "\n" +
n5 + "\n" +
n6 + "\n" +
n7 + "\n" +
n8
, color.yellow, no);
#

IQ1gdlD.jpg
HI, is there a way we could have a scan for this ?
Thanks.
 

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.
Top