Market Internals Labels for ThinkorSwim

markos

Well-known member
VIP
Market Internals Labels for ThinkorSwim

Code:
# Put-Call SP500 Label
# Markos
# useThinkscript Request 7-2019
# https://tos.mx/zGXVIH

input SYMB = "$PCSP";
def Data = close(symbol = "$PCSP", period = AggregationPeriod.DAY);
addLabel(1, "SP500 PCRatio = " + Data, if Data < 0
then color.red
else color.green);
# End Code

5PRpfWvm.jpg


Here is a PE Ratio Label

Code:
# PE Ratio Label
# Dilbert
# 10.28.2017

def AE = if IsNaN(GetActualEarnings()) then 0 else GetActualEarnings();

plot EPS_TTM = Sum(AE, 292);

def pe = close / EPS_TTM;

AddLabel(yes, "P/E: " + pe, color.MAGENTA);

Here is A/D of SP500 Label

Code:
# AD Label
# Mobius
# Chat Room Request 04.26.2016

input SYMB = "$ADSPD";

def Data = close(symbol = "$ADSPD", period = AggregationPeriod.WEEK);
addLabel(1, "AD = " + Data, if Data < 0
then color.red
else color.green);
# End Code
 

Attachments

  • 5PRpfWvm.jpg
    5PRpfWvm.jpg
    6.7 KB · Views: 13
Last edited by a moderator:

markos

Well-known member
VIP
Take a look at this and the information I have above. Everything you need should be here.

Code:
# https://www.reddit.com/r/thewallstreet/comments/7wiyvf/a_beginners_guide_to_market_internals/
Advance/Decline Difference and Ratio - $ADDC (NYSE), $ADSPDC (S&P) or $ADQDC (NQ)

This internal shows you the total number of advancing vs declining stocks in the NYSE or Nasdaq Composite. If 1800 stocks are positive for the day and 500 are down, you'll get a reading of 1300. Since there are a limited number of stocks in the composites, this metric has a cap.

The $ADDC and the ratio of advancing ($ADVN) to declining ($DECN) issues give us market breadth. If the Nasdaq is up today, how many stocks are pushing it up? Is it a broad-based rally or is a green day the result of only a small portion of the market. Naturally, you will likely find choppier days closer to 0. Rallies and steep drops will begin to pull more and more stocks up/down as the day wears on. This is the most basic indicator here and forms the basis for the subject at hand.

A reading of +800 or so means stocks are advancing roughly 2 to 1, which can be a good signal. The inverse is true for bearish conditions, but anything too close to 0 is no signal at all.

Since these two have charts, it is useful to see how things change over time. Because we cannot get a chart of the a/d ratio it is more useful as a number. Thus, the following script:

Advance/Decline Ratio Thinkscript

Here's a little gift. I only later realized Thinkorswim's advance/decline is a study, but we can get a simple number output with this that fits on any chart as a green/red label for bullish/bearish conditions and use it for any of the major indexes. For the mathematically challenged, 1.3 basically means 30% more stocks are advancing today vs declining in that index, while a reading as low as 0.3 means only 30% of stocks are advancing. I used composites as they include the data from all exchanges. Rip off the C in the code for these symbols if you for some reason want only the main source (if so tell me why!).

REMOVE THE (#) SIGN IN FRONT OF THE LINE YOU WANT TO USE.

#Use this if you want to see the ratio as a study beneath your chart, then copy the others you need.

#declare lower;

#Switch any below def to plot to see the NYSE Composite advance decline ratio as a chart.    Def will give us the label

#def adratio = close("$ADVNC") / close("$DECNC");

#Addlabel(yes, adratio + " Adv/Dec", if adratio >= 1 then color.green else color.red);

#Uncomment the below to show Nasdaq Composite Advance Decline

#def adrationasdaq = close("$ADVNC/Q") / close("$DECNC/Q");

#Addlabel(yes, adrationasdaq + " Adv/Dec NQ", if adrationasdaq >= 1 then color.green else color.red);

#Uncomment below to show S&P 500 Composite Advance Decline

#def adratiosp = close("$ADVSPC") / close("$DECLSPC");

#Addlabel(yes, adratiosp + " Adv/Dec S&P", if adratiosp >= 1 then color.green else color.red);

#All 3 can be used together if you like, and will show separate labels. You can also find the advance decline info for the Russell and Dow, just swap the symbols in or copy one of the script blocks.

As for using this, I want to know how broad a rally is. Is this thing really going to break out, or am I about to get whipsawed by a shitty market that's almost 50/50? It's no good on its own but in combination with the next one can be a pretty damned big clue as to whether we will have a trending day.

Volume Difference and Totals - $VOLDC $VOLSPDC and $VOLNDDC

These two show the total difference in volume going into stocks advancing vs those declining. Unlike the Advance Declinne Ratio it is immensely useful to view as a chart itself because on a really bloody day, or a strong rally, the numbers will grow relatively from one day to another. It is useful to know what type of volume has been seen in the market recently.

$UVOL and $DVOL show the amounts separately - throw a /Q or SP on the end to get this for the nasdaq or S&P by themselves. It is important to note that these are a cumulative total, but it can go down. This is because a stock in the down volume category can move to the up volume category when it goes green for the day. Its cumulative volume is subtracted from the dvol category and added to the uvol category as a result of its improved status.

You choose which of these is right for you - either the pairing of UVOL and DVOL or the simple difference by itself. If you use the difference, you can plot a 0 line in your trading software to easily see when it is positive vs negative. Numbers can range into the billions here so it's useful to do this. Here's how in thinkorswim. Make a simple study and name it zeroline and you can use it in anything like this:

plot zeroline = 0;

Good Luck and Good Trading
 
Last edited by a moderator:

bobomatic

Member
here are labels for VOLUME RATIOS and A/D on the NYSE, NASDAQ, and SP I hobbled together from a few sources

knzpbG6.jpg


Code:
input market = {default NYSE, NASDAQ, SP};

def UVOL = close("$UVOL");
def DVOL = close("$DVOL");
def UVOLQ = close("$UVOL/Q");
def DVOLQ = close("$DVOL/Q");
def UVOLSP = close("$UVOLSP");
def DVOLSP = close("$DVOLSP");
def Data = close("$ADSPD");

#NYSE Breadth ratio
def NYSEratio =  if (UVOL >= DVOL) then (UVOL / DVOL) else -(DVOL / UVOL);
AddLabel(yes, Concat(Round(NYSEratio, 2), " :1 NYSE VOL"), (if NYSEratio >= 0 then Color.GREEN else Color.RED));

#Nasdaq Breadth ratio
def NASDratio =  if (UVOLQ >= DVOLQ) then (UVOLQ / DVOLQ) else -(DVOLQ / UVOLQ) ;
AddLabel(yes, Concat(Round(NASDratio, 2), " :1 NASD VOL"), (if NASDratio >= 0 then Color.GREEN else Color.RED));

#SP Breadth ratio
def SPratio =  if (UVOLSP >= DVOLSP) then (UVOLSP / DVOLSP) else -(DVOLSP / UVOLSP) ;
AddLabel(yes, Concat(Round(SPratio, 2), " :1 SP VOL"), (if SPratio >= 0 then Color.GREEN else Color.RED));

# AD Numbers
input SYMB = "$ADD";#Hint SYMB:$ADD for NYSE Adv-Decline Issues
input SYMB2 = "$ADQD";#Hint SYMB2:$ADQD for Nasdaq Adv-Decline Issues
def AD = close(symbol = SYMB);
AddLabel(1, "A/D NYSE: " +  AD, (if AD >= 0 then Color.GREEN else Color.RED));
def AD2 = close(symbol = SYMB2);
AddLabel(1, "A/D NASDAQ: " +  AD2, (if AD2 >= 0 then Color.GREEN else Color.RED));
AddLabel(1, "A/D SP: " + Data, if Data < 0 then color.RED else color.GREEN);
 
Last edited by a moderator:

markos

Well-known member
VIP
@bobomatic thanks for the post. Please do all a favor and keep the original author and date at the top of any posting. If you've made changes, that's great. Put your name and date below if you are not the original poster. It's quite ok to make changes to others scripts, just be sure to give them credit. Thanks & welcome.
 

markos

Well-known member
VIP
Haven't been around much lately. I'll be scarce for an extended period but will check in as I can. I meant to add the image below a while back but I just came across it. Please note that there is a share at the top of the picture. This is courtesy of BOC, who hangs out in several chat rooms at TOS.... btw, if you don't know what something is, try it and see what it does... I put a call in to TOS Omaha Operations and they couldn't help. There are over 200 TOS Index Indicators here, it is believed that they originated with "shadowtrader", whom ever that may be...

List of Market Internal Tickers

LBm3nWb.png
 

markos

Well-known member
VIP
Another symbol I'm using, for quite some time already, is $SPXA200R. I find it really helpful to determine the direction of the market
@Art ! You're a genius! Advanced support told me there was no way to do it. Thank you.
 
Last edited:

Rojo Grande

Active member
VIP
I am asking for some help. I am trying to add a label for price net change by symbol. Is it doable? Thank you. Please disregard, I have found the code.

I have been trying to figure out a chart label to show the net price change for $DJI. I managed to get a label to show the current price, but since I'm not a code writer, I have been unsuccessful piecing together one for net change. Below is the study for price I pieced together. Could someone point me in the right direction? Thank you.

Code:
input TICKER_1 = "$DJI";
input PRICE_TYPE = close;

def PRICE_1 = Close(ticker_1);

AddLabel(yes, "Price: " + Price_1, Color.LIGHT_GRAY);
 
Last edited:

Pensar

Well-known member
VIP
Lifetime
@Rojo Grande, here's a label I found somewhere, can't remember where. I modified it to also show the net change of a chosen symbol. When checking it against /ES and $DJI, it appeared to work fine - run/test it and let me know if it works. :)

Code:
#DailyandNetChangeLabels
#Original author unknown
#Pensar - 06/17/2020 - Added net change label, user inputs for symbol and label selection

input symbol = "$DJI";
input Chg_From_Open_Label = yes;
input Net_Chg_Label = yes;

def begin = open(symbol, AggregationPeriod.DAY);
def end = close(symbol, AggregationPeriod.DAY);
def DayChg = end - begin;
def PctDayChg = (end / begin) - 1;

def c = close(symbol, AggregationPeriod.DAY);
def NetChg = c - c[1];
def PctNetChg = (c / c[1]) - 1;

AddLabel(Chg_From_Open_Label, "Chg from Open: " + (DayChg) + " points, " + AsPercent(PctDayChg), if DayChg > 0 then Color.GREEN else if DayChg < 0 then color.RED else color.LIGHT_GRAY);

AddLabel(Net_Chg_Label, "Net Chg: " + (NetChg) + " points, " + AsPercent(PctNetChg), if NetChg > 0 then Color.GREEN else if NetChg < 0 then color.RED else color.LIGHT_GRAY);

#end code
 

Nahmed45

New member
Hello,

Looking for some help with a basic script. I would like to have the major indexing current pricing on my charts. I have looked for examples but havent been able to get it to work.

Any examples available to help me get started.
 

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
159 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.
Top