Market Breath Labels for ThinkorSwim

J007RMC

Well-known member
2019 Donor
Used these labels today seemed to work fine.

Code:
# Market Breath Ratios
# Paris (based on an earlier idea from ESP)
# 11.02.2015
# One Note Download

def UVOL   = close(“$UVOL”);
def DVOL   = close(“$DVOL”);

def UVOLD  = close(“$UVOLI”);
def DVOLD  = close(“$DVOLI”);

def UVOLS  = close(“$UVOLSP”);
def DVOLS  = close(“$DVOLSP”);

def UVOLN  = close(“$UVOL/Q”);
def DVOLN  = close(“$DVOL/Q”);

def UVOLR  = close(“$UVOLRL”);
def DVOLR  = close(“$DVOLRL”);

def SPYRatio =  if (UVOLS >= DVOLS) then (UVOLS / DVOLS) else -(DVOLS / UVOLS);
AddLabel(yes, "S&P500: " + Concat(Round(SPYRatio, 2), ” :1”), if SPYRatio >= 0 then Color.UPTICK else Color.DOWNTICK);

def DJIRatio =  if (UVOLD >= DVOLD) then (UVOLD / DVOLD) else -(DVOLD / UVOLD);
AddLabel(yes, "DJI: " + Concat(Round(DJIRatio, 2), ” :1”), if DJIRatio >= 0 then Color.UPTICK else Color.DOWNTICK);

def NDXRatio =  if (UVOLN >= DVOLN) then (UVOLN / DVOLN) else -(DVOLN / UVOLN);
AddLabel(yes, "QQQ: " + Concat(Round(NDXRatio, 2), ” :1”), if NDXRatio >= 0 then Color.UPTICK else Color.DOWNTICK);

def RUTRatio =  if (UVOLR >= DVOLR) then (UVOLR / DVOLR) else -(DVOLR / UVOLR);
AddLabel(yes, "R2000: " + Concat(Round(RUTRatio, 2), ” :1”), if RUTRatio >= 0 then Color.UPTICK else Color.DOWNTICK);

def NYSERatio =  if (UVOL >= DVOL) then (UVOL / DVOL) else -(DVOL / UVOL);
AddLabel(yes, "NYSE: " + Concat(Round(NYSERatio, 2), ” :1”), if NYSERatio >= 0 then Color.UPTICK else Color.DOWNTICK);
 
Last edited by a moderator:
Well Im jusying I may not enter a trade if the advance decline levels are red so I look for the market index strength
 
@alexR Please be as specific as possible when reporting an issue. What is not working? Can you post a screenshot of the chart?
 
Hello! I've been helped by a couple badass code writers so far, and I'm hoping for another handout! I have these Market breadth bubbles( Don't remember where I got em from, but they were free, so public information, not proprietary) And I was hoping for a addendum. They work well to show general state of the markets, but Id like to have an arrow up or arrow down next to each reading that shows whether the reading has moved up/down since the last reading. for example, NYSE reading is negative right now, but went from -1.51 to -1.49. still negative, but moved up. or NASD is in the green positive, but went from +1.8 to +1.7. moved down. Is it possible to have a dynamic arrow that can show the direction of each last move as the day goes by? Thanks again to any and all who care to read this and give it a go!

#BREADTH RATIO SCRIPT
#CODED BY JUSTIN WILLIAMS

input ShowZeroLine = yes;
input market = {default NYSE, NASDAQ};

def UVOL = close(“$UVOL”);
def DVOL = close(“$DVOL”);
def UVOLQ = close(“$UVOL/Q”);
def DVOLQ = close(“$DVOL/Q”);

#NYSE Breadth ratio
def NYSEratio = if (UVOL >= DVOL) then (UVOL / DVOL) else -(DVOL / UVOL);
AddLabel(yes, Concat(Round(NYSEratio, 2), ” :1 NYSE”), (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”), (if NASDratio >= 0 then Color.GREEN else Color.RED));
 
Last edited by a moderator:
Hello! I've been helped by a couple badass code writers so far, and I'm hoping for another handout! I have these Market breadth bubbles( Don't remember where I got em from, but they were free, so public information, not proprietary) And I was hoping for a addendum. They work well to show general state of the markets, but Id like to have an arrow up or arrow down next to each reading that shows whether the reading has moved up/down since the last reading. for example, NYSE reading is negative right now, but went from -1.51 to -1.49. still negative, but moved up. or NASD is in the green positive, but went from +1.8 to +1.7. moved down. Is it possible to have a dynamic arrow that can show the direction of each last move as the day goes by? Thanks again to any and all who care to read this and give it a go!

MerryDay just graciously reminded me that I forgot to add the doggone script...foolish of me...

#BREADTH RATIO SCRIPT
#CODED BY JUSTIN WILLIAMS

input ShowZeroLine = yes;
input market = {default NYSE, NASDAQ};

def UVOL = close(“$UVOL”);
def DVOL = close(“$DVOL”);
def UVOLQ = close(“$UVOL/Q”);
def DVOLQ = close(“$DVOL/Q”);

#NYSE Breadth ratio
def NYSEratio = if (UVOL >= DVOL) then (UVOL / DVOL) else -(DVOL / UVOL);
AddLabel(yes, Concat(Round(NYSEratio, 2), ” :1 NYSE”), (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”), (if NASDratio >= 0 then Color.GREEN else Color.RED));

Here is my attempt at it! The label appears if the current value is either greater or lesser than the previous value. Otherwise, it does not show up.
#BREADTH RATIO SCRIPT
#CODED BY JUSTIN WILLIAMS

input ShowZeroLine = yes;
input market = {default NYSE, NASDAQ};

def UVOL = close(“$UVOL”);
def DVOL = close(“$DVOL”);
def UVOLQ = close(“$UVOL/Q”);
def DVOLQ = close(“$DVOL/Q”);

#NYSE Breadth ratio
def NYSEratio = if (UVOL >= DVOL) then (UVOL / DVOL) else -(DVOL / UVOL);
AddLabel(yes, Concat(Round(NYSEratio, 2), ” :1 NYSE”), (if NYSEratio >= 0 then Color.GREEN else Color.RED));
AddLabel(yes, if NYSEratio > NYSEratio[1] then "Up" else if NYSEratio < NYSEratio[1] then "Dn" else "", if NYSEratio > NYSEratio[1] then color.light_green else if NYSEratio < NYSEratio[1] then color.light_red else color.gray);

#Nasdaq Breadth ratio
def NASDratio = if (UVOLQ >= DVOLQ) then (UVOLQ / DVOLQ) else -(DVOLQ / UVOLQ) ;
AddLabel(yes, Concat(Round(NASDratio, 2), ” :1 NASD”), (if NASDratio >= 0 then Color.GREEN else Color.RED));
AddLabel(yes, if NASDratio > NASDratio[1] then "Up" else if NASDratio < NASDratio[1] then "Dn" else "", if NASDratio > NASDratio[1] then color.light_green else if NASDratio < NASDratio[1] then color.light_red else color.gray);
 
Wondering if anyone wants to have a go at it, but have this give an alert when ratio reaches a set number which is possibly adjustable? Would be nice to have for /ES to identify trend days early. Usually when ratio is > 3:1 or <-3:1. Thanks.
Hello! I've been helped by a couple badass code writers so far, and I'm hoping for another handout! I have these Market breadth bubbles( Don't remember where I got em from, but they were free, so public information, not proprietary) And I was hoping for a addendum. They work well to show general state of the markets, but Id like to have an arrow up or arrow down next to each reading that shows whether the reading has moved up/down since the last reading. for example, NYSE reading is negative right now, but went from -1.51 to -1.49. still negative, but moved up. or NASD is in the green positive, but went from +1.8 to +1.7. moved down. Is it possible to have a dynamic arrow that can show the direction of each last move as the day goes by? Thanks again to any and all who care to read this and give it a go!

#BREADTH RATIO SCRIPT
#CODED BY JUSTIN WILLIAMS

input ShowZeroLine = yes;
input market = {default NYSE, NASDAQ};

def UVOL = close(“$UVOL”);
def DVOL = close(“$DVOL”);
def UVOLQ = close(“$UVOL/Q”);
def DVOLQ = close(“$DVOL/Q”);

#NYSE Breadth ratio
def NYSEratio = if (UVOL >= DVOL) then (UVOL / DVOL) else -(DVOL / UVOL);
AddLabel(yes, Concat(Round(NYSEratio, 2), ” :1 NYSE”), (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”), (if NASDratio >= 0 then Color.GREEN else Color.RED));
 
SPX Market Breadth Indicator
This is my first attempt at thinkscript, and I also wanted to share back with the community. Please give me feedback if this is not the right way to share.

Indicator Image

This indicator shows the number of stocks that are above 50-day, 100-day, and 200-day moving averages. It is one of my favorite ways to get a sense of market health.

Code:
# Market Breath Indicator to Display $SPXA50R, $SPXA100R, and $SPXA200R
# Author: bulusufinances
# Version: 1


declare lower;

# The values come as 0.X format - multiplying by 100 to make the graph more readable

plot SPXA50R = close("$SPXA50R")*100;
plot SPXA100R = close("$SPXA100R")*100;
plot SPXA200R = close("$SPXA200R")*100;

# Set the plot colors and line styles
SPXA50R.SetDefaultColor(Color.GREEN);
SPXA100R.SetDefaultColor(Color.RED);
SPXA200R.SetDefaultColor(Color.BLUE);

# Optional: Set line styles
SPXA50R.SetStyle(Curve.FIRM);
SPXA100R.SetStyle(Curve.FIRM);
SPXA200R.SetStyle(Curve.FIRM);

# Optional: Add labels to the plots
AddLabel(yes, "$SPXA50R", Color.GREEN);
AddLabel(yes, "$SPXA100R", Color.RED);
AddLabel(yes, "$SPXA200R", Color.BLUE);

# Add horizontal lines
plot line30 = 30;
line30.SetDefaultColor(Color.RED);
line30.SetLineWeight(2);

plot line60 = 70;
line60.SetDefaultColor(Color.GREEN);
line60.SetLineWeight(2);
 
Last edited by a moderator:
Good morning,
I have search for something similar for the Semiconductor Sector SOX without success.
Hint: IXCO XCI NYA

Please help........

(y)
 
Last edited by a moderator:
Sorry for the delay. Traveling internationally.

@Alchicago1 - Can you please try again? It looks like there could be some delay in activating the tos.mx links. But they are working fine when I just tested it.
 

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