Sector Lookup Label?

JMW

New member
VIP
I'm not even sure if this is possible, but I thought I'd ask...

Is anyone aware of a script to lookup the SPDR sector a symbol is a part of, if applicable? Right now, I have various labels for the primary sectors I swing trade in (Tech / XLK, Energy / XLE, etc.) and they show on each symbol. Looking at an AAPL chart will show all sectors. It would be pretty cool if there was a way to lookup the sector, and display that value - using our AAPL example, the label would return XLK and I would then apply my basic "green/red" value to display if the sector is positive or negative.

Obviously if the symbol isn't included, we can just return an N/A or something.

wIS8B4b.png
 

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

@Pensar Thanks, I figured.. Was trying to write items out to strings and compare against an array, and couldn't get that to work. Oh well, need to just remember where items sit, I suppose.
 
I guess you could hard code each symbol in each sector and then display the appropriate sector label when you choose a stock - probably not worth the effort though. Would take a long time to code as well, and need to be updated if stocks get removed or added from any sector.
 
If you could get a list of all the symbols in text format with a standard delineation, it wouldn't be that hard to write a small program which would automatically generate the brute force code for ThinkScript. My only concern would be the size of the completed ThinkScript, or how it might slow down the platform when switching between charts, etc. Perhaps using Case rather than If/Then/Else might help, but it would require some experimentation.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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