Stock Symbol Lookup

Stock Symbol Lookup Text Description for an Index, Sector, or Industry using thinkScript

Wealth Builders Club

Stock Symbol Lookup

The symbols used for most indices, industries, sectors, and equities are terse. Meaning that they are cryptic and don't fully describe what they represent. If you want a quick way to see a description of what is on your current chart, this thinkorswim thinkScript code will allow you to do so.

This example code will put meaningful text on the upper price chart automatically and simplify a stock symbol lookup for you. The description text will only appear on the chart if it is specifically included in the "getSymbolPart()" and "AddLabel" function lines of code:

def spx = getSymbolPart() == "SPX";
AddLabel(spx, " S&P 500 ", Color.BLACK);

How it Works

The above code first defines the variable "spx" if the current price chart is showing the "SPX" market symbol (the S&P 500). The second line places a text label value " S&P 500 " on the chart with a black background only if the "spx" variable is defined (which happens in the first line of code).

If the "spx" variable is not defined, the text label is not shown on the screen. One thing to note is the spaces in the quotes for the text label output. The spaced before and after the output text (" text ") makes sure that the black background extents one character on each side of the text. It is not required to do this for the code to work, I just simply prefer the look and feel of it this way.

You can use this to place text onto a price chart for any symbol available within your trading account using the thinkorswim trading platform. For example, here is the code for the information technology S&P sector:

def info_tech = getSymbolPart() == "$SP500#45";
AddLabel(info_tech, " Information Technology Sector ", Color.BLACK);

Here is another example using the S&P communications equipment industry:

def communications_eq_sub = getSymbolPart() == "$SP500#45201020";
AddLabel(communications_eq_sub, " Communications Equipment Industry ", Color.BLACK);

In summary, to show a better definition (that you define) of what you are looking at on your price chart, you can create these text definitions in a thinkScript study, and add the study to your chart grid to see them.

I hope you find this stock symbol lookup and text display example code useful, and I wish you the best in your trading.

Get the Code Here

Screenshot

Stock Symbol Lookup Example Screen

thinkScript Code

# THINKSCRIPT - DUANE MURRAY, 2021
# DETERMINE WHICH SYMBOL IS BEING VIEWED

# SHOW DESCRIPTION TEXT FOR CURRENT SYMBOL

AddLabel(1, "", Color.WHITE); # ALWAYS SHOW A DEFAULT

# INDICES
# IF THE MARKET SYMBOL INCLUDES THE TERM, CREATE TEXT LABEL
def spx = getSymbolPart() == "SPX";
AddLabel(spx, " S&P 500 ", Color.BLACK);
def ndx = getSymbolPart() == "$COMP";
AddLabel(ndx, " NASDAQ ", Color.BLACK);
def rut = getSymbolPart() == "RUT";
AddLabel(rut, " Russel 2000 ", Color.BLACK);
def dow = getSymbolPart() == "$DJI";
AddLabel(dow, " Dow Jones ", Color.BLACK);
def nya = getSymbolPart() == "NYA";
AddLabel(nya, " NY Stock Exchange ", Color.BLACK);

# MORE SYMBOLS ARE INCLUDE IN THE DOWNLOADABLE VERSION - CLICK BELOW

Get the Code Here

Wealth Builders Club

Leave a Comment