NASDAQ NORMALIZED NEW HIGHS & NEW LOWS For ThinkOrSwim

Cybersloth

Member
Really appreciate the willingness of others to share their Thinkscript codes here. Accordingly, what follows is a Thinkscript indicator which tallies the new highs and new lows for the NASDAQ in a normalized format. The indicator is from Bryan Johnson's book, "Before the Bear Strikes", in which the code was shared in Metastock format. Here, it is translated to Thinkscript. The author normalized the highs and lows to accommodate the changing number of issues. and suggested Normalized New Lows > 40 is a bearish indication. I haven't found that particular value to be especially useful, although monitoring market breadth is unquestionably important. Hope you find the Thinkscript helpful in some manner.

sH9lECU.png



Thinkscript Code:

Code:
input time_frame = AggregationPeriod.DAY;

#COND1
input cond1_newhighs = "$NAHGH";
input cond1_newlows = "$NALOW";
input cond1_ema_length = 260;

def cond1_source_newhighs = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newhighs, period = time_frame);
def cond1_source_newlows = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newlows, period = time_frame);

#COND2
input cond2_advances = "$ADVN/Q";
input cond2_declines = "$DECN/Q";
input cond2_ema_length = 260;

def cond2_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_advances, period = time_frame);
def cond2_source_declines = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_declines, period = time_frame);
def cond2_advance_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_advances, cond2_ema_length);
def cond2_decline_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_declines, cond2_ema_length);

#COND3
input cond3_unchanged = "$UNCN/Q";
input cond3_ema_length = 260;
input cond3_multiplier = 3000;

def cond3_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond3_unchanged, period = time_frame);
def cond3_ema = movingaverage(averageType.EXPONENTIAL, cond3_source_advances, cond3_ema_length);

plot normalized_newhighs = round(cond1_source_newhighs / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newhighs.definecolor("Default", color.green);
normalized_newhighs.assignvalueColor(normalized_newhighs.color("Default"));
addlabel(yes, "Normalized New Highs: " + normalized_newhighs, normalized_newhighs.color("Default"));

plot normalized_newlows = round(cond1_source_newlows / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newlows.definecolor("Default", color.red);
normalized_newlows.assignvalueColor(normalized_newlows.color("Default"));
addlabel(yes, "Normalized New Lows: " + normalized_newlows, normalized_newlows.color("Default"));
 
Last edited by a moderator:

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

Really appreciate the willingness of others to share their Thinkscript codes here. Accordingly, what follows is a Thinkscript indicator which tallies the new highs and new lows for the NASDAQ in a normalized format. The indicator is from Bryan Johnson's book, "Before the Bear Strikes", in which the code was shared in Metastock format. Here, it is translated to Thinkscript. The author normalized the highs and lows to accommodate the changing number of issues. and suggested Normalized New Lows > 40 is a bearish indication. I haven't found that particular value to be especially useful, although monitoring market breadth is unquestionably important. Hope you find the Thinkscript helpful in some manner.

sH9lECU.png



Thinkscript Code:

input time_frame = AggregationPeriod.DAY;

#COND1
input cond1_newhighs = "$NAHGH";
input cond1_newlows = "$NALOW";
input cond1_ema_length = 260;

def cond1_source_newhighs = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newhighs, period = time_frame);
def cond1_source_newlows = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newlows, period = time_frame);

#COND2
input cond2_advances = "$ADVN/Q";
input cond2_declines = "$DECN/Q";
input cond2_ema_length = 260;

def cond2_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_advances, period = time_frame);
def cond2_source_declines = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_declines, period = time_frame);
def cond2_advance_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_advances, cond2_ema_length);
def cond2_decline_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_declines, cond2_ema_length);

#COND3
input cond3_unchanged = "$UNCN/Q";
input cond3_ema_length = 260;
input cond3_multiplier = 3000;

def cond3_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond3_unchanged, period = time_frame);
def cond3_ema = movingaverage(averageType.EXPONENTIAL, cond3_source_advances, cond3_ema_length);

plot normalized_newhighs = round(cond1_source_newhighs / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newhighs.definecolor("Default", color.green);
normalized_newhighs.assignvalueColor(normalized_newhighs.color("Default"));
addlabel(yes, "Normalized New Highs: " + normalized_newhighs, normalized_newhighs.color("Default"));

plot normalized_newlows = round(cond1_source_newlows / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newlows.definecolor("Default", color.red);
normalized_newlows.assignvalueColor(normalized_newlows.color("Default"));
addlabel(yes, "Normalized New Lows: " + normalized_newlows, normalized_newlows.color("Default"));
thanks for sharing this! i am reading over the code you share here, but was wondering if you could tell us what the study is calculating or if you have a link to the book's description/calculation?
 
There isn't really a satisfactory explanation of the formulation in the book, although I think I understand what the author is attempting to accomplish. I'll explain the formulation's logic by drawing attention to 2 problems with identifying new highs and new lows, ipso facto, in an index: 1) The number of total issues is subject to change; 2) The changes in new highs and new lows are often erratic, increasing the likelihood of an interpretive error. The above formulation weights the divisor with the 3000 multiple to address the arbitrary change that an added and subtracted number of issues brings, and it attempts to isolate potentially more significant changes in the new highs and new lows by linking those with the broader directional movements of advancing and declining issues in the index.

I posted the indicator under the pretense someone might either follow the formula as is, because it does identify times of unrest in the market, or so others might take the general idea as a starting point for more useful breadth metrics.
 
Last edited:
it sounds interesting. i can understand why he would have wanted to solve the number of issues problem. also, having two charts on the page would make it more difficult to decipher than to have one representing both. also one could calculate the percentage change rather than a whole number.
 
Really appreciate the willingness of others to share their Thinkscript codes here. Accordingly, what follows is a Thinkscript indicator which tallies the new highs and new lows for the NASDAQ in a normalized format. The indicator is from Bryan Johnson's book, "Before the Bear Strikes", in which the code was shared in Metastock format. Here, it is translated to Thinkscript. The author normalized the highs and lows to accommodate the changing number of issues. and suggested Normalized New Lows > 40 is a bearish indication. I haven't found that particular value to be especially useful, although monitoring market breadth is unquestionably important. Hope you find the Thinkscript helpful in some manner.

View attachment 13947


Thinkscript Code:

input time_frame = AggregationPeriod.DAY;

#COND1
input cond1_newhighs = "$NAHGH";
input cond1_newlows = "$NALOW";
input cond1_ema_length = 260;

def cond1_source_newhighs = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newhighs, period = time_frame);
def cond1_source_newlows = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond1_newlows, period = time_frame);

#COND2
input cond2_advances = "$ADVN/Q";
input cond2_declines = "$DECN/Q";
input cond2_ema_length = 260;

def cond2_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_advances, period = time_frame);
def cond2_source_declines = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond2_declines, period = time_frame);
def cond2_advance_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_advances, cond2_ema_length);
def cond2_decline_ema = movingaverage(averageType.EXPONENTIAL, cond2_source_declines, cond2_ema_length);

#COND3
input cond3_unchanged = "$UNCN/Q";
input cond3_ema_length = 260;
input cond3_multiplier = 3000;

def cond3_source_advances = Fundamental(fundamentalType = FundamentalType.CLOSE, symbol = cond3_unchanged, period = time_frame);
def cond3_ema = movingaverage(averageType.EXPONENTIAL, cond3_source_advances, cond3_ema_length);

plot normalized_newhighs = round(cond1_source_newhighs / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newhighs.definecolor("Default", color.green);
normalized_newhighs.assignvalueColor(normalized_newhighs.color("Default"));
addlabel(yes, "Normalized New Highs: " + normalized_newhighs, normalized_newhighs.color("Default"));

plot normalized_newlows = round(cond1_source_newlows / (cond2_advance_ema + cond2_decline_ema + cond3_ema) * cond3_multiplier,2);
normalized_newlows.definecolor("Default", color.red);
normalized_newlows.assignvalueColor(normalized_newlows.color("Default"));
addlabel(yes, "Normalized New Lows: " + normalized_newlows, normalized_newlows.color("Default"));
Thanks for interesting code and idea. Your are right, New Highs And New lows can be quite noisy.

How would it look on a minute chart ? It apears on daily tf, right ? Watching on 1 min tf could be telling.

Further more, I have noticed that "all us new highs and lows" from weekly to yearly does not show up on this site. you may allready be familiar with this. There is the etf version, i understand. That is if I am not mistaken. Here it is: $ushi1w vs $uslow1 $advus $declus $unchus
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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