Req: Daily Change By Weighted Sector

"Q" 2Be

New member
Since ToS has a predefined list have few symbols/ tickers are covering the 11 sectors of $SPX and introduced column for % change of current day as per the following snapshot.

My intention here is: make the user is able to fill the value of sector weighting and re-order them according from heaviest to lightest according to the quarterly update, then plot (% change of current day beside description) at the right upper corner of chart as boxes with the multiple Red, Green lightens to darkens.

1743144185595.png


mod note:
To follow along with this discussion
create the above table:
1. click on MarketWatch
2. click on Quotes
3. in the drop down table names, click on Public (S-W)
4. scroll down and click on S&P 500 Sector Indices
HfPnUkf.png


To add the % change of current day column:
1. click on the gear icon at the end of the column headings
2. click on customize
3. in the drop down box, type in: pct chg open
4. click on pct_Chg_Open
5. click on Add
6. click on OK
 
Last edited by a moderator:
Solution
Since ToS has a predefined list have few symbols/ tickers are covering the 11 sectors of $SPX and introduced column for % change of current day as per the following snapshot.

My intention here is: make the user is able to fill the value of sector weighting and re-order them according from heaviest to lightest according to the quarterly update, then plot (% change of current day beside description) at the right upper corner of chart as boxes with the multiple Red, Green lightens to darkens.


mod note:
To follow along with this discussion
create the above table:
1. click on MarketWatch
2. click on Quotes
3. in the drop down table names, click on Public (S-W)
4. scroll down and click on S&P 500 Sector Indices


To add...
Since ToS has a predefined list have few symbols/ tickers are covering the 11 sectors of $SPX and introduced column for % change of current day as per the following snapshot.

My intention here is: make the user is able to fill the value of sector weighting and re-order them according from heaviest to lightest according to the quarterly update, then plot (% change of current day beside description) at the right upper corner of chart as boxes with the multiple Red, Green lightens to darkens.


mod note:
To follow along with this discussion
create the above table:
1. click on MarketWatch
2. click on Quotes
3. in the drop down table names, click on Public (S-W)
4. scroll down and click on S&P 500 Sector Indices


To add the % change of current day column:
1. click on the gear icon at the end of the column headings
2. click on customize
3. in the drop down box, type in: pct chg open
4. click on pct_Chg_Open
5. click on Add
6. click on OK

not sure what you want? just a list of the weight numbers?

here is a chart study
this lets a user set weight numbers for 11 sectors.
if the current symbol matches 1 of the sectors, then the weight for that sector is displayed in a label.

use this as a column study , and disable the label that displays the symbol


Code:
#sector_wt_sort

#https://usethinkscript.com/threads/req-daily-change-by-weighted-sector.20793/
#Req: Daily Change By Weighted Sector
#"Q" 2Be  May 6, 2025

#Since ToS has a predefined list have few symbols/ tickers are covering the 11 sectors of $SPX and introduced column for % change of current day as per the following snapshot.

#My intention here is: make the user is able to fill the value of sector weighting and re-order them according from heaviest to lightest according to the quarterly update, then plot (% change of current day beside description) at the right upper corner of chart as boxes with the multiple Red, Green lightens to darkens.


# $SP500#10  ENERGY
# $SP500#15  MATERIALS
# $SP500#20  INDUSTRIALS
# $SP500#25  CONSUMER DISCRES
# $SP500#30  CONSUMER STAPLES
# $SP500#35  HEALTH CARE
# $SP500#40  FINANCIALS
# $SP500#45  INFORMATION TECH
# $SP500#50  COMM SERVICES
# $SP500#55  UTILITIES
# $SP500#60  REAL ESTATE


input ENERGY_wt_per = 3.2;
input MATERIALS_wt_per = 2.0;
input INDUSTRIALS_wt_per = 8.5;
input CONSUMER_DISCRES_wt_per = 10.3;
input CONSUMER_STAPLES_wt_per = 6.2;
input HEALTH_CARE_wt_per = 10.8;
input FINANCIALS_wt_per = 14.5;
input INFORMATION_TECH_wt_per = 30.3;
input COMM_SERVICES_wt_per = 9.3;
input UTILITIES_wt_per = 2.6;
input REAL_ESTATE_wt_per = 2.3;


def wt = if GetSymbol() == "$SP500#10" then ENERGY_wt_per
#  ENERGY
else if GetSymbol() == "$SP500#15" then MATERIALS_wt_per
#  MATERIALS
else if GetSymbol() == "$SP500#20" then INDUSTRIALS_wt_per 
#  INDUSTRIALS
else if GetSymbol() == "$SP500#25" then CONSUMER_DISCRES_wt_per
#  CONSUMER DISCRES
else if GetSymbol() == "$SP500#30" then CONSUMER_STAPLES_wt_per
#  CONSUMER STAPLES
else if GetSymbol() == "$SP500#35" then HEALTH_CARE_wt_per
#  HEALTH CARE
else if GetSymbol() == "$SP500#40" then FINANCIALS_wt_per 
#  FINANCIALS
else if GetSymbol() == "$SP500#45" then INFORMATION_TECH_wt_per
#  INFORMATION TECH
else if GetSymbol() == "$SP500#50" then COMM_SERVICES_wt_per 
#  COMM SERVICES
else if GetSymbol() == "$SP500#55" then UTILITIES_wt_per 
#  UTILITIES
else if GetSymbol() == "$SP500#60" then REAL_ESTATE_wt_per
#  REAL ESTATE
else 0;


addlabel(1,
getsymbol()
, color.yellow);

addlabel(1,
wt + "%"
, color.yellow);



#  ref
# XLK  Technology Select Sector SPDR Fund
# XLF  Financial Select Sector SPDR Fund
# XLV  Health Care Select Sector SPDR Fund
# XLY  Consumer Discretionary Select Sector SPDR Fund
# XLI  Industrial Select Sector SPDR Fund
# XLE  Energy Select Sector SPDR Fund
# XLP  Consumer Staples Select Sector SPDR Fund
# XLC  Communication Services Select Sector SPDR Fund
# XLU  Utilities Select Sector SPDR Fund
# XLB  Materials Select Sector SPDR Fund
# XLRE Real Estate Select Sector SPDR Fund
#https://usethinkscript.com/threads/s-p-500-sector-performance.1152/
#
 
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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