Market Internals Labels for ThinkorSwim

drakoniano

New member
From left to the right:

NQ CHART
1) VOLUME: Color comes from previous volume bar comparison, GREEN if there're more buyers than sellers and the volume increases in relation with the previous volume bar and RED if there're more sellers than buyers with volume increasing in relation with previous volume bar
2) PROFILE: volume in the profile, meaning if there is more volume in the in the top half of the distribution yields a “p” shape, which favors higher prices. More volume in the bottom half of the distribution forms a “b” shape, which favors lower prices. (skewness). So Profile color comes from the correlation between profile shape (p,b or D) and VWAP slope (bias). GREEN if profile 'p' and VWAP rising, and RED if profile 'b' and VWAP falling. Also GRAY with balanced 'D' profile and VWAP neutral.
3) Trend: means that the price is below or above the vwap. Trend color comes from VWAP slope, GREEN rising and RED falling.
4) ALERT: it is green or red meaning there is a correlation between ES and ADSPD (in my case NQ y and ADNDD). Up correlation green , down correlation RED.

INTERNALS of NASDAQ
5) VOL: label of ($VOLNDD/$TVOLND). Green positive and RED negative, meaning more volume for the up and down in the stocks respectively.

IM READY WITH THIS
6) A-D: label of ($ADNDD/100). Green positive meaning that is advancing and red negative data meaning that is declining
7) TICK: label of ($TIKND/100). Green positive RED negative like the symbol in TOS. IM READY WITH THIS
8) ALERT: when all the previous internals are green or red, show you an alert.

The image is in the following link

profile.png


Thanks for your time man, I really appreciate
 

markos

Well-known member
VIP
Here is a label, you will have to change it to what you are looking for.

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.png


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
 

drakoniano

New member
Hi Thanks for your answer, is not auto trade is just the internal to indicate the possibility of a big pullback to reverse that permit me to close my position. You know what i mean?
 

markos

Well-known member
VIP
@drakoniano 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
 

bobomatic

New member
@drakoniano 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);
 

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

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
@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
 

BbenSD

New member
VIP
Hello everyone, so I've been using this Mobius script which is essentially market internals. It's pretty decent but I was wondering if anyone could help me do 1 thing pertaining to the script.

1. Make it usable on a tick chart

Here's the code, and thank you very much.

Code:
# Study Name: Quad_Momentum_Intraday

# Mobius

# V01.01.2012 Revised 03.12.2017

#hint: <b>This Study is for intraday trading only. The study uses Consolidated TICK, Advance Decline, Volume Breadth and Price for Trend Momentum. When all 4 agree the study plots a directional marker and colors the candles blue for ascending or yellow for descending price. The markers and candle color can be turned on and off with user inputs. The "n" input is for momentum length calculations.\n Trading Note: Look for the candle color or trend marker to "stop plotting" for indication trend may be slowing, possibly changing.\n Highest and best use is with a pivot study and a multiple contract Risk On / Risk off money management approach.



declare hide_on_daily;



input n = 8; #hint n: Length for Momentum calculations.

input CandleColor = yes;

input TrendMarkers = no;

input ShowData = yes;

input TickSymb = {default "$TIKSP", "$TICK", "$TICK/Q"};

input ADSymb = {default "$ADSPD", "$ADD", "$ADQD"};

input VolSymb = {default "$VOLSPD", "$VOLQD", "$VOLID"};



def tick = if IsNaN(close(TickSymb))

           then tick[1]

           else close(TickSymb);

def AD = if IsNaN(close(ADSymb))

         then AD[1]

         else close(ADSymb);

def Breadth = if IsNaN(close(VolSymb))

              then Breadth[1]

              else close(VolSymb);

def price = close;

def Hrs = Floor(9.5 + SecondsFromTime(0930) / 60 / 60) - 1;

def Min = ((9.5 + SecondsFromTime(930) / 60 / 60) % 1) * 60;

def active = if SecondsFromTime(0930) >= 0 and

                SecondsTillTime(1600) >= 0

             then  1

             else 0;

def lowestAD = if active and !active[1]

               then AD

               else if active and

                       AD < lowestAD[1]

                    then AD

                    else lowestAD[1];

def AD_low_Time_Hrs = if AD == lowestAD

                      then Hrs

                      else AD_low_Time_Hrs[1];

def AD_low_Time_min = if AD == lowestAD

                      then Min

                      else AD_low_Time_min[1];

def highestAD = if active and !active[1]

                then AD

                else if active and

                        AD > highestAD[1]

                     then AD

                     else highestAD[1];

def AD_high_Time_Hrs = if AD == highestAD

                       then Hrs

                       else AD_high_Time_Hrs[1];

def AD_high_Time_min = if AD == highestAD

                       then Min

                       else AD_high_Time_min[1];

def sumAD = if active and !active[1]

            then AD

            else if active

                 then sumAD[1] + AD

                 else sumAD[1];

def barLength = if active and !active[1]

                then 1

                else if active

                     then barLength[1] + 1

                     else barLength[1];

def MA_AD = sumAD / barLength;

def CumTick = fold i = 0 to active

              with p

              while active

              do CumTick[1] + tick;

def CumTickMomo = (CumTick - Lowest(CumTick, n)) /

                  (Highest(CumTick, n) - Lowest(CumTick, n));

def ADMomo = (AD - Lowest(AD, n)) /

             (Highest(AD, n) - Lowest(AD, n));

def BreadthMomo = (Breadth - Lowest(Breadth, n)) /

                  (Highest(Breadth, n) - Lowest(Breadth, n));

def PriceMomo = (price - Lowest(price, n)) /

                (Highest(price, n) - Lowest(price, n));

plot QuadTrendUp = if CumTickMomo > .5 and

                      ADMomo > .5 and

                      BreadthMomo > .5 and

                      PriceMomo > .5

                   then low - TickSize()

                   else Double.NaN;

QuadTrendUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);

QuadTrendUp.SetLineWeight(1);

QuadTrendUp.SetDefaultColor(Color.GREEN);

QuadTrendUp.SetHiding(!TrendMarkers);

plot QuadTrendDn = if CumTickMomo < .5 and

                      ADMomo < .5 and

                      BreadthMomo < .5 and

                      PriceMomo < .5

                   then high + TickSize()

                   else Double.NaN;

QuadTrendDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);

QuadTrendDn.SetLineWeight(1);

QuadTrendDn.SetDefaultColor(Color.RED);

QuadTrendDn.SetHiding(!TrendMarkers);

def Range = Highest(high, n) - Lowest(low, n);

AssignPriceColor(if CandleColor and !IsNaN(QuadTrendUp)

                 then CreateColor(25,49,250)

                 else if CandleColor and !IsNaN(QuadTrendDn)

                      then Color.YELLOW

                      else Color.CURRENT);

AddLabel(ShowData, "Quad Data:  " +

          "  Tick = " + tick +

          "  || AD = " + AD +

          "  Highest AD = " + highestAD + "  At: " + AD_high_Time_Hrs + ":" + AD_high_Time_min +

          "  Lowest AD = " + lowestAD + "  At: " + AD_low_Time_Hrs + ":" + AD_low_Time_min +

          "  Avg AD = " + Round(MA_AD, 0) +

          "  || Breadth = " + Round(Breadth / 1000000, 2) + "m" +

          "  || Range("+ n + ") = " + AsDollars(Round(Range / TickSize(), 0) * TickSize()),

             if !IsNaN(QuadTrendUp)

             then CreateColor(25,49,250)

             else if !IsNaN(QuadTrendDn)

                  then Color.YELLOW

                  else Color.WHITE);

# End Code Quad_Momentum_Intraday
 

J007RMC

Well-known member
2019 Donor
Is it possible for some to code the above label and have it change colors green/red?
 

trotromate

New member
Hey guys, I need a simple $TRIN label that shows bullish: less than 1, bearish: greater than 1 and neutral: 1.
Color added will be great as well. Thank you
 

Nahmed45

New member
VIP
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.
 

Similar threads

Top