Weighted Advance/Decline For ThinkOrSwim

Thanks @Joshua - couldn't you just use the SPX change from open, instead, for the weighted piece of the code, and leave the unweighted as-is?

That would help avoid you needing to update the weights every day/week.
 

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

Thanks @Joshua - couldn't you just use the SPX change from open, instead, for the weighted piece of the code, and leave the unweighted as-is?

That would help avoid you needing to update the weights every day/week.

That's basically what you get with the histogram... There are a lot of other things you could do also.

Like, if you want to compare heavily weighted sectors to lightly weighted sectors, well, just compare them then... You could group them into heavy weight and light weight categories, how ever you decide, and just compare averages of the categories. Maybe toss in a third line of the S&P for good measure... no need to weight anything yourself.

Also... the Dow has the big boys, right? The NASDAQ is similar to XLK, which is the largest sector in the S&P. The S&P itself covers broad large cap, and the Russell covers small cap... Maybe toss in some important sectors like the transports. Give it a shot with plots of major indexes, see what you find, Might be useful, maybe not, like all things.

Given that adding up all the S&P sectors basically just comes out as the S&P, maybe try the S&P versus the Equal Weight S&P. Its just two things, no need to weight it either. Might provide a good look at large cap versus small cap. But then again, the S&P versus the Russell might work in that case too.

its just percent change after all. There is nothing particularly special about it.
 
I agree with Joshua,
After watching Peter on his latest video, he is making the graphic fit his narrative. He didn't know the stock was going to follow that line of his it was just a line he drew after the fact. Much like Histograms do. Blake's Fibonacci graphics are a better predictor of direction.

I've tried all kinds of combinations of this graphic and none of them really do anything magical. You base your decision on the fixed percentage you entered that is compared to a market percentage that changes hourly.

This just seems to be a snake oil salesman talking. I have subscribed to Peter and I lost more than I gained in my experience with him.
I think you should just look for the whale bets on something like sweep cast or even TDA trade flash window and bet with them on your favorite stocks. You would do better betting on those directions than with this mumbo jumbo histogram. At least whale better would sway the market into thinking the stock is going to go their way.
 
I agree with Joshua,
After watching Peter on his latest video, he is making the graphic fit his narrative. He didn't know the stock was going to follow that line of his it was just a line he drew after the fact. Much like Histograms do. Blake's Fibonacci graphics are a better predictor of direction.

I've tried all kinds of combinations of this graphic and none of them really do anything magical. You base your decision on the fixed percentage you entered that is compared to a market percentage that changes hourly.

This just seems to be a snake oil salesman talking. I have subscribed to Peter and I lost more than I gained in my experience with him.
I think you should just look for the whale bets on something like sweep cast or even TDA trade flash window and bet with them on your favorite stocks. You would do better betting on those directions than with this mumbo jumbo histogram. At least whale better would sway the market into thinking the stock is going to go their way.
What is Blake's Fibonacci?
 
Shadowtrader FX Hour
Hosted by Blake Young every Tuesday after the market.
He uses the Monkey bars as a standard distribution chart (only sideways, with standard deviations of -2, -1.8, -1.5, -1.2, 0, 1.2, 1.5, 1.8, 2.0 ) looking for what the fair price should be on stock the following day/month and uses the Fibonacci retracement tool in TDA as measuring stick to get the fair price of today's range and adjust it with the Fibonacci extension tool as an adjusted measuring stick to reposition the Fibonacci retracement values
then finally looking at where the stock closed that day, you can predict the stock will be going up or down with some certainty for the next day.

I was trying to code this but found it challenging to get some values. In any case, Blake is, and I find his process to be more reliable.
You can learn this process by watching his last three videos in slow mode and not paying the $95 for his classes.
 
I also was experimenting with alternatives using the actual Equal Weight Sector Indexes and the Standard Indexes, so you wouldn't need the weighting tables. The code was a bit ripped up and I had to put it back. I've also cleaned it up for your guys and also changed it to use Script{} in case you want to experiment farther. It takes some time to put all this together.

Anyway, in order for it to “match”, the weighting tables need to be the same as what you're comparing it to. We basically have samples from the video, and the screen shot that strange posted. I set the weights back to what they were in the video for the best match.

Forgive the MSPAINT distortions from lining up the images in the thin gray line


Luckily, strange's post doesn't include any updates to the weighting tables either, so we can still use that as well. He also has the real code I believe, so go ahead and ask him if you have any doubts about my code.


However, its not actually supposed match anymore. Price is a factor in market capitalization, sector weighting is dynamic. You're going to need to go to this page and update them, or else you're dealing with weights that are months out of date. Check it fairly frequently, it changes every day. It actually changes moment to moment in live markets, but this snap shot from yesterday is the closest thing.

O3jEQUF.png

(XLP in the script is 5.8)

This part is important; Its also apparently using the close of the first bar to establish the zero line for each day. This is why the first bar always appears to be skipped. This is wrong and it really should be changed to measure from the actual open, but I left it as close because that's the match.

This line:

Should be:


Code:
declare lower;
script PC {
    input Sym = "SPY";
    def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
    def O = if isFirstBar then close(Sym) else O[1];
    def C = close(Sym);
    plot PC = (C - O) / O;
}
def cXLK = PC("XLK");
def cXLY = PC("XLY");
def cXLV = PC("XLV");
def cXLF = PC("XLF");
def cXLC = PC("XLC");
def cXLI = PC("XLI");
def cXLP = PC("XLP");
def cXLRE = PC("XLRE");
def cXLE = PC("XLE");
def cXLB = PC("XLB");
def cXLU = PC("XLU");
def wXLK = cXLK * 27.9;
def wXLY = cXLY * 11.9;
def wXLV = cXLV * 13.4;
def wXLF = cXLF * 11.2;
def wXLC = cXLC * 11.5;
def wXLI = cXLI * 8.2;
def wXLP = cXLP * 5.8;
def wXLRE = cXLRE * 2.6;
def wXLE = cXLE * 2.4;
def wXLB = cXLB * 2.6;
def wXLU = cXLU * 2.5;
def wTotal =
    wXLK + wXLY + wXLV +
    wXLF + wXLC + wXLI +
    wXLP + wXLRE + wXLE +
    wXLB + wXLU
;
def uTotal =
    cXLK + cXLY + cXLV +
    cXLF + cXLC + cXLI +
    cXLP + cXLRE + cXLE +
    cXLB + cXLU

;
plot Histo = wtotal / 11;
plot Line = utotal ;
Line.setDefaultColor(color.gray);
Line.setlineWeight(1);
Histo.setpaintingStrategy(paintingStrategy.HISTOGRAM);
Histo.assignvalueColor(if Histo > Histo[1] then color.plum else color.yellow);
Histo.setlineWeight(1);
plot z = 0;

Here are the Equal Weights if you want to experiment with those too:
S9NgpIF.png
Joshua, thank you for your input on this!!
 
  • Like
Reactions: ion
Joshua, thank you for your input on this!!
Code:
declare lower;

script PC {
    # get primary symbol
    input Sym = "/ESH22";
    # onlyu plot during trading hours
    def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
    
    # get Opening unless this is the first bar of histogram to be drawn
    def O = if isFirstBar then open(Sym) else O[1];
    # get the close of the symbol
    def C = close(Sym);
    # draw the histogram base on Close - Open / Open
    plot PC = (C - O) / O;
}


# Ask User input
# for 11 stocks
input Stock01A = "XLK";
input Stock01_Weight = 27.9;#AAPL

input Stock02A = "XLY";
input Stock02_Weight = 11.9;#MSFT

input Stock03A = "XLV";
input Stock03_Weight = 13.4;  #AMZN

input Stock04A = "XLF";
input Stock04_Weight = 11.2; #TSLA

input Stock05A = "XLC";
input Stock05_Weight = 11.5; #GOOG

input Stock06A = "XLI";
input Stock06_Weight = 8.2; #NVDA

input Stock07A = "XLP";
input Stock07_Weight = 5.8; #GOOGL

input Stock08A = "XLRE";
input Stock08_Weight = 2.6;   #FB

input Stock09A = "XLE";
input Stock09_Weight = 2.4; #Broadcom

input Stock10A = "XLB";
input Stock10_Weight = 2.6; #CSCO

input Stock11A = "XLU";
input Stock11_Weight = 2.5; #COST

input StockDIV = 11;


# Calculate each stock01_Weight open and close
#
def cXLK = PC(Stock01A);
def cXLY = PC(Stock02A);
def cXLV = PC(Stock03A);
def cXLF = PC(Stock04A);
def cXLC = PC(Stock05A);
def cXLI = PC(Stock06A);
def cXLP = PC(Stock07A);
def cXLRE = PC(Stock08A);
def cXLE = PC(Stock09A);
def cXLB = PC(Stock10A);
def cXLU = PC(Stock11A);

# Now take closing value * weighted percentage
#
def wXLK = cXLK * Stock01_Weight;
def wXLY = cXLY * Stock02_Weight;
def wXLV = cXLV * Stock03_Weight;
def wXLF = cXLF * Stock04_Weight;
def wXLC = cXLC * Stock05_Weight;
def wXLI = cXLI * Stock06_Weight;
def wXLP = cXLP * Stock07_Weight;
def wXLRE = cXLRE * Stock08_Weight;
def wXLE = cXLE * Stock09_Weight;
def wXLB = cXLB * Stock10_Weight;
def wXLU = cXLU * Stock11_Weight;

# Sum up to get total weighted value
#
def wTotal =
    wXLK + wXLY + wXLV +
    wXLF + wXLC + wXLI +
    wXLP + wXLRE + wXLE +
    wXLB + wXLU
;

# Sum up to get toal unweighted value
#
def uTotal =
    cXLK + cXLY + cXLV +
    cXLF + cXLC + cXLI +
    cXLP + cXLRE + cXLE +
    cXLB + cXLU
;

plot Histo = wTotal / StockDIV;
plot Line = uTotal ;

# draw the histogram first
Histo.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Histo.AssignValueColor(if Histo > Histo[1] then Color.PLUM else Color.YELLOW);
Histo.SetLineWeight(1);
# draw then unweighted value in light cyan on top of the histogram
Line.SetDefaultColor(Color.CYAN);
Line.SetLineWeight(2);

# draw a center white line as reference
plot z = 0;
This script seems to work faster than the later versions. Made some changes to adjust the Stocks and Percentages with GUI
 
thanks for scripts and input from "Tofu, mrkya253, Stitrader, Joshua " and shadowtrader youtube videos.
updated script to spx weighted-ad-line, SP500 sector green BUBBLE and ndx nonweighed line.

Code:
# # Sources:
# best with 5 mins timeframe.
# concept from shadowtrader.net
# coded by TWOO
# https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data
# sector-breakdown

declare lower;
input open_time = 930;


input xlpwt = 6.2; #ConsumerStaples
input xluwt = 2.6; #Utilities
input xlcwt = 9.6; #Communications
input xlfwt = 11.5; #Financials
input xlbwt = 2.6; #Materials
input xliwt = 8.0; #Industrials
input xlewt = 3.7; #Energy
input xlrewt = 2.6; #RealEstate
input xlvwt = 13.3; #HealthCare
input xlkwt = 28.1; #InformationTechnology
input xlywt = 11.8; #ConsumerDiscretionary

def SectorCount = 11;
def Scale = 5000;

#SP500 ETF sectors percent change
script PC {
    input Symbol = "SPX";
    def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
    def O = if isFirstBar then close(Symbol) else O[1];
    def C = close(Symbol);
    plot PctChg = (C - O) / O;
}
def xlkPctChg = PC("XLK");
def xlyPctChg = PC("XLY");
def xlvPctChg = PC("XLV");
def xlfPctChg = PC("XLF");
def xlcPctChg = PC("XLC");
def xliPctChg = PC("XLI");
def xlpPctChg = PC("XLP");
def xlrePctChg = PC("XLRE");
def xlePctChg = PC("XLE");
def xlbPctChg = PC("XLB");
def xluPctChg = PC("XLU");


def xlkSizing = xlkPctChg * xlkwt;
def xlvSizing = xlvPctChg * xlvwt;
def xlySizing = xlyPctChg * xlywt;
def xlfSizing = xlfPctChg * xlfwt;
def xlcSizing = xlcPctChg * xlcwt;
def xliSizing = xliPctChg * xliwt;
def xlpSizing = xlpPctChg * xlpwt;
def xleSizing = xlePctChg * xlewt;
def xlreSizing = xlrePctChg * xlrewt;
def xlbSizing = xlbPctChg * xlbwt;
def xluSizing = xluPctChg * xluwt;
def combinedSizing = Scale * (
xlkSizing +
xlvSizing +
xlySizing +
xlfSizing +
xlcSizing +
xliSizing +
xlpSizing +
xleSizing +
xlreSizing +
xlbSizing +
xluSizing
) / SectorCount;

# Weighted_AD
plot Weighted_AD = if !IsNaN(combinedSizing) then combinedSizing else Double.NaN;
Weighted_AD.DefineColor("Lower", Color.YELLOW);
Weighted_AD.DefineColor("Higher", Color.MAGENTA);
Weighted_AD.AssignValueColor(if Weighted_AD < Weighted_AD[1] then Weighted_AD.Color("Lower") else  Weighted_AD.Color("Higher"));
Weighted_AD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#Zeroline
plot zero = 0;
zero.SetDefaultColor(Color.GRAY);
zero.HideBubble();
zero.HideTitle();

# SPX Non_Weighted_AD
def spxcombinedSizing = Scale *
(xlkPctChg +
xlvPctChg +
xlyPctChg +
xlfPctChg +
xlcPctChg +
xliPctChg +
xlpPctChg +
xlePctChg +
xlrePctChg +
xlbPctChg +
xluPctChg);
plot Non_Weighted_AD =  spxcombinedSizing ;
Non_Weighted_AD.SetDefaultColor(Color.WHITE);
Non_Weighted_AD.SetPaintingStrategy(PaintingStrategy.LINE);

# NDX Non_Weighted_AD
def NDXPctChg = PC("NDX") * 35000;
plot Non_Weighted_NDX = NDXPctChg   ;
Non_Weighted_NDX.SetDefaultColor(Color.CYAN);
Non_Weighted_NDX.SetLineWeight(1);
Non_Weighted_NDX.Hide();
Non_Weighted_NDX.HideBubble();
Non_Weighted_NDX.HideTitle();

AddVerticalLine(( GetDay() <> GetDay()[1]), "", Color.YeLLOW, Curve.SHORT_DASH);

#SP500 ETF sectors BUBBLE
Script pct {
input Symbol = "SPX";
def aggregationPeriod = AggregationPeriod.DAY;
def price = open(Symbol, period = aggregationPeriod);
def diff = close (Symbol) - open(Symbol, period = aggregationPeriod);
 plot d_pct = 100 * diff / price;
}

def XLK_d_pct = pct(“XLK”)  ;
 def XLV_d_pct = pct(“XLV”)  ;
def XLY_d_pct = pct(“XLY”)  ;
def XLC_d_pct = pct(“XLC”)  ;
 def XLF_d_pct = pct(“XLF”)  ;
 def XLI_d_pct = pct(“XLI”)  ;
 def XLP_d_pct = pct(“XLP”)  ;
 def XLRE_d_pct = pct(“XLRE”)  ;
 def XLB_d_pct = pct(“XLB”)  ;
 def XLU_d_pct = pct(“XLU”)  ;
def XLE_d_pct = pct(“XLE”)  ;

AddLabel(if xlk_d_pct  > 0 then 1 else 0, "InfoTech " + xlkwt + "%: " + xlk_d_pct,
 Color.GREEN);
AddLabel(if xlv_d_pct  > 0 then 1 else 0, " Healthcare " + xlvwt + "%: " + xlv_d_pct,
 Color.GREEN);
AddLabel(if xly_d_pct  > 0 then 1 else 0, " ConsDisc " + xlywt + "%: " + xly_d_pct,
 Color.GREEN);
AddLabel(if xlc_d_pct  > 0 then 1 else 0, " Comms " + xlcwt + "%: " + xlc_d_pct,
 Color.GREEN);
AddLabel(if xlf_d_pct  > 0 then 1 else 0, " Financials " + xlfwt + "%: " + xlf_d_pct,
 Color.GREEN);
AddLabel(if xli_d_pct  > 0 then 1 else 0, " Industrials " + xliwt + "%: " + xli_d_pct,
 Color.GREEN);
AddLabel(if xlp_d_pct  > 0 then 1 else 0, " ConsStaples " + xlpwt + "%: " + xlp_d_pct,
 Color.GREEN);
AddLabel(if xlre_d_pct  > 0 then 1 else 0, " RealEstate " + xlrewt + "%: " + xlre_d_pct,
 Color.GREEN);
AddLabel(if xlb_d_pct  > 0 then 1 else 0, " Materials " + xlbwt + "%: " + xlb_d_pct,
 Color.GREEN);
AddLabel(if xlu_d_pct  > 0 then 1 else 0, " Utilities " + xluwt + "%: " + xlu_d_pct,
 Color.GREEN);
AddLabel(if xle_d_pct  > 0 then 1 else 0, " Energy " + xlewt + "%: " + xle_d_pct,
 Color.GREEN);
 
Last edited:
thanks for scripts and input from "Tofu, mrkya253, Stitrader, Joshua " and shadowtrader youtube videos.
updated script to spx weighted-ad-line, SP500 sector green BUBBLE and ndx nonweighed line.

Code:
# # Sources:
# best with 5 mins timeframe.
# concept from shadowtrader.net
# coded by TWOO
# https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data
# sector-breakdown

declare lower;
input open_time = 930;


input xlpwt = 6.2; #ConsumerStaples
input xluwt = 2.6; #Utilities
input xlcwt = 9.6; #Communications
input xlfwt = 11.5; #Financials
input xlbwt = 2.6; #Materials
input xliwt = 8.0; #Industrials
input xlewt = 3.7; #Energy
input xlrewt = 2.6; #RealEstate
input xlvwt = 13.3; #HealthCare
input xlkwt = 28.1; #InformationTechnology
input xlywt = 11.8; #ConsumerDiscretionary

def SectorCount = 11;
def Scale = 5000;

#SP500 ETF sectors percent change
script PC {
    input Symbol = "SPX";
    def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
    def O = if isFirstBar then close(Symbol) else O[1];
    def C = close(Symbol);
    plot PctChg = (C - O) / O;
}
def xlkPctChg = PC("XLK");
def xlyPctChg = PC("XLY");
def xlvPctChg = PC("XLV");
def xlfPctChg = PC("XLF");
def xlcPctChg = PC("XLC");
def xliPctChg = PC("XLI");
def xlpPctChg = PC("XLP");
def xlrePctChg = PC("XLRE");
def xlePctChg = PC("XLE");
def xlbPctChg = PC("XLB");
def xluPctChg = PC("XLU");


def xlkSizing = xlkPctChg * xlkwt;
def xlvSizing = xlvPctChg * xlvwt;
def xlySizing = xlyPctChg * xlywt;
def xlfSizing = xlfPctChg * xlfwt;
def xlcSizing = xlcPctChg * xlcwt;
def xliSizing = xliPctChg * xliwt;
def xlpSizing = xlpPctChg * xlpwt;
def xleSizing = xlePctChg * xlewt;
def xlreSizing = xlrePctChg * xlrewt;
def xlbSizing = xlbPctChg * xlbwt;
def xluSizing = xluPctChg * xluwt;
def combinedSizing = Scale * (
xlkSizing +
xlvSizing +
xlySizing +
xlfSizing +
xlcSizing +
xliSizing +
xlpSizing +
xleSizing +
xlreSizing +
xlbSizing +
xluSizing
) / SectorCount;

# Weighted_AD
plot Weighted_AD = if !IsNaN(combinedSizing) then combinedSizing else Double.NaN;
Weighted_AD.DefineColor("Lower", Color.YELLOW);
Weighted_AD.DefineColor("Higher", Color.MAGENTA);
Weighted_AD.AssignValueColor(if Weighted_AD < Weighted_AD[1] then Weighted_AD.Color("Lower") else  Weighted_AD.Color("Higher"));
Weighted_AD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#Zeroline
plot zero = 0;
zero.SetDefaultColor(Color.GRAY);
zero.HideBubble();
zero.HideTitle();

# SPX Non_Weighted_AD
def spxcombinedSizing = Scale *
(xlkPctChg +
xlvPctChg +
xlyPctChg +
xlfPctChg +
xlcPctChg +
xliPctChg +
xlpPctChg +
xlePctChg +
xlrePctChg +
xlbPctChg +
xluPctChg);
plot Non_Weighted_AD =  spxcombinedSizing ;
Non_Weighted_AD.SetDefaultColor(Color.WHITE);
Non_Weighted_AD.SetPaintingStrategy(PaintingStrategy.LINE);

# NDX Non_Weighted_AD
def NDXPctChg = PC("NDX") * 35000;
plot Non_Weighted_NDX = NDXPctChg   ;
Non_Weighted_NDX.SetDefaultColor(Color.CYAN);
Non_Weighted_NDX.SetLineWeight(1);
Non_Weighted_NDX.Hide();
Non_Weighted_NDX.HideBubble();
Non_Weighted_NDX.HideTitle();

AddVerticalLine(( GetDay() <> GetDay()[1]), "", Color.YeLLOW, Curve.SHORT_DASH);

#SP500 ETF sectors BUBBLE
Script pct {
input Symbol = "SPX";
def aggregationPeriod = AggregationPeriod.DAY;
def price = open(Symbol, period = aggregationPeriod);
def diff = close (Symbol) - open(Symbol, period = aggregationPeriod);
 plot d_pct = 100 * diff / price;
}

def XLK_d_pct = pct(“XLK”)  ;
 def XLV_d_pct = pct(“XLV”)  ;
def XLY_d_pct = pct(“XLY”)  ;
def XLC_d_pct = pct(“XLC”)  ;
 def XLF_d_pct = pct(“XLF”)  ;
 def XLI_d_pct = pct(“XLI”)  ;
 def XLP_d_pct = pct(“XLP”)  ;
 def XLRE_d_pct = pct(“XLRE”)  ;
 def XLB_d_pct = pct(“XLB”)  ;
 def XLU_d_pct = pct(“XLU”)  ;
def XLE_d_pct = pct(“XLE”)  ;

AddLabel(if xlk_d_pct  > 0 then 1 else 0, "InfoTech " + xlkwt + "%: " + xlk_d_pct,
 Color.GREEN);
AddLabel(if xlv_d_pct  > 0 then 1 else 0, " Healthcare " + xlvwt + "%: " + xlv_d_pct,
 Color.GREEN);
AddLabel(if xly_d_pct  > 0 then 1 else 0, " ConsDisc " + xlywt + "%: " + xly_d_pct,
 Color.GREEN);
AddLabel(if xlc_d_pct  > 0 then 1 else 0, " Comms " + xlcwt + "%: " + xlc_d_pct,
 Color.GREEN);
AddLabel(if xlf_d_pct  > 0 then 1 else 0, " Financials " + xlfwt + "%: " + xlf_d_pct,
 Color.GREEN);
AddLabel(if xli_d_pct  > 0 then 1 else 0, " Industrials " + xliwt + "%: " + xli_d_pct,
 Color.GREEN);
AddLabel(if xlp_d_pct  > 0 then 1 else 0, " ConsStaples " + xlpwt + "%: " + xlp_d_pct,
 Color.GREEN);
AddLabel(if xlre_d_pct  > 0 then 1 else 0, " RealEstate " + xlrewt + "%: " + xlre_d_pct,
 Color.GREEN);
AddLabel(if xlb_d_pct  > 0 then 1 else 0, " Materials " + xlbwt + "%: " + xlb_d_pct,
 Color.GREEN);
AddLabel(if xlu_d_pct  > 0 then 1 else 0, " Utilities " + xluwt + "%: " + xlu_d_pct,
 Color.GREEN);
AddLabel(if xle_d_pct  > 0 then 1 else 0, " Energy " + xlewt + "%: " + xle_d_pct,
 Color.GREEN);
Thanks for the update TWO
I like to see the labels change according to the direction so adjusted the label section

AddLabel(yes, "InfoTech " + ROUND(xlkwt,2) + "%: ", (if xlk_d_pct > 0 then Color.GREEN else if xlk_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Healthcare " + ROUND(xlvwt,2) + "%: ", (if xlv_d_pct > 0 then Color.GREEN else if xlv_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsDisc " + ROUND(xlywt,2) + "%: ", (if xly_d_pct > 0 then Color.GREEN else if xly_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsDisc " + ROUND(xlcwt,2) + "%: ", (if xlc_d_pct > 0 then Color.GREEN else if xlc_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Financials " + ROUND(xlfwt,2) + "%: ", (if xlf_d_pct > 0 then Color.GREEN else if xlf_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Industrials " + ROUND(xliwt,2) + "%: ",(if xli_d_pct > 0 then Color.GREEN else if xli_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsStaples " + ROUND(xlpwt,2) + "%: ", (if xlp_d_pct > 0 then Color.GREEN else if xlp_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "RealEstate " + ROUND(xlrewt,2) + "%: ", (if xlre_d_pct > 0 then Color.GREEN else if xlre_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Materials " + ROUND(xlbwt,2) + "%: ", (if xlb_d_pct > 0 then Color.GREEN else if xlb_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Materials " + ROUND(xluwt,2) + "%: ", (if xlu_d_pct > 0 then Color.GREEN else if xlu_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Materials " + ROUND(xlewt,2) + "%: ", (if xle_d_pct > 0 then Color.GREEN else if xle_d_pct < 0 then color.RED else Color.gray));
 
Last edited:
Thanks to all!! I put twoo's script (love NDX line add) and used ion's tweek for bubble color. I made this all display in upper chart with $adspd as line chart for visual ease. After comparing to the weekend video I'm pleased with the outcome. Thanks again!
 
Thanks to all!! I put twoo's script (love NDX line add) and used ion's tweek for bubble color. I made this all display in upper chart with $adspd as line chart for visual ease. After comparing to the weekend video I'm pleased with the outcome. Thanks again!
@strange Can you please share the final script you have? TIA
 
@pk1729
Code:
# # Sources:
# best with 5 mins timeframe.
# concept from shadowtrader.net
# coded by TWOO
# https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data
# sector-breakdown

declare lower;
input open_time = 930;


input xlpwt = 6.2; #ConsumerStaples
input xluwt = 2.6; #Utilities
input xlcwt = 9.6; #Communications
input xlfwt = 11.5; #Financials
input xlbwt = 2.6; #Materials
input xliwt = 8.0; #Industrials
input xlewt = 3.7; #Energy
input xlrewt = 2.6; #RealEstate
input xlvwt = 13.3; #HealthCare
input xlkwt = 28.1; #InformationTechnology
input xlywt = 11.8; #ConsumerDiscretionary

def SectorCount = 11;
def Scale = 5000;

#SP500 ETF sectors percent change
script PC {
    input Symbol = "SPX";
    def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
    def O = if isFirstBar then close(Symbol) else O[1];
    def C = close(Symbol);
    plot PctChg = (C - O) / O;
}
def xlkPctChg = PC("XLK");
def xlyPctChg = PC("XLY");
def xlvPctChg = PC("XLV");
def xlfPctChg = PC("XLF");
def xlcPctChg = PC("XLC");
def xliPctChg = PC("XLI");
def xlpPctChg = PC("XLP");
def xlrePctChg = PC("XLRE");
def xlePctChg = PC("XLE");
def xlbPctChg = PC("XLB");
def xluPctChg = PC("XLU");


def xlkSizing = xlkPctChg * xlkwt;
def xlvSizing = xlvPctChg * xlvwt;
def xlySizing = xlyPctChg * xlywt;
def xlfSizing = xlfPctChg * xlfwt;
def xlcSizing = xlcPctChg * xlcwt;
def xliSizing = xliPctChg * xliwt;
def xlpSizing = xlpPctChg * xlpwt;
def xleSizing = xlePctChg * xlewt;
def xlreSizing = xlrePctChg * xlrewt;
def xlbSizing = xlbPctChg * xlbwt;
def xluSizing = xluPctChg * xluwt;
def combinedSizing = Scale * (
xlkSizing +
xlvSizing +
xlySizing +
xlfSizing +
xlcSizing +
xliSizing +
xlpSizing +
xleSizing +
xlreSizing +
xlbSizing +
xluSizing
) / SectorCount;

# Weighted_AD
plot Weighted_AD = if !IsNaN(combinedSizing) then combinedSizing else Double.NaN;
Weighted_AD.DefineColor("Lower", Color.YELLOW);
Weighted_AD.DefineColor("Higher", Color.MAGENTA);
Weighted_AD.AssignValueColor(if Weighted_AD < Weighted_AD[1] then Weighted_AD.Color("Lower") else  Weighted_AD.Color("Higher"));
Weighted_AD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#Zeroline
plot zero = 0;
zero.SetDefaultColor(Color.GRAY);
zero.HideBubble();
zero.HideTitle();

# SPX Non_Weighted_AD
def spxcombinedSizing = Scale *
(xlkPctChg +
xlvPctChg +
xlyPctChg +
xlfPctChg +
xlcPctChg +
xliPctChg +
xlpPctChg +
xlePctChg +
xlrePctChg +
xlbPctChg +
xluPctChg);
plot Non_Weighted_AD =  spxcombinedSizing ;
Non_Weighted_AD.SetDefaultColor(Color.WHITE);
Non_Weighted_AD.SetPaintingStrategy(PaintingStrategy.LINE);

# NDX Non_Weighted_AD
def NDXPctChg = PC("NDX") * 35000;
plot Non_Weighted_NDX = NDXPctChg   ;
Non_Weighted_NDX.SetDefaultColor(Color.CYAN);
Non_Weighted_NDX.SetLineWeight(1);
Non_Weighted_NDX.Hide();
Non_Weighted_NDX.HideBubble();
Non_Weighted_NDX.HideTitle();

AddVerticalLine(( GetDay() <> GetDay()[1]), "", Color.YeLLOW, Curve.SHORT_DASH);

#SP500 ETF sectors BUBBLE
Script pct {
input Symbol = "SPX";
def aggregationPeriod = AggregationPeriod.DAY;
def price = open(Symbol, period = aggregationPeriod);
def diff = close (Symbol) - open(Symbol, period = aggregationPeriod);
 plot d_pct = 100 * diff / price;
}

def XLK_d_pct = pct(“XLK”)  ;
 def XLV_d_pct = pct(“XLV”)  ;
def XLY_d_pct = pct(“XLY”)  ;
def XLC_d_pct = pct(“XLC”)  ;
 def XLF_d_pct = pct(“XLF”)  ;
 def XLI_d_pct = pct(“XLI”)  ;
 def XLP_d_pct = pct(“XLP”)  ;
 def XLRE_d_pct = pct(“XLRE”)  ;
 def XLB_d_pct = pct(“XLB”)  ;
 def XLU_d_pct = pct(“XLU”)  ;
def XLE_d_pct = pct(“XLE”)  ;

AddLabel(yes, "InfoTech 29.2%: " + XLK_d_pct,  (if xlk_d_pct > 0 then Color.GREEN else if xlk_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Healthcare 13.3%: " + XLV_d_pct, (if xlv_d_pct > 0 then Color.GREEN else if xlv_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsDisc 12.5%: " + XLY_d_pct, (if xly_d_pct > 0 then Color.GREEN else if xly_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Comms 10.2%: " + XLC_d_pct, (if xlc_d_pct > 0 then Color.GREEN else if xlc_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Financials 10.7%: " + XLF_d_pct, (if xlf_d_pct > 0 then Color.GREEN else if xlf_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Industrials 7.8%: " + XLI_d_pct,(if xli_d_pct > 0 then Color.GREEN else if xli_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsStaples 5.9%: " + XLP_d_pct, (if xlp_d_pct > 0 then Color.GREEN else if xlp_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "RealEstate 2.8%: " + XLRE_d_pct,(if xlre_d_pct > 0 then Color.GREEN else if xlre_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Materials 2.6%: " + XLB_d_pct, (if xlb_d_pct > 0 then Color.GREEN else if xlb_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Utilities 2.5%: " + XLU_d_pct, (if xlu_d_pct > 0 then Color.GREEN else if xlu_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Energy 2.7%: " + XLE_d_pct,(if xle_d_pct > 0 then Color.GREEN else if xle_d_pct < 0 then color.RED else Color.gray));plot Data = close
 
Code:
# # Sources:
# best with 5 mins timeframe.
# concept from shadowtrader.net
# coded by TWOO
# https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data
# sector-breakdown

declare lower;
input open_time = 930;


input xlpwt = 6.8; #ConsumerStaples
input xluwt = 2.9; #Utilities
input xlcwt = 8.6; #Communications
input xlfwt = 11.0; #Financials
input xlbwt = 2.8; #Materials
input xliwt = 8.0; #Industrials
input xlewt = 4.2; #Energy
input xlrewt = 2.9; #RealEstate
input xlvwt = 14.2; #HealthCare
input xlkwt = 27.2; #InformationTechnology
input xlywt = 11.5; #ConsumerDiscretionary

def SectorCount = 11;
def Scale = 5000;

#SP500 ETF sectors percent change
script PC {
    input Symbol = "SPX";
    def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
    def O = if isFirstBar then close(Symbol) else O[1];
    def C = close(Symbol);
    plot PctChg = (C - O) / O;
}
def xlkPctChg = PC("XLK");
def xlyPctChg = PC("XLY");
def xlvPctChg = PC("XLV");
def xlfPctChg = PC("XLF");
def xlcPctChg = PC("XLC");
def xliPctChg = PC("XLI");
def xlpPctChg = PC("XLP");
def xlrePctChg = PC("XLRE");
def xlePctChg = PC("XLE");
def xlbPctChg = PC("XLB");
def xluPctChg = PC("XLU");


def xlkSizing = xlkPctChg * xlkwt;
def xlvSizing = xlvPctChg * xlvwt;
def xlySizing = xlyPctChg * xlywt;
def xlfSizing = xlfPctChg * xlfwt;
def xlcSizing = xlcPctChg * xlcwt;
def xliSizing = xliPctChg * xliwt;
def xlpSizing = xlpPctChg * xlpwt;
def xleSizing = xlePctChg * xlewt;
def xlreSizing = xlrePctChg * xlrewt;
def xlbSizing = xlbPctChg * xlbwt;
def xluSizing = xluPctChg * xluwt;
def combinedSizing = Scale * (
xlkSizing +
xlvSizing +
xlySizing +
xlfSizing +
xlcSizing +
xliSizing +
xlpSizing +
xleSizing +
xlreSizing +
xlbSizing +
xluSizing
) / SectorCount;

# Weighted_AD
plot Weighted_AD = if !IsNaN(combinedSizing) then combinedSizing else Double.NaN;
Weighted_AD.DefineColor("Lower", Color.YELLOW);
Weighted_AD.DefineColor("Higher", Color.MAGENTA);
Weighted_AD.AssignValueColor(if Weighted_AD < Weighted_AD[1] then Weighted_AD.Color("Lower") else  Weighted_AD.Color("Higher"));
Weighted_AD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#Zeroline
plot zero = 0;
zero.SetDefaultColor(Color.GRAY);
zero.HideBubble();
zero.HideTitle();

# SPX Non_Weighted_AD
def spxcombinedSizing = Scale *
(xlkPctChg +
xlvPctChg +
xlyPctChg +
xlfPctChg +
xlcPctChg +
xliPctChg +
xlpPctChg +
xlePctChg +
xlrePctChg +
xlbPctChg +
xluPctChg);
plot Non_Weighted_AD =  spxcombinedSizing ;
Non_Weighted_AD.SetDefaultColor(Color.WHITE);
Non_Weighted_AD.SetPaintingStrategy(PaintingStrategy.LINE);

# NDX Non_Weighted_AD
def NDXPctChg = PC("NDX") * 35000;
plot Non_Weighted_NDX = NDXPctChg   ;
Non_Weighted_NDX.SetDefaultColor(Color.CYAN);
Non_Weighted_NDX.SetLineWeight(1);
Non_Weighted_NDX.Hide();
Non_Weighted_NDX.HideBubble();
Non_Weighted_NDX.HideTitle();

AddVerticalLine(( GetDay() <> GetDay()[1]), "", Color.YeLLOW, Curve.SHORT_DASH);

#SP500 ETF sectors BUBBLE
Script pct {
input Symbol = "SPX";
def aggregationPeriod = AggregationPeriod.DAY;
def price = open(Symbol, period = aggregationPeriod);
def diff = close (Symbol) - open(Symbol, period = aggregationPeriod);
 plot d_pct = 100 * diff / price;
}

def XLK_d_pct = pct(“XLK”)  ;
 def XLV_d_pct = pct(“XLV”)  ;
def XLY_d_pct = pct(“XLY”)  ;
def XLC_d_pct = pct(“XLC”)  ;
 def XLF_d_pct = pct(“XLF”)  ;
 def XLI_d_pct = pct(“XLI”)  ;
 def XLP_d_pct = pct(“XLP”)  ;
 def XLRE_d_pct = pct(“XLRE”)  ;
 def XLB_d_pct = pct(“XLB”)  ;
 def XLU_d_pct = pct(“XLU”)  ;
def XLE_d_pct = pct(“XLE”)  ;

AddLabel(yes, "InfoTech 27.2%: " + XLK_d_pct,  (if xlk_d_pct > 0 then Color.GREEN else if xlk_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Healthcare 14.2%: " + XLV_d_pct, (if xlv_d_pct > 0 then Color.GREEN else if xlv_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsDisc 11.5: " + XLY_d_pct, (if xly_d_pct > 0 then Color.GREEN else if xly_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Comms 8.6%: " + XLC_d_pct, (if xlc_d_pct > 0 then Color.GREEN else if xlc_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Financials 11.0%: " + XLF_d_pct, (if xlf_d_pct > 0 then Color.GREEN else if xlf_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Industrials 8.0%: " + XLI_d_pct,(if xli_d_pct > 0 then Color.GREEN else if xli_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsStaples 6.8%: " + XLP_d_pct, (if xlp_d_pct > 0 then Color.GREEN else if xlp_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "RealEstate 2.9%: " + XLRE_d_pct,(if xlre_d_pct > 0 then Color.GREEN else if xlre_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Materials 2.8%: " + XLB_d_pct, (if xlb_d_pct > 0 then Color.GREEN else if xlb_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Utilities 2.9%: " + XLU_d_pct, (if xlu_d_pct > 0 then Color.GREEN else if xlu_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Energy 4.2%: " + XLE_d_pct,(if xle_d_pct > 0 then Color.GREEN else if xle_d_pct < 0 then color.RED else Color.gray));

post includes these new weightings
360f2905781add02992d2c8&id=09b2899c8a&e=efc611f67b.png
 
Last edited:
Link to the indicator: http://tos.mx/pL7BP15



Code:
# # Sources:
# best with 5 mins timeframe.
# concept from shadowtrader.net
# coded by TWOO
# https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data
# sector-breakdown
# modified by CWPARKER23

declare lower;
input open_time = 930;

DEF displace = 0;
input length = 12;
input xlpwt = 6.8; #ConsumerStaples
input xluwt = 2.9; #Utilities
input xlcwt = 8.6; #Communications
input xlfwt = 11.0; #Financials
input xlbwt = 2.8; #Materials
input xliwt = 8.0; #Industrials
input xlewt = 4.2; #Energy
input xlrewt = 2.9; #RealEstate
input xlvwt = 14.2; #HealthCare
input xlkwt = 27.2; #InformationTechnology
input xlywt = 11.5; #ConsumerDiscretionary

def SectorCount = 11;
def Scale = 5000;

#SP500 ETF sectors percent change
script PC {
    input Symbol = "SPX";
    def isFirstBar = GetTime() == RegularTradingStart(GetYYYYMMDD()) + 1;
    def O = if isFirstBar then close(Symbol) else O[1];
    def C = close(Symbol);
    plot PctChg = (C - O) / O;
}
def xlkPctChg = PC("XLK");
def xlyPctChg = PC("XLY");
def xlvPctChg = PC("XLV");
def xlfPctChg = PC("XLF");
def xlcPctChg = PC("XLC");
def xliPctChg = PC("XLI");
def xlpPctChg = PC("XLP");
def xlrePctChg = PC("XLRE");
def xlePctChg = PC("XLE");
def xlbPctChg = PC("XLB");
def xluPctChg = PC("XLU");


def xlkSizing = xlkPctChg * xlkwt;
def xlvSizing = xlvPctChg * xlvwt;
def xlySizing = xlyPctChg * xlywt;
def xlfSizing = xlfPctChg * xlfwt;
def xlcSizing = xlcPctChg * xlcwt;
def xliSizing = xliPctChg * xliwt;
def xlpSizing = xlpPctChg * xlpwt;
def xleSizing = xlePctChg * xlewt;
def xlreSizing = xlrePctChg * xlrewt;
def xlbSizing = xlbPctChg * xlbwt;
def xluSizing = xluPctChg * xluwt;
def combinedSizing = Scale * (
xlkSizing +
xlvSizing +
xlySizing +
xlfSizing +
xlcSizing +
xliSizing +
xlpSizing +
xleSizing +
xlreSizing +
xlbSizing +
xluSizing
) / SectorCount;

# Weighted_AD
DEF Weighted_AD = if !IsNaN(combinedSizing) then combinedSizing else Double.NaN;
#Weighted_AD.DefineColor("Lower", Color.YELLOW);
#Weighted_AD.DefineColor("Higher", Color.MAGENTA);
#Weighted_AD.AssignValueColor(if Weighted_AD < Weighted_AD[1] then Weighted_AD.Color("Lower") else  Weighted_AD.Color("Higher"));
#Weighted_AD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

plot LowerBand = Lowest(Weighted_AD[-displace + 1], length);
LowerBand.SetDefaultColor(GetColor(8));

plot UpperBand = Highest(Weighted_AD[-displace + 1], length);
UpperBand.SetDefaultColor(GetColor(1));

PLOT MID = (UPPERBand + LOWErBand)/2;


plot Diff_Weighted_AD = Weighted_AD;

Diff_Weighted_AD.SetDefaultColor(GetColor(5));
Diff_Weighted_AD.SetPaintingStrategy(PaintingStrategy.sQUARED_HISTOGRAM);
Diff_Weighted_AD.SetLineWeight(3);
Diff_Weighted_AD.DefineColor("Positive and Up", Color.GREEN);
Diff_Weighted_AD.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff_Weighted_AD.DefineColor("Negative and Down", Color.RED);
Diff_Weighted_AD.DefineColor("Negative and Up", Color.pink);
Diff_Weighted_AD.AssignValueColor(if Diff_Weighted_AD >= 0 then if Diff_Weighted_AD > Diff_Weighted_AD[1] then Diff_Weighted_AD.color("Positive and Up") else Diff_Weighted_AD.color("Positive and Down") else if Diff_Weighted_AD < Diff_Weighted_AD[1] then Diff_Weighted_AD.color("Negative and Down") else Diff_Weighted_AD.color("Negative and Up"));

#Zeroline
plot zero = 0;
zero.SetDefaultColor(Color.GRAY);
zero.HideBubble();
zero.HideTitle();

# SPX Non_Weighted_AD
def spxcombinedSizing = Scale *
(xlkPctChg +
xlvPctChg +
xlyPctChg +
xlfPctChg +
xlcPctChg +
xliPctChg +
xlpPctChg +
xlePctChg +
xlrePctChg +
xlbPctChg +
xluPctChg);
plot Non_Weighted_AD =  spxcombinedSizing ;
Non_Weighted_AD.SetDefaultColor(Color.WHITE);
Non_Weighted_AD.SetPaintingStrategy(PaintingStrategy.LINE);
DefineGlobalColor("Bullish", Color.cyan);
DefineGlobalColor("Bearish", Color.pink);
AddCloud(Non_Weighted_AD, zero , globalColor("Bullish"), globalColor("Bearish"));
# NDX Non_Weighted_AD
def NDXPctChg = PC("NDX") * 35000;
plot Non_Weighted_NDX = NDXPctChg   ;
Non_Weighted_NDX.SetDefaultColor(Color.CYAN);
Non_Weighted_NDX.SetLineWeight(1);
Non_Weighted_NDX.Hide();
Non_Weighted_NDX.HideBubble();
Non_Weighted_NDX.HideTitle();

def na = double.NaN ;
def isbulldiv = if (weighted_AD - weighted_AD[1] )>0 and (LOW[1] - LOW)>0 then 1 else 0;
def isbeardiv = if (weighted_AD[1] - weighted_AD )>0  and (HIGH - HIGH[1])>0  then 1 else 0;

DEF PositveDivergence = if
        
         isbulldiv > 0 then
        non_Weighted_AD else na;
    
plot PD = if PositveDivergence IS TRUE then non_Weighted_AD else Double.NaN;
PD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
PD.SetDefaultColor(Color.WHITE);
PD.HideBubble();
PD.HideTitle();

DEF NegativeDivergence = if
        
         isbeardiv > 0 then
        non_Weighted_AD else na;
    
plot ND = if NEGativeDivergence  IS TRUE then non_Weighted_AD else Double.NaN;
ND.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ND.SetDefaultColor(Color.YELLOW);
ND.HideBubble();
ND.HideTitle();





AddVerticalLine(( GetDay() <> GetDay()[1]), "", Color.YeLLOW, Curve.SHORT_DASH);

#SP500 ETF sectors BUBBLE
Script pct {
input Symbol = "SPX";
def aggregationPeriod = AggregationPeriod.DAY;
def price = open(Symbol, period = aggregationPeriod);
def diff = close (Symbol) - open(Symbol, period = aggregationPeriod);
 plot d_pct = 100 * diff / price;
}

def XLK_d_pct = pct(“XLK”)  ;
 def XLV_d_pct = pct(“XLV”)  ;
def XLY_d_pct = pct(“XLY”)  ;
def XLC_d_pct = pct(“XLC”)  ;
 def XLF_d_pct = pct(“XLF”)  ;
 def XLI_d_pct = pct(“XLI”)  ;
 def XLP_d_pct = pct(“XLP”)  ;
 def XLRE_d_pct = pct(“XLRE”)  ;
 def XLB_d_pct = pct(“XLB”)  ;
 def XLU_d_pct = pct(“XLU”)  ;
def XLE_d_pct = pct(“XLE”)  ;

AddLabel(yes, "InfoTech 27.2%: " + XLK_d_pct,  (if xlk_d_pct > 0 then Color.GREEN else if xlk_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Healthcare 14.2%: " + XLV_d_pct, (if xlv_d_pct > 0 then Color.GREEN else if xlv_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsDisc 11.5: " + XLY_d_pct, (if xly_d_pct > 0 then Color.GREEN else if xly_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Comms 8.6%: " + XLC_d_pct, (if xlc_d_pct > 0 then Color.GREEN else if xlc_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Financials 11.0%: " + XLF_d_pct, (if xlf_d_pct > 0 then Color.GREEN else if xlf_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Industrials 8.0%: " + XLI_d_pct,(if xli_d_pct > 0 then Color.GREEN else if xli_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "ConsStaples 6.8%: " + XLP_d_pct, (if xlp_d_pct > 0 then Color.GREEN else if xlp_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "RealEstate 2.9%: " + XLRE_d_pct,(if xlre_d_pct > 0 then Color.GREEN else if xlre_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Materials 2.8%: " + XLB_d_pct, (if xlb_d_pct > 0 then Color.GREEN else if xlb_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Utilities 2.9%: " + XLU_d_pct, (if xlu_d_pct > 0 then Color.GREEN else if xlu_d_pct < 0 then color.RED else Color.gray));

AddLabel(yes, "Energy 4.2%: " + XLE_d_pct,(if xle_d_pct > 0 then Color.GREEN else if xle_d_pct < 0 then color.RED else Color.gray));
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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