TradingView
MartinShkreIi
2021년 2월 25일 오전 1시 17분

Sectors 

S&P 500SP

설명

This script attempts to show the relative strength of the 11 sectors in the SPX, which can be accomplished in three ways:

1. Sectors - displays all sector indices as they appear normally

2. Sector Relativity - displays each sector divided by the sum of the other 10 sectors

3. Sector Alpha - displays the alpha of each sector as compared to the sum of the other 10 sectors


I have seen some other iterations of this script that compare each sector to the SPX as a whole, a couple problems with that:

1. SPX sector weightings are unequal and change quarterly, meaning you will get an inaccurate depiction of relative sector strength across time.

2. Even if using an equal-weight SPX, you would be comparing a sector to itself as all 11 sectors are included in the SPX, not just the complementary 10 you are looking to compare one sector to.


For more information on the sectors in the SPX or the calculation of Alpha, visit the links at the top of the script.


*Includes an option for repainting -- default value is true, meaning the script will repaint the current bar.
False = Not Repainting = Value for the current bar is not repainted, but all past values are offset by 1 bar.
True = Repainting = Value for the current bar is repainted, but all past values are correct and not offset by 1 bar.
In both cases, all of the historical values are correct, it is just a matter of whether you prefer the current bar to be realistically painted and the historical bars offset by 1, or the current bar to be repainted and the historical data to match their respective price bars.
As explained by TradingView,`f_security()` is for coders who want to offer their users a repainting/no-repainting version of the HTF data.
코멘트
prithvi1974
Hi can you please guide how to change to Indian market indices, this will be helpful
prakashartwani
its wonderful creation. can u pls let know how this script can be use for indian markets.
1. as it is the way u have coded.
or some changes must be done. help in getting the same for indian markets
jellygill
Hi Sir!! You have made and shared a wonderful script but when I tried to use this, the right hand side horizontal bars were not displaying on my chart not I see anything in the code which generates these horizontal label bars. Can you please shed some light on how to display these sectoral labels?
MartinShkreIi
@jellygill, Hello, thank you for the suggestion! You can add the labels in settings, go to Scales -> Indicator Name Label. I will see if I can update the code to add them as standard.
SenBa009
Thank you so much for sharing this script. I am unable to view the label descriptions for the sectors as you have them on your chart. Please let me know how to make them visible.
nilanjan62
hi, can you make this for NSE:NIFTY500 please, this is just brilliant code
qwerpoiu338
Great tool! Thanks!
rahulr892
Its a wonderful and really helpful script to me as it helps me avoid weak sectors to invest.
but I don't see any name label at the right. and like you mentioned previously I don't see any scales -> indicator name label under settings ?
so I for now I color match the bar and sectors from settings
thanks!
never mind. got it
prithvi1974
@rahulr892, hi were you able to change to Indian indices ? if so can you please guide than you
더보기