Nope. Not supposed to be working. I said I don't know what the symbols for ToS are for the sectors.Is this supposed work ?nothing's showing up
Nope. Not supposed to be working. I said I don't know what the symbols for ToS are for the sectors.Is this supposed work ?nothing's showing up
If its not much to ask for, could it still be possible for you to share this script here or something similar? Thanks in advance
It is used to see the difference between the weighted sectors vs. unweightedSomething isn't right here.
- The Advance/Decline ($ADSPD) represents the cumulative difference between the number of advancing and declining stocks within SPX.
Example: NWS (weight 0.000715 in the SPX) have the same "$ADSPD weight" as the 1000 times bigger AAPL (weight 7.074 in the SPX)
- The Weighted Advance/Decline distributes the "weight" based on the sectors XLK 27.6%, XLV 13.5%, XLV 12.7%, etc.)
Watch begining it's a companion to advance/ decline line. It is used to see the difference between the weighted sectors vs. unweightedThe indicator called Weighted_SPX_Sector_AD
There are no references to the advance/decline of individual sectors, or to anything else like $ADD, $ADSPD, or to any other advance/decline data, weighted or otherwise, whatsoever, at any point within the actual code of this indicator.
# # Sources:
# https://siblisresearch.com/data/us-sector-weightings/
# https://seekingalpha.com/etfs-and-funds/etf-tables/sectors
# https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data
# debug
declare lower;
declare once_per_bar;
input open_time = 930;
input ConsumerStaples = 5.88; #XLP
input Utilities = 2.5; #XLU
input Communications = 10.16; #XLC
input Financials = 10.69; #XLF
input Materials = 2.56; #XLB
input Industrials = 7.77; #XLI
input Energy = 2.67; #XLE
input RealEstate = 2.77; #XLRE
input HealthCare = 13.29; #XLV
input InformationTechnology = 29.17; #XLK
input ConsumerDiscretionary = 12.54; #XLY
input sticker = "SPX";
def SectorCount = 11;
def NewDay = SecondsFromTime(open_time) < SecondsFromTime(open_time)[1];
def xlkWeight = InformationTechnology;
def xlvWeight = HealthCare;
def xlyWeight = ConsumerDiscretionary;
def xlfWeight = Financials;
def xlcWeight = Communications;
def xliWeight = Industrials;
def xlpWeight = ConsumerStaples;
def xleWeight = Energy;
def xlreWeight = RealEstate;
def xlbWeight = Materials;
def xluWeight = Utilities;
def xlk = close("XLK");
def xlv = close("XLV");
def xly = close("XLY");
def xlf = close("XLF");
def xlc = close("XLC");
def xli = close("XLI");
def xlp = close("XLP");
def xle = close("XLE");
def xlre = close("XLRE");
def xlb = close("XLB");
def xlu = close("XLU");
def xlkprice = open("XLK");
def xlvprice = open("XLV");
def xlyprice = open("XLY");
def xlfprice = open("XLF");
def xlcprice = open("XLC");
def xliprice = open("XLI");
def xlpprice = open("XLP");
def xleprice = open("XLE");
def xlreprice = open("XLRE");
def xlbprice = open("XLB");
def xluprice = open("XLU");
def xlkChangePercent = (xlk - xlkprice) / xlkprice;
def xlvChangePercent = (xlv - xlvprice) / xlvprice;
def xlyChangePercent = (xly - xlyprice) / xlyprice;
def xlfChangePercent = (xlf - xlfprice) / xlfprice;
def xlcChangePercent = (xlc - xlcprice) / xlcprice;
def xliChangePercent = (xli - xliprice) / xliprice;
def xlpChangePercent = (xlp - xlpprice) / xlpprice;
def xleChangePercent = (xle - xleprice) / xleprice;
def xlreChangePercent = (xlre - xlreprice) / xlreprice;
def xlbChangePercent = (xlb - xlbprice) / xlbprice;
def xluChangePercent = (xlu - xluprice) / xluprice;
def xlkSizing = xlkChangePercent * xlkWeight;
def xlvSizing = xlvChangePercent * xlvWeight;
def xlySizing = xlyChangePercent * xlyWeight;
def xlfSizing = xlfChangePercent * xlfWeight;
def xlcSizing = xlcChangePercent * xlcWeight;
def xliSizing = xliChangePercent * xliWeight;
def xlpSizing = xlpChangePercent * xlpWeight;
def xleSizing = xleChangePercent * xleWeight;
def xlreSizing = xlreChangePercent * xlreWeight;
def xlbSizing = xlbChangePercent * xlbWeight;
def xluSizing = xluChangePercent * xluWeight;
def combinedSizing = 6000 * (
xlkSizing +
xlvSizing +
xlySizing +
xlfSizing +
xlcSizing +
xliSizing +
xlpSizing +
xleSizing +
xlreSizing +
xlbSizing +
xluSizing
) / SectorCount;
def cumuCombinedSizing = if NewDay then combinedSizing else cumuCombinedSizing[1] + combinedSizing;
# Display
plot cumuSectorWeightAD = if !IsNaN(combinedSizing) then cumuCombinedSizing else Double.NaN;
cumuSectorWeightAD.AssignValueColor(if cumuSectorWeightAD < cumuSectorWeightAD[1] then Color.YELLOW else Color.MAGENTA);
cumuSectorWeightAD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot zeroLine = 0;
zeroLine.AssignValueColor(Color.WHITE);
zeroLine.HideBubble();
zeroLine.HideTitle();
def spx = close("SPX");
def spxprice = open("SPX");
def spxChangePercent = (spx - spxprice) / spxprice;
def spxSizing = spxChangePercent * 100 / SectorCount;
def spxcombinedSizing = spxSizing * 6000;
def cumuSPX = if NewDay then spxcombinedSizing else cumuSPX[1] + spxcombinedSizing;
plot cumuSPXAD = if spxChangePercent != 0 then cumuSPX else Double.NaN ;
cumuSPXAD.AssignValueColor(Color.white);
cumuSPXAD.SetPaintingStrategy(PaintingStrategy.LINE);
This is what im seeing vs. yours. Very close as day progressed Monday and later Friday. But beginning of both days look very differentthis is what I get so far. I am not sure calculations are correct.
Code:# # Sources: # https://siblisresearch.com/data/us-sector-weightings/ # https://seekingalpha.com/etfs-and-funds/etf-tables/sectors # https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data # debug declare lower; declare once_per_bar; input open_time = 930; input ConsumerStaples = 5.88; #XLP input Utilities = 2.5; #XLU input Communications = 10.16; #XLC input Financials = 10.69; #XLF input Materials = 2.56; #XLB input Industrials = 7.77; #XLI input Energy = 2.67; #XLE input RealEstate = 2.77; #XLRE input HealthCare = 13.29; #XLV input InformationTechnology = 29.17; #XLK input ConsumerDiscretionary = 12.54; #XLY input sticker = "SPX"; def SectorCount = 11; def NewDay = SecondsFromTime(open_time) < SecondsFromTime(open_time)[1]; def xlkWeight = InformationTechnology; def xlvWeight = HealthCare; def xlyWeight = ConsumerDiscretionary; def xlfWeight = Financials; def xlcWeight = Communications; def xliWeight = Industrials; def xlpWeight = ConsumerStaples; def xleWeight = Energy; def xlreWeight = RealEstate; def xlbWeight = Materials; def xluWeight = Utilities; def xlk = close("XLK"); def xlv = close("XLV"); def xly = close("XLY"); def xlf = close("XLF"); def xlc = close("XLC"); def xli = close("XLI"); def xlp = close("XLP"); def xle = close("XLE"); def xlre = close("XLRE"); def xlb = close("XLB"); def xlu = close("XLU"); def xlkprice = open("XLK"); def xlvprice = open("XLV"); def xlyprice = open("XLY"); def xlfprice = open("XLF"); def xlcprice = open("XLC"); def xliprice = open("XLI"); def xlpprice = open("XLP"); def xleprice = open("XLE"); def xlreprice = open("XLRE"); def xlbprice = open("XLB"); def xluprice = open("XLU"); def xlkChangePercent = (xlk - xlkprice) / xlkprice; def xlvChangePercent = (xlv - xlvprice) / xlvprice; def xlyChangePercent = (xly - xlyprice) / xlyprice; def xlfChangePercent = (xlf - xlfprice) / xlfprice; def xlcChangePercent = (xlc - xlcprice) / xlcprice; def xliChangePercent = (xli - xliprice) / xliprice; def xlpChangePercent = (xlp - xlpprice) / xlpprice; def xleChangePercent = (xle - xleprice) / xleprice; def xlreChangePercent = (xlre - xlreprice) / xlreprice; def xlbChangePercent = (xlb - xlbprice) / xlbprice; def xluChangePercent = (xlu - xluprice) / xluprice; def xlkSizing = xlkChangePercent * xlkWeight; def xlvSizing = xlvChangePercent * xlvWeight; def xlySizing = xlyChangePercent * xlyWeight; def xlfSizing = xlfChangePercent * xlfWeight; def xlcSizing = xlcChangePercent * xlcWeight; def xliSizing = xliChangePercent * xliWeight; def xlpSizing = xlpChangePercent * xlpWeight; def xleSizing = xleChangePercent * xleWeight; def xlreSizing = xlreChangePercent * xlreWeight; def xlbSizing = xlbChangePercent * xlbWeight; def xluSizing = xluChangePercent * xluWeight; def combinedSizing = 6000 * ( xlkSizing + xlvSizing + xlySizing + xlfSizing + xlcSizing + xliSizing + xlpSizing + xleSizing + xlreSizing + xlbSizing + xluSizing ) / SectorCount; def cumuCombinedSizing = if NewDay then combinedSizing else cumuCombinedSizing[1] + combinedSizing; # Display plot cumuSectorWeightAD = if !IsNaN(combinedSizing) then cumuCombinedSizing else Double.NaN; cumuSectorWeightAD.AssignValueColor(if cumuSectorWeightAD < cumuSectorWeightAD[1] then Color.YELLOW else Color.MAGENTA); cumuSectorWeightAD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); plot zeroLine = 0; zeroLine.AssignValueColor(Color.WHITE); zeroLine.HideBubble(); zeroLine.HideTitle(); def spx = close("SPX"); def spxprice = open("SPX"); def spxChangePercent = (spx - spxprice) / spxprice; def spxSizing = spxChangePercent * 100 / SectorCount; def spxcombinedSizing = spxSizing * 6000; def cumuSPX = if NewDay then spxcombinedSizing else cumuSPX[1] + spxcombinedSizing; plot cumuSPXAD = if spxChangePercent != 0 then cumuSPX else Double.NaN ; cumuSPXAD.AssignValueColor(Color.white); cumuSPXAD.SetPaintingStrategy(PaintingStrategy.LINE);
Thanks, i think the script is working good except for the start, from what i am seeing on ShadowTraders screen, he is skipping the first bar of the day, if i am looking at 5min chart, i only see 5 bars on his screenshot, but in this script we have 6 bars. How can we skip the first bar on a given day?this is what I get so far. I am not sure calculations are correct.
Code:# # Sources: # https://siblisresearch.com/data/us-sector-weightings/ # https://seekingalpha.com/etfs-and-funds/etf-tables/sectors # https://www.spglobal.com/spdji/en/indices/equity/sp-500/#data # debug declare lower; declare once_per_bar; input open_time = 930; input ConsumerStaples = 5.88; #XLP input Utilities = 2.5; #XLU input Communications = 10.16; #XLC input Financials = 10.69; #XLF input Materials = 2.56; #XLB input Industrials = 7.77; #XLI input Energy = 2.67; #XLE input RealEstate = 2.77; #XLRE input HealthCare = 13.29; #XLV input InformationTechnology = 29.17; #XLK input ConsumerDiscretionary = 12.54; #XLY input sticker = "SPX"; def SectorCount = 11; def NewDay = SecondsFromTime(open_time) < SecondsFromTime(open_time)[1]; def xlkWeight = InformationTechnology; def xlvWeight = HealthCare; def xlyWeight = ConsumerDiscretionary; def xlfWeight = Financials; def xlcWeight = Communications; def xliWeight = Industrials; def xlpWeight = ConsumerStaples; def xleWeight = Energy; def xlreWeight = RealEstate; def xlbWeight = Materials; def xluWeight = Utilities; def xlk = close("XLK"); def xlv = close("XLV"); def xly = close("XLY"); def xlf = close("XLF"); def xlc = close("XLC"); def xli = close("XLI"); def xlp = close("XLP"); def xle = close("XLE"); def xlre = close("XLRE"); def xlb = close("XLB"); def xlu = close("XLU"); def xlkprice = open("XLK"); def xlvprice = open("XLV"); def xlyprice = open("XLY"); def xlfprice = open("XLF"); def xlcprice = open("XLC"); def xliprice = open("XLI"); def xlpprice = open("XLP"); def xleprice = open("XLE"); def xlreprice = open("XLRE"); def xlbprice = open("XLB"); def xluprice = open("XLU"); def xlkChangePercent = (xlk - xlkprice) / xlkprice; def xlvChangePercent = (xlv - xlvprice) / xlvprice; def xlyChangePercent = (xly - xlyprice) / xlyprice; def xlfChangePercent = (xlf - xlfprice) / xlfprice; def xlcChangePercent = (xlc - xlcprice) / xlcprice; def xliChangePercent = (xli - xliprice) / xliprice; def xlpChangePercent = (xlp - xlpprice) / xlpprice; def xleChangePercent = (xle - xleprice) / xleprice; def xlreChangePercent = (xlre - xlreprice) / xlreprice; def xlbChangePercent = (xlb - xlbprice) / xlbprice; def xluChangePercent = (xlu - xluprice) / xluprice; def xlkSizing = xlkChangePercent * xlkWeight; def xlvSizing = xlvChangePercent * xlvWeight; def xlySizing = xlyChangePercent * xlyWeight; def xlfSizing = xlfChangePercent * xlfWeight; def xlcSizing = xlcChangePercent * xlcWeight; def xliSizing = xliChangePercent * xliWeight; def xlpSizing = xlpChangePercent * xlpWeight; def xleSizing = xleChangePercent * xleWeight; def xlreSizing = xlreChangePercent * xlreWeight; def xlbSizing = xlbChangePercent * xlbWeight; def xluSizing = xluChangePercent * xluWeight; def combinedSizing = 6000 * ( xlkSizing + xlvSizing + xlySizing + xlfSizing + xlcSizing + xliSizing + xlpSizing + xleSizing + xlreSizing + xlbSizing + xluSizing ) / SectorCount; def cumuCombinedSizing = if NewDay then combinedSizing else cumuCombinedSizing[1] + combinedSizing; # Display plot cumuSectorWeightAD = if !IsNaN(combinedSizing) then cumuCombinedSizing else Double.NaN; cumuSectorWeightAD.AssignValueColor(if cumuSectorWeightAD < cumuSectorWeightAD[1] then Color.YELLOW else Color.MAGENTA); cumuSectorWeightAD.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); plot zeroLine = 0; zeroLine.AssignValueColor(Color.WHITE); zeroLine.HideBubble(); zeroLine.HideTitle(); def spx = close("SPX"); def spxprice = open("SPX"); def spxChangePercent = (spx - spxprice) / spxprice; def spxSizing = spxChangePercent * 100 / SectorCount; def spxcombinedSizing = spxSizing * 6000; def cumuSPX = if NewDay then spxcombinedSizing else cumuSPX[1] + spxcombinedSizing; plot cumuSPXAD = if spxChangePercent != 0 then cumuSPX else Double.NaN ; cumuSPXAD.AssignValueColor(Color.white); cumuSPXAD.SetPaintingStrategy(PaintingStrategy.LINE);
There are no references to the advance/decline of individual sectors, or to anything else like $ADD, $ADSPD, or to any other advance/decline data, weighted or otherwise, whatsoever, at any point within the actual code of this indicator.
I've been trying to follow along and I'm a little confused.
I agree w/ your comments about how comparing to SPX doesn't make sense.... but I'm not sure that's what their indicator does.
Are you assuming they are using SPX? Or are you looking at their actual script? (I can't tell if you are talking about the ones posted in this thread or their actual version).
And if you are looking at their actual script, are you saying they use SPX as the "unweighted" line instead of $ADSPD (scaled) or a cumulative total of sector % changes - all being treated equally - added together?
FWIW - the difference in bar colors is just to indicate if it moved up or down versus the previous bar (purple up, yellow down) - it does not tell you anything about specific sectors. Just how the weighted sectors are doing versus unweighted (the line). So each bar - no matter the color - represents all the sectors as weighted by SPX. Colors are just to discern direction/ movement.I Change the color to Light Red and Light Green, I agree it really is just a visual of the Sector status above.
it needs a better display to let you know what sector is really driving the move
Oh... I like your thought on different colors for each sectors delta change. Even if it used the main color for the sector that changed the most. That would beI guess we could adjust the colors to change according to which sector has the most delta change but it will look like a rainbow and
hard to follow. Even if you knew what sector was up or down the most, how could this help you decide if your stock choice is the right one for today's or tomorrow's play?
Should be:def O = if isFirstBar then close(Sym) else O[1];
def O = if isFirstBar then Open(Sym) else O[1];
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;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
VWOP: Volume Weighted & Oscillated Price for ThinkOrSwim | Indicators | 13 | ||
Time Weighted Average Price (TWAP) Indicator for ThinkorSwim | Indicators | 36 | ||
V | Volume Weighted Moving Average (VWMA) for ThinkorSwim | Indicators | 18 | |
Advance/Decline Line Indicator for ThinkorSwim | Indicators | 37 |
Start a new thread and receive assistance from our community.
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.
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.