Symbol Sector Comparison to Current Chart

stockmonkey

New member
Hi Everyone!

I have a small watchlist consisting about 20 symbols. I'm looking for a way to have a study that will add the underlying sector ETF as a comparison to the currently selected ticker. For example:

My watchlist:
ACGLNARCH CAPITAL GROUP DEP SHS REP 1/1000TH PFD *CLBLFinancials
ABRARBOR REALTY TRUST INC COM USD0.01Financials
ABCMABCAM PLC ADR SPONSOREDHealth Care
AATAMERICAN ASSETS TRUST INC COM USD0.01Real Estate
ABALLIANCEBERNSTEIN HOLDING LP SBIFinancials
ABNBAIRBNB INC COM CL AConsumer Discretionary
ACAARCOSA INC COMIndustrials
AAPLAPPLE INC COMInformation Technology

When I have Apple as my current chart is there a way that the study can check the listed symbols from the above list (already coded as a part of this study) and find the corresponding sector of the current chart symbol (Information Technology for the Apple example) and add the corresponding ETF from the below listed as a comparison overlaying chart:

Cyclicals = "XLY";
Technology = "XLK";
Industrials = "XLI";
Materials = "XLB";
Energy = "XLE";
Staples = "XLP";
HealthCare = "XLV";
Utilities = "XLU";
Financials = "XLF";

Hope I was clear in my expression and thanks so much for any help in advance.
 
Solution
Hi Everyone!

I have a small watchlist consisting about 20 symbols. I'm looking for a way to have a study that will add the underlying sector ETF as a comparison to the currently selected ticker. For example:

My watchlist:
ACGLNARCH CAPITAL GROUP DEP SHS REP 1/1000TH PFD *CLBLFinancials
ABRARBOR REALTY TRUST INC COM USD0.01Financials
ABCMABCAM PLC ADR SPONSOREDHealth Care
AATAMERICAN ASSETS TRUST INC COM USD0.01Real Estate
ABALLIANCEBERNSTEIN HOLDING LP SBIFinancials
ABNBAIRBNB INC COM CL AConsumer Discretionary
...
Stockmonkey, could you please share what information that you are looking for from the secondary symbol. For example, do you want to be able to see what the MACD of XLK is doing while you are on a chart of AAPL? Thus, is there a particular indicator that you want to be able to see of a secondary symbol, or are you looking for something else?
 

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

Hi Everyone!

I have a small watchlist consisting about 20 symbols. I'm looking for a way to have a study that will add the underlying sector ETF as a comparison to the currently selected ticker. For example:

My watchlist:
ACGLNARCH CAPITAL GROUP DEP SHS REP 1/1000TH PFD *CLBLFinancials
ABRARBOR REALTY TRUST INC COM USD0.01Financials
ABCMABCAM PLC ADR SPONSOREDHealth Care
AATAMERICAN ASSETS TRUST INC COM USD0.01Real Estate
ABALLIANCEBERNSTEIN HOLDING LP SBIFinancials
ABNBAIRBNB INC COM CL AConsumer Discretionary
ACAARCOSA INC COMIndustrials
AAPLAPPLE INC COMInformation Technology

When I have Apple as my current chart is there a way that the study can check the listed symbols from the above list (already coded as a part of this study) and find the corresponding sector of the current chart symbol (Information Technology for the Apple example) and add the corresponding ETF from the below listed as a comparison overlaying chart:

Cyclicals = "XLY";
Technology = "XLK";
Industrials = "XLI";
Materials = "XLB";
Energy = "XLE";
Staples = "XLP";
HealthCare = "XLV";
Utilities = "XLU";
Financials = "XLF";

Hope I was clear in my expression and thanks so much for any help in advance.

this should work , to get you started
Code:
def na = double.nan;
def z;
if GetSymbol() == "AAPL" then {
z= close("XLK")

# copy these 2 lines and replace symbols as needed
} else if GetSymbol() == "ACA" then {
z= close("XLI")

} else {
z = 0;
};

plot z2 = if z>0 then z else na;
 
Solution
Stockmonkey, could you please share what information that you are looking for from the secondary symbol. For example, do you want to be able to see what the MACD of XLK is doing while you are on a chart of AAPL? Thus, is there a particular indicator that you want to be able to see of a secondary symbol, or are you looking for something else?
Hi JamesB!
Thanks for the reply. I’m looking for what XLK is doing while I am on a chart of AAPL. XLK As an overlay (or compare with study) on the AAPL chart. Similar to that when I am on another symbol like ABCM which is a healthcare sector I’m looking for XLV as the overlay(comparison study) on the ABCM chart. I hope I was able to explain better this time.
 
Hi JamesB!
Thanks for the reply. I’m looking for what XLK is doing while I am on a chart of AAPL. XLK As an overlay (or compare with study) on the AAPL chart. Similar to that when I am on another symbol like ABCM which is a healthcare sector I’m looking for XLV as the overlay(comparison study) on the ABCM chart. I hope I was able to explain better this time.
#This will chart a symbol in the subgraph if that is what you are after.

# thanks to @mashume for the method
declare lower;
input symbol = "XLK";

def nan = double.nan;
def o = open(symbol = symbol);
def c = close(symbol = symbol);
def h = high(symbol = symbol);
def l = low(symbol = symbol);

AddChart(high = if c > o then h else nan,
low = if c > o then l else nan,
close = if c > o then c else nan,
open = if c > o then o else nan,
ChartType.CANDLE, Color.GREEN);
AddChart(high = if c < o then h else nan,
low = if c < o then l else nan,
open = if c < o then o else nan,
close = if c < o then c else nan,
ChartType.CANDLE, Color.RED);
AddChart(high = if c == o then h else nan,
low = if c == o then l else nan,
open = if c == o then o else nan,
close = if c == o then c else nan,
ChartType.CANDLE, Color.GRAY);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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