S&P 500 Sector Performance for ThinkorSwim

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

Hello guys,

I'm having a difficult time finding daily percent-change labels for sectors.
So I can ask the question: which sector today is up, which is down, based on daily percent change.

Any help?

Or can anybody point me to a resource on how to make them?

THanks
 
can u make this to show price and percentage
Code:
# PctComp - Key Risk ETFs
# 01-22-2017
# Chat request by Blackhatter - Dilbert & Spectrum in TSL

def IWMPctChg = (close("IWM", period = "Day") / close("IWM", period = "Day")[1]) - 1;
AddLabel(1, "IWM" + " = " + AsPercent(IWMPctChg), if IWMPctChg > 0 then Color.GREEN else Color.RED);

def SPYPctChg = (close("SPY", period = "Day") / close("SPY", period = "Day")[1]) - 1;
AddLabel(1, "SPY" + " = " + AsPercent(SPYPctChg), if SPYPctChg > 0 then Color.GREEN else Color.RED);

def EEMPctChg = (close("EEM", period = "Day") / close("EEM", period = "Day")[1]) - 1;
AddLabel(1, "EEM" + " = " + AsPercent(EEMPctChg), if EEMPctChg > 0 then Color.GREEN else Color.RED);

def XLYPctChg = (close("XLY", period = "Day") / close("XLY", period = "Day")[1]) - 1;
AddLabel(1, "XLY" + " = " + AsPercent(XLYPctChg), if XLYPctChg > 0 then Color.GREEN else Color.RED);

def XLPPctChg = (close("XLP", period = "Day") / close("XLP", period = "Day")[1]) - 1;
AddLabel(1, "XLP" + " = " + AsPercent(XLPPctChg), if XLPPctChg > 0 then Color.GREEN else Color.RED);

def XLUPctChg = (close("XLU", period = "Day") / close("XLU", period = "Day")[1]) - 1;
AddLabel(1, "XLU" + " = " + AsPercent(XLUPctChg), if XLUPctChg > 0 then Color.GREEN else Color.RED);

def JNKPctChg = (close("JNK", period = "Day") / close("JNK", period = "Day")[1]) - 1;
AddLabel(1, "JNK" + "  = " + AsPercent(JNKPctChg), if JNKPctChg > 0 then Color.GREEN else Color.RED);

def LQDPctChg = (close("LQD", period = "Day") / close("LQD", period = "Day")[1]) - 1;
AddLabel(1, "LQD" + " = " + AsPercent(LQDPctChg), if LQDPctChg > 0 then Color.GREEN else Color.RED);

AddLabel(1, "IWM - SPY = " + AsPercent(IWMPctChg - SPYPctChg), if IWMPctChg - SPYPctChg > 0 then Color.GREEN else Color.RED);
AddLabel(1, "EEM - SPY = " + AsPercent(EEMPctChg - SPYPctChg), if EEMPctChg - SPYPctChg > 0 then Color.GREEN else Color.RED);
AddLabel(1, "SPY - XLU = " + AsPercent(SPYPctChg - XLUPctChg), if SPYPctChg - XLUPctChg > 0 then Color.GREEN else Color.RED);
AddLabel(1, "XLY - XLP = " + AsPercent(XLYPctChg - XLPPctChg), if XLYPctChg - XLPPctChg > 0 then Color.GREEN else Color.RED);
AddLabel(1, "JNK - LQD = " + AsPercent(JNKPctChg - LQDPctChg), if JNKPctChg - LQDPctChg > 0 then Color.GREEN else Color.RED);

AddLabel(1, "Total = " + AsPercent((IWMPctChg - SPYPctChg) + (EEMPctChg - SPYPctChg) + (SPYPctChg - XLUPctChg) + (XLYPctChg - XLPPctChg) + (JNKPctChg - LQDPctChg)), if ((IWMPctChg - SPYPctChg) + (EEMPctChg - SPYPctChg) + (SPYPctChg - XLUPctChg) + (XLYPctChg - XLPPctChg) + (JNKPctChg - LQDPctChg)) > 0 then color.green else color.red);
#EOC#
 
Last edited by a moderator:
Hello guys,

I'm having a difficult time finding daily percent-change labels for sectors.
So I can ask the question: which sector today is up, which is down, based on daily percent change.

Any help?

Or can anybody point me to a resource on how to make them?

THanks

@George1
I moved your thread here. It will give you ideas for your project.
 
Last edited:
Hi, trying to create Intraday Super Sectors - clone from https://www.tradingview.com/script/Iff03iNm-Intraday-Super-Sectors/ Need your code review because it is first time i try to write code based on TradingView. So I got similar but not identical result. Any updates are Welcome!
Code:
#Intraday Super Sectors
#Version 1.0 Released 04/16/2022
#Original Code: stuarthenryjames
#https://www.tradingview.com/script/Iff03iNm-Intraday-Super-Sectors/
#==========================================================

declare lower;

input EmaLength = 5;

def oWeightXLB = 2.6;
def oSectorCyclicalXLB = 1;
def oSectorDefensiveXLB = 0;

def oWeightXLC = 10.8;
def oSectorCyclicalXLC = 1;
def oSectorDefensiveXLC = 0;

def oWeightXLE = 2.3;
def oSectorCyclicalXLE = 0;
def oSectorDefensiveXLE = 1;

def oWeightXLF = 10.4;
def oSectorCyclicalXLF = 1;
def oSectorDefensiveXLF = 0;

def oWeightXLI = 8.4;
def oSectorCyclicalXLI = 1;
def oSectorDefensiveXLI = 0;

def oWeightXLK = 27.6;
def oSectorCyclicalXLK = 1;
def oSectorDefensiveXLK = 0;

def oWeightXLP = 6.5;
def oSectorCyclicalXLP = 0;
def oSectorDefensiveXLP = 1;

def oWeightXLRE = 2.4;
def oSectorCyclicalXLRE = 1;
def oSectorDefensiveXLRE = 0;

def oWeightXLU = 2.8;
def oSectorCyclicalXLU = 0;
def oSectorDefensiveXLU = 1;

def oWeightXLV = 13.5;
def oSectorCyclicalXLV = 0;
def oSectorDefensiveXLV = 1;

def oWeightXLY = 12.7;
def oSectorCyclicalXLY = 1;
def oSectorDefensiveXLY = 0;

def oOpenXLB = open("XLB", period = AggregationPeriod.DAY) * oWeightXLB;
def oOpenXLC = open("XLC", period = AggregationPeriod.DAY) * oWeightXLC;
def oOpenXLE = open("XLE", period = AggregationPeriod.DAY) * oWeightXLE;
def oOpenXLF = open("XLF", period = AggregationPeriod.DAY) * oWeightXLF;
def oOpenXLI = open("XLI", period = AggregationPeriod.DAY) * oWeightXLI;
def oOpenXLK = open("XLK", period = AggregationPeriod.DAY) * oWeightXLK;
def oOpenXLP = open("XLP", period = AggregationPeriod.DAY) * oWeightXLP;
def oOpenXLRE = open("XLRE", period = AggregationPeriod.DAY) * oWeightXLRE;
def oOpenXLU = open("XLU", period = AggregationPeriod.DAY) * oWeightXLU;
def oOpenXLV = open("XLV", period = AggregationPeriod.DAY) * oWeightXLV;
def oOpenXLY = open("XLY", period = AggregationPeriod.DAY) * oWeightXLY;
def oOpenSpx = open(period = AggregationPeriod.DAY);

def MarketOpenTime = 0930;
def FirstMinute = if SecondsFromTime(MarketOpenTime) < 60 then 1 else 0;
def oOpenCyclical;
def oOpenDefensive;

if FirstMinute {
oOpenCyclical = oSectorCyclicalXLB * oOpenXLB + oSectorCyclicalXLC * oOpenXLC +
                    oSectorCyclicalXLE * oOpenXLE + oSectorCyclicalXLF * oOpenXLF +
                    oSectorCyclicalXLI * oOpenXLI + oSectorCyclicalXLK * oOpenXLK +
                    oSectorCyclicalXLP * oOpenXLP + oSectorCyclicalXLRE * oOpenXLRE +
                    oSectorCyclicalXLU * oOpenXLU + oSectorCyclicalXLV * oOpenXLV +
                    oSectorCyclicalXLY * oOpenXLY;

oOpenDefensive = oSectorDefensiveXLB * oOpenXLB + oSectorDefensiveXLC * oOpenXLC +
                     oSectorDefensiveXLE * oOpenXLE + oSectorDefensiveXLF * oOpenXLF +
                     oSectorDefensiveXLI * oOpenXLI + oSectorDefensiveXLK * oOpenXLK +
                     oSectorDefensiveXLP * oOpenXLP + oSectorDefensiveXLRE * oOpenXLRE +
                     oSectorDefensiveXLU * oOpenXLU + oSectorDefensiveXLV * oOpenXLV +
                     oSectorDefensiveXLY * oOpenXLY;
} else {
oOpenCyclical = oOpenCyclical[1];
oOpenDefensive = oOpenDefensive[1];
}

def oCurrentSpx = close("SPX");
def oCurrentXLB = close("XLB") * oWeightXLB;
def oCurrentXLC = close("XLC") * oWeightXLC;
def oCurrentXLE = close("XLE") * oWeightXLE;
def oCurrentXLF = close("XLF") * oWeightXLF;
def oCurrentXLI = close("XLI") * oWeightXLI;
def oCurrentXLK = close("XLK") * oWeightXLK;
def oCurrentXLP = close("XLP") * oWeightXLP;
def oCurrentXLRE = close("XLRE") * oWeightXLRE;
def oCurrentXLU = close("XLU") * oWeightXLU;
def oCurrentXLV = close("XLV") * oWeightXLV;
def oCurrentXLY = close("XLY") * oWeightXLY;

def oCurrentCyclical = oSectorCyclicalXLB * oCurrentXLB + oSectorCyclicalXLC * oCurrentXLC +
                       oSectorCyclicalXLE * oCurrentXLE + oSectorCyclicalXLF * oCurrentXLF +
                       oSectorCyclicalXLI * oCurrentXLI + oSectorCyclicalXLK * oCurrentXLK +
                       oSectorCyclicalXLP * oCurrentXLP + oSectorCyclicalXLRE * oCurrentXLRE +
                       oSectorCyclicalXLU * oCurrentXLU + oSectorCyclicalXLV * oCurrentXLV +
                       oSectorCyclicalXLY * oCurrentXLY;

def oCurrentDefensive = oSectorDefensiveXLB * oCurrentXLB + oSectorDefensiveXLC * oCurrentXLC +
                        oSectorDefensiveXLE * oCurrentXLE + oSectorDefensiveXLF * oCurrentXLF +
                        oSectorDefensiveXLI * oCurrentXLI + oSectorDefensiveXLK * oCurrentXLK +
                        oSectorDefensiveXLP * oCurrentXLP + oSectorDefensiveXLRE * oCurrentXLRE +
                        oSectorDefensiveXLU * oCurrentXLU + oSectorDefensiveXLV * oCurrentXLV +
                        oSectorDefensiveXLY * oCurrentXLY;

def oSpx = 100 * (oCurrentSpx / Max(1, oOpenSpx) - 1);
def oCyclical = 100 * (oCurrentCyclical / oOpenCyclical - 1);
def oDefensive = 100 * (oCurrentDefensive / oOpenDefensive - 1);

plot o = 0;
o.SetDefaultColor(Color.YELLOW);
o.SetLineWeight(1);

plot oSpxPlot = ExpAverage(oSpx, EmaLength);
oSpxPlot.SetDefaultColor(Color.WHITE);
oSpxPlot.SetLineWeight(2);

plot oCyclicalPlot = ExpAverage(oCyclical, EmaLength);
oCyclicalPlot.SetDefaultColor(Color.GREEN);
oCyclicalPlot.SetLineWeight(2);

plot oDefensivePlot = ExpAverage(oDefensive, EmaLength);
oDefensivePlot.SetDefaultColor(Color.RED);
oDefensivePlot.SetLineWeight(2);
 
I think, it should start "count" EMA after 5 bars...but I have no idea how to say "IF bars since open >=5 -> Use EMA else just MA with Length == number of bars since open:
 
# V1.3 - 04.27.2022 - EvilSurgeon - converted to top chart lables only with Beta and Stoch Values
#- Added Colors Coded by Beta Value
#- Changed Lengths to 22
#- Added Indices and additional Sectors
#- Shortened Labels and Alphabetized Sectors
Forgive me if I mess up this post - it is my first.

I agree with your concern about difficulty seeing all the bubbles. I added the value of the stoch to the labels.

Here is my revised code:

# From https://usethinkscript.com/threads/s-p-500-sector-performance.1152/

# Beta Rotation V1.1
# ed_nn, with modifications by tomsk
# 1.4.2020

# V1.0 - 04.10.2019 - ed_nn - Initial release of Beta Rotation from TSL
# V1.1 - 01.04.2020 - tomsk - Standardized plots for stoch1-stoch9 and added sector percent correlation
# V1.2 -01.11.2020 - RmS59 - added Stoch values to the labels

Code:
#added 4-27-22

# From https://usethinkscript.com/threads/s-p-500-sector-performance.1152/

# Beta Rotation V1.1
# ed_nn, with modifications by tomsk
# 1.4.2020

# V1.0 - 04.10.2019 - ed_nn - Initial release of Beta Rotation from TSL
# V1.1 - 01.04.2020 - tomsk - Standardized plots for stoch1-stoch9 and added sector percent correlation
# V1.2 - 01.11.2020 - RmS59 - added Stoch values to the labels
# V1.3 - 04.27.2022 - EvilSurgeon    - converted to top chart lables only with Beta and Stoch Values
                                    #- Added Colors Coded by Beta Value
                                    #- Changed Lengths to 22
                                    #- Added Indices and additional Sectors
                                    #- Shortened Labels and Alphabetized Sectors

# ed_nn: Maybe it has some interest. It attempts to code a posted idea
# (using Beta + Stochastics to observe rotation) from last week

# Mobius: To find rotation quickly, use primary ETF's in a watchlist with 2 columns
# first column is Correlation to SPX, second column is a stochastic of Beta
# if Beta is 1 or close to 1 that ETF is moving at the fastest momentum in that range
# and if correlation is with SPX .85 or better it's moving with SPX correlation below 0
# and it's moving the opposite of SPX.

# RmS59: To facilitate legibility, the value of the various sector stochs are displayed in the Labels



input BetaLength = 22;
input StochLength = 34;
input showBeta = yes;
input showOverlay = Yes;

input SnP = {default "SPX"};
input Nsdq = {default "COMP"};
input Rus = {default "RUT"};
input Energy = {default "$SP500#10" };
input Mtls= {default  "$SP500#15" };
input Industr = {default  "$SP500#20"};
input ConsDiscr = {default "$SP500#25"};
input ConsStpls = {default "$SP500#30"};
input Health = {default "$SP500#35"};
input Finance = {default "$SP500#40"};
input Tech = {default "$SP500#45"};
input Comms = {default "$SP500#50"};
input Util = {default "$SP500#55"};
input RealEst = "$SP500#60";
input Retail = "XRT";


DefineGlobalColor("VeryGood", Color.Dark_Green);
DefineGlobalColor("Good", CreateColor ( 34,139,34 ) );
DefineGlobalColor("ModGood", CreateColor(60, 179, 113));
DefineGlobalColor("SlightlyGood", CreateColor(50, 205, 50));
DefineGlobalColor("SluggishGood", CreateColor(0, 255, 127));
DefineGlobalColor("Neutral", color.yellow);
DefineGlobalColor("SluggishBad", CreateColor(255, 215, 0));##
DefineGlobalColor("SlightlyBad", color.dark_orange);
DefineGlobalColor("ModBad", color.downtick);
DefineGlobalColor("Bad", color.red);
DefineGlobalColor("VeryBad", color.dark_red);

AddLabel(1, "Sect Rotat Beta/Stoch", Color.Blue);

script calcBeta {
    input secondSymbol = "XLF";
    input refSymbol = "SPX";
    input betaLength = 22;
    input returnLength = 1;

    def refPrice = close(refSymbol);
    def primary = if refPrice[returnLength] == 0
                then 0
                else (refPrice - refPrice[returnLength]) /
                      refPrice[returnLength] * 100;
    def secondPrice = close(secondSymbol);
    def secondary = if secondPrice[returnLength] == 0
                  then 0
                  else (secondPrice - secondPrice[returnLength]) /
                        secondPrice[returnLength] * 100;
    plot Beta = Covariance(secondary, primary, betaLength) /
                         Sqr(StDev(primary, betaLength));
}

script EhlersESSfilter {
    input price = close;
    input length = 8;
    def ESS_coeff_0 = Exp(-Double.Pi * Sqrt(2) / length);
    def ESS_coeff_2 = 2 * ESS_coeff_0 * Cos(Sqrt(2) * Double.Pi / length);
    def ESS_coeff_3 = - Sqr(ESS_coeff_0);
    def ESS_coeff_1 = 1 - ESS_coeff_2 - ESS_coeff_3;
    def ESS_filter = if IsNaN(price + price[1]) then
                      ESS_filter[1]
                 else ESS_coeff_1 * (price + price[1]) / 2 +
                      ESS_coeff_2 * ESS_filter[1] +
                      ESS_coeff_3 * ESS_filter[2];
    plot Smooth_Filter =
         if BarNumber() <  length then
              price
         else if !IsNaN(price) then
              ESS_filter
         else Double.NaN;
}

script calcStoch {
    input data = close;
    input StochLength = 22;
    def stochasticValue = ((data - Lowest(data, StochLength)) /
                         (Highest(data, StochLength) - Lowest(data, StochLength)));
    plot stoch = stochasticValue;
}

def upStochLimit = 0.85;
def lowStockLimit = 0.15;

def stoch13 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = SnP, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "S&P " +  "(" + round(calcBeta(SnP),2) + " / " + round(stoch13,2) + ")",
if stoch13 <= lowStockLimit and stoch13 <= stoch13[1] then GlobalColor("Bad") else
if stoch13 <= lowStockLimit and stoch13 >= stoch13[1] then GlobalColor("ModBad") else
if between(stoch13, lowStockLimit, 0.5) and stoch13 <= stoch13[1] then GlobalColor("SluggishBad") else
if between(stoch13, lowStockLimit, 0.5) and stoch13 >= stoch13[1] then GlobalColor("neutral") else
if between(stoch13, 0.5, upStochLimit) and stoch13 <= stoch13[1] then GlobalColor("SluggishGood") else
if between(stoch13, 0.5, upStochLimit) and stoch13 >= stoch13[1] then GlobalColor("SlightlyGood") else
if stoch13 >= upStochLimit  and stoch13 <= stoch13[1] then GlobalColor("ModGood") else
if stoch13 >= upStochLimit  and stoch13 >= stoch13[1] then GlobalColor("VeryGood") else color.gray);

def stoch14 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = NSDQ, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "NSDQ " +  "(" + round(calcBeta(NSDQ),2) + " / " + round(stoch14,2) + ")",   
if stoch14 <= lowStockLimit and stoch14 <= stoch14[1] then GlobalColor("Bad") else
if stoch14 <= lowStockLimit and stoch14 >= stoch14[1] then GlobalColor("ModBad") else
if between(stoch14, lowStockLimit, 0.5) and stoch14 <= stoch14[1] then GlobalColor("SluggishBad") else
if between(stoch14, lowStockLimit, 0.5) and stoch14 >= stoch14[1] then GlobalColor("neutral") else
if between(stoch14, 0.5, upStochLimit) and stoch14 <= stoch14[1] then GlobalColor("SluggishGood") else
if between(stoch14, 0.5, upStochLimit) and stoch14 >= stoch14[1] then GlobalColor("SlightlyGood") else
if stoch14 >= upStochLimit  and stoch14 <= stoch14[1] then GlobalColor("ModGood") else
if stoch14 >= upStochLimit  and stoch14 >= stoch14[1] then GlobalColor("VeryGood") else color.gray);

def stoch15 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Rus, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Rus " +  "(" + round(calcBeta(Rus),2) + " / " + round(stoch15,2) + ")", 
if stoch15 <= lowStockLimit and stoch15 <= stoch15[1] then GlobalColor("Bad") else
if stoch15 <= lowStockLimit and stoch15 >= stoch15[1] then GlobalColor("ModBad") else
if between(stoch15, lowStockLimit, 0.5) and stoch15 <= stoch15[1] then GlobalColor("SluggishBad") else
if between(stoch15, lowStockLimit, 0.5) and stoch15 >= stoch15[1] then GlobalColor("neutral") else
if between(stoch15, 0.5, upStochLimit) and stoch15 <= stoch15[1] then GlobalColor("SluggishGood") else
if between(stoch15, 0.5, upStochLimit) and stoch15 >= stoch15[1] then GlobalColor("SlightlyGood") else
if stoch15 >= upStochLimit  and stoch15 <= stoch15[1] then GlobalColor("ModGood") else
if stoch15 >= upStochLimit  and stoch15 >= stoch15[1] then GlobalColor("VeryGood") else color.gray);

def stoch10 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Comms, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Comms " + "(" + round(calcBeta(Comms),2) + " / " + round(stoch10,2) + ")",   
if stoch10 <= lowStockLimit and stoch10 <= stoch10[1] then GlobalColor("Bad") else
if stoch10 <= lowStockLimit and stoch10 >= stoch10[1] then GlobalColor("ModBad") else
if between(stoch10, lowStockLimit, 0.5) and stoch10 <= stoch10[1] then GlobalColor("SluggishBad") else
if between(stoch10, lowStockLimit, 0.5) and stoch10 >= stoch10[1] then GlobalColor("neutral") else
if between(stoch10, 0.5, upStochLimit) and stoch10 <= stoch10[1] then GlobalColor("SluggishGood") else
if between(stoch10, 0.5, upStochLimit) and stoch10 >= stoch10[1] then GlobalColor("SlightlyGood") else
if stoch10 >= upStochLimit  and stoch10 <= stoch10[1] then GlobalColor("ModGood") else
if stoch10 >= upStochLimit  and stoch10 >= stoch10[1] then GlobalColor("VeryGood") else color.gray);

def stoch1 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = ConsDiscr, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "ConsDiscr " +  "(" + round(calcBeta(ConsDiscr),2) + " / " + round(stoch1,2) + ")",
if stoch1 <= lowStockLimit and stoch1 <= stoch1[1] then GlobalColor("Bad") else
if stoch1 <= lowStockLimit and stoch1 >= stoch1[1] then GlobalColor("ModBad") else
if between(stoch1, lowStockLimit, 0.5) and stoch1 <= stoch1[1] then GlobalColor("SluggishBad") else
if between(stoch1, lowStockLimit, 0.5) and stoch1 >= stoch1[1] then GlobalColor("neutral") else
if between(stoch1, 0.5, upStochLimit) and stoch1 <= stoch1[1] then GlobalColor("SluggishGood") else
if between(stoch1, 0.5, upStochLimit) and stoch1 >= stoch1[1] then GlobalColor("SlightlyGood") else
if stoch1 >= upStochLimit  and stoch1 <= stoch1[1] then GlobalColor("ModGood") else
if stoch1 >= upStochLimit  and stoch1 >= stoch1[1] then GlobalColor("VeryGood") else color.gray);

def stoch6 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = ConsStpls, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "ConsStpls " + "(" + round(calcBeta(ConsStpls),2) + " / " + round(stoch6,2) + ")",
if stoch6 <= lowStockLimit and stoch6 <= stoch6[1] then GlobalColor("Bad") else
if stoch6 <= lowStockLimit and stoch6 >= stoch6[1] then GlobalColor("ModBad") else
if between(stoch6, lowStockLimit, 0.5) and stoch6 <= stoch6[1] then GlobalColor("SluggishBad") else
if between(stoch6, lowStockLimit, 0.5) and stoch6 >= stoch6[1] then GlobalColor("neutral") else
if between(stoch6, 0.5, upStochLimit) and stoch6 <= stoch6[1] then GlobalColor("SluggishGood") else
if between(stoch6, 0.5, upStochLimit) and stoch6 >= stoch6[1] then GlobalColor("SlightlyGood") else
if stoch6 >= upStochLimit  and stoch6 <= stoch6[1] then GlobalColor("ModGood") else
if stoch6 >= upStochLimit  and stoch6 >= stoch6[1] then GlobalColor("VeryGood") else color.gray);

def stoch5 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Energy, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Energy " + "(" + round(calcBeta(Energy),2) + " / " + round(stoch5,2) + ")",
if stoch5 <= lowStockLimit and stoch5 <= stoch5[1] then GlobalColor("Bad") else
if stoch5 <= lowStockLimit and stoch5 >= stoch5[1] then GlobalColor("ModBad") else
if between(stoch5, lowStockLimit, 0.5) and stoch5 <= stoch5[1] then GlobalColor("SluggishBad") else
if between(stoch5, lowStockLimit, 0.5) and stoch5 >= stoch5[1] then GlobalColor("neutral") else
if between(stoch5, 0.5, upStochLimit) and stoch5 <= stoch5[1] then GlobalColor("SluggishGood") else
if between(stoch5, 0.5, upStochLimit) and stoch5 >= stoch5[1] then GlobalColor("SlightlyGood") else
if stoch5 >= upStochLimit  and stoch5 <= stoch5[1] then GlobalColor("ModGood") else
if stoch5 >= upStochLimit  and stoch5 >= stoch5[1] then GlobalColor("VeryGood") else color.gray);

def stoch9 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Finance, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Finance " +  "(" + round(calcBeta(Finance),2) + " / " + round(stoch9,2) + ")",
if stoch9 <= lowStockLimit and stoch9 <= stoch9[1] then GlobalColor("Bad") else
if stoch9 <= lowStockLimit and stoch9 >= stoch9[1] then GlobalColor("ModBad") else
if between(stoch9, lowStockLimit, 0.5) and stoch9 <= stoch9[1] then GlobalColor("SluggishBad") else
if between(stoch9, lowStockLimit, 0.5) and stoch9 >= stoch9[1] then GlobalColor("neutral") else
if between(stoch9, 0.5, upStochLimit) and stoch9 <= stoch9[1] then GlobalColor("SluggishGood") else
if between(stoch9, 0.5, upStochLimit) and stoch9 >= stoch9[1] then GlobalColor("SlightlyGood") else
if stoch9 >= upStochLimit  and stoch9 <= stoch9[1] then GlobalColor("ModGood") else
if stoch9 >= upStochLimit  and stoch9 >= stoch9[1] then GlobalColor("VeryGood") else color.gray);

def stoch7 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Health, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Health " +  "(" + round(calcBeta(Health),2) + " / " + round(stoch7,2) + ")",
if stoch7 <= lowStockLimit and stoch7 <= stoch7[1] then GlobalColor("Bad") else
if stoch7 <= lowStockLimit and stoch7 >= stoch7[1] then GlobalColor("ModBad") else
if between(stoch7, lowStockLimit, 0.5) and stoch7 <= stoch7[1] then GlobalColor("SluggishBad") else
if between(stoch7, lowStockLimit, 0.5) and stoch7 >= stoch7[1] then GlobalColor("neutral") else
if between(stoch7, 0.5, upStochLimit) and stoch7 <= stoch7[1] then GlobalColor("SluggishGood") else
if between(stoch7, 0.5, upStochLimit) and stoch7 >= stoch7[1] then GlobalColor("SlightlyGood") else
if stoch7 >= upStochLimit  and stoch7 <= stoch7[1] then GlobalColor("ModGood") else
if stoch7 >= upStochLimit  and stoch7 >= stoch7[1] then GlobalColor("VeryGood") else color.gray);

def stoch3 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Industr, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Industr " +  "(" + round(calcBeta(Industr),2) + " / " + round(stoch3,2) + ")",
if stoch3 <= lowStockLimit and stoch3 <= stoch3[1] then GlobalColor("Bad") else
if stoch3 <= lowStockLimit and stoch3 >= stoch3[1] then GlobalColor("ModBad") else
if between(stoch3, lowStockLimit, 0.5) and stoch3 <= stoch3[1] then GlobalColor("SluggishBad") else
if between(stoch3, lowStockLimit, 0.5) and stoch3 >= stoch3[1] then GlobalColor("neutral") else
if between(stoch3, 0.5, upStochLimit) and stoch3 <= stoch3[1] then GlobalColor("SluggishGood") else
if between(stoch3, 0.5, upStochLimit) and stoch3 >= stoch3[1] then GlobalColor("SlightlyGood") else
if stoch3 >= upStochLimit  and stoch3 <= stoch3[1] then GlobalColor("ModGood") else
if stoch3 >= upStochLimit  and stoch3 >= stoch3[1] then GlobalColor("VeryGood") else color.gray);

def stoch4 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Mtls, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Mtls " +  "(" + round(calcBeta(Mtls),2) + " / " + round(stoch4,2) + ")",
if stoch4 <= lowStockLimit and stoch4 <= stoch4[1] then GlobalColor("Bad") else
if stoch4 <= lowStockLimit and stoch4 >= stoch4[1] then GlobalColor("ModBad") else
if between(stoch4, lowStockLimit, 0.5) and stoch4 <= stoch4[1] then GlobalColor("SluggishBad") else
if between(stoch4, lowStockLimit, 0.5) and stoch4 >= stoch4[1] then GlobalColor("neutral") else
if between(stoch4, 0.5, upStochLimit) and stoch4 <= stoch4[1] then GlobalColor("SluggishGood") else
if between(stoch4, 0.5, upStochLimit) and stoch4 >= stoch4[1] then GlobalColor("SlightlyGood") else
if stoch4 >= upStochLimit  and stoch4 <= stoch4[1] then GlobalColor("ModGood") else
if stoch4 >= upStochLimit  and stoch4 >= stoch4[1] then GlobalColor("VeryGood") else color.gray);

def stoch11 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = RealEst, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "RealEst " +  "(" + round(calcBeta(RealEst),2) + " / " + round(stoch11,2) + ")",
if stoch11 <= lowStockLimit and stoch11 <= stoch11[1] then GlobalColor("Bad") else
if stoch11 <= lowStockLimit and stoch11 >= stoch11[1] then GlobalColor("ModBad") else
if between(stoch11, lowStockLimit, 0.5) and stoch11 <= stoch11[1] then GlobalColor("SluggishBad") else
if between(stoch11, lowStockLimit, 0.5) and stoch11 >= stoch11[1] then GlobalColor("neutral") else
if between(stoch11, 0.5, upStochLimit) and stoch11 <= stoch11[1] then GlobalColor("SluggishGood") else
if between(stoch11, 0.5, upStochLimit) and stoch11 >= stoch11[1] then GlobalColor("SlightlyGood") else
if stoch11 >= upStochLimit  and stoch11 <= stoch11[1] then GlobalColor("ModGood") else
if stoch11 >= upStochLimit  and stoch11 >= stoch11[1] then GlobalColor("VeryGood") else color.gray);

def stoch12 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Retail, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Retail " +  "(" + round(calcBeta(Retail),2) + " / " + round(stoch12,2) + ")",
if stoch12 <= lowStockLimit and stoch12 <= stoch12[1] then GlobalColor("Bad") else
if stoch12 <= lowStockLimit and stoch12 >= stoch12[1] then GlobalColor("ModBad") else
if between(stoch12, lowStockLimit, 0.5) and stoch12 <= stoch12[1] then GlobalColor("SluggishBad") else
if between(stoch12, lowStockLimit, 0.5) and stoch12 >= stoch12[1] then GlobalColor("neutral") else
if between(stoch12, 0.5, upStochLimit) and stoch12 <= stoch12[1] then GlobalColor("SluggishGood") else
if between(stoch12, 0.5, upStochLimit) and stoch12 >= stoch12[1] then GlobalColor("SlightlyGood") else
if stoch12 >= upStochLimit  and stoch12 <= stoch12[1] then GlobalColor("ModGood") else
if stoch12 >= upStochLimit  and stoch12 >= stoch12[1] then GlobalColor("VeryGood") else color.gray);

def stoch2 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Tech, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Tech " +  "(" + round(calcBeta(Tech),2) + " / " + round(stoch2,2) + ")",
if stoch2 <= lowStockLimit and stoch2 <= stoch2[1] then GlobalColor("Bad") else
if stoch2 <= lowStockLimit and stoch2 >= stoch2[1] then GlobalColor("ModBad") else
if between(stoch2, lowStockLimit, 0.5) and stoch2 <= stoch2[1] then GlobalColor("SluggishBad") else
if between(stoch2, lowStockLimit, 0.5) and stoch2 >= stoch2[1] then GlobalColor("neutral") else
if between(stoch2, 0.5, upStochLimit) and stoch2 <= stoch2[1] then GlobalColor("SluggishGood") else
if between(stoch2, 0.5, upStochLimit) and stoch2 >= stoch2[1] then GlobalColor("SlightlyGood") else
if stoch2 >= upStochLimit  and stoch2 <= stoch2[1] then GlobalColor("ModGood") else
if stoch2 >= upStochLimit  and stoch2 >= stoch2[1] then GlobalColor("VeryGood") else color.gray);

def stoch8 = calcStoch( data = EhlersESSfilter( calcBeta(secondSymbol = Util, betaLength = betaLength) ), stochLength = StochLength);
AddLabel(showOverlay, "Util " +  "(" + round(calcBeta(Util),2) + " / " + round(stoch8,2) + ")",
if stoch8 <= lowStockLimit and stoch8 <= stoch8[1] then GlobalColor("Bad") else
if stoch8 <= lowStockLimit and stoch8 >= stoch8[1] then GlobalColor("ModBad") else
if between(stoch8, lowStockLimit, 0.5) and stoch8 <= stoch8[1] then GlobalColor("SluggishBad") else
if between(stoch8, lowStockLimit, 0.5) and stoch8 >= stoch8[1] then GlobalColor("neutral") else
if between(stoch8, 0.5, upStochLimit) and stoch8 <= stoch8[1] then GlobalColor("SluggishGood") else
if between(stoch8, 0.5, upStochLimit) and stoch8 >= stoch8[1] then GlobalColor("SlightlyGood") else
if stoch8 >= upStochLimit  and stoch8 <= stoch8[1] then GlobalColor("ModGood") else
if stoch8 >= upStochLimit  and stoch8 >= stoch8[1] then GlobalColor("VeryGood") else color.gray);

AddLabel(yes, " ", Color.BLACK);

# End Beta Rotation V1.3

 
Thread starter Similar threads Forum Replies Date
RmS59 Alternate Sector Analysis Study for ThinkorSwim Indicators 16
markos Sector Rotation Indicator for ThinkorSwim Indicators 83

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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