1. Home
  2. ThinkorSwim Indicators
  3. New 52-Week Highs and Lows Indicator for ThinkorSwim

New 52-Week Highs and Lows Indicator for ThinkorSwim

The New 52-Week Highs and Lows indicator for ThinkorSwim measures the number of stocks hitting new highs or lows on a specified index.

It includes data from popular indices like the NYSE, Nasdaq, Amex, and Arca.

New Highs & Lows (NH-NL) may be used as a contrarian indicator to detect extreme sentiments among bullish and bearish investors.

New Highs – New Lows Indicator for ThinkorSwim

# Copyright 2022 Scott J. Johnson (https://scottjjohnson.com)
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#      http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.

# ExchangeListedNetHighLow
# Shows the number of new 52-week highs - new 52-week lows by day for the selected exchange. If the
# number of lows is greater than the number of highs, the value will be negative. If highs are
# greater, the number will be positive. Exchange = "ETF" shows net highs - lows for all ETFs listed
# on the 4 exchanges.
# The TOS symbols don't appear to work at expected when the aggregation period is WEEK so this
# study is only for daily charts.
declare lower;
input exchange = {default "NYSE", "NASDAQ", "AMEX", "ARCA", "ETF"};

def ap = AggregationPeriod.DAY;
def diff;
switch (exchange){
case "NYSE":
    diff = close(Symbol = "$NYHGH", period = ap) - close(Symbol = "$NYLOW", period = ap);
case "NASDAQ":
    diff = close(Symbol = "$NAHGH", period = ap) - close(Symbol = "$NALOW", period = ap);
case "AMEX":
    diff = close(Symbol = "$AMHGH", period = ap) - close(Symbol = "$AMLOW", period = ap);
case "ARCA":
    diff = close(Symbol = "$ARHGH", period = ap) - close(Symbol = "$ARLOW", period = ap);
case "ETF":
    diff = close(Symbol = "$ETFHIGH", period = ap) - close(Symbol = "$ETFLOW", period = ap);

plot hlp = if IsNaN(close) then Double.NaN else diff;
hlp.AssignValueColor(if hlp < 0 then Color.RED
                        else if hlp > 0 then Color.GREEN
                        else Color.CYAN);

plot zero = 0.0;

Market sentiment is frequently represented using the NYSE and Nasdaq indices.

By default, the indicator will show the number of new 52-week highs – new 52-week lows by day for the NYSE exchange.

You can go into the indicator settings and and select another exchange from the dropdown.

Chart Example

The example below shows the S&P 500 Index (upper chart) with the Net New Highs – New Lows indicator, which is based on data from the NYSE exchange (bottom chart).

How to Trade with New Highs and Lows Indicator

There are many ways to utilize the 52-Week New Highs – New Lows indicator.

It can be used to determine market dominance. A reading above 0 suggests bulls are in control. If the value falls below 0, bears are in control of the market. A negative reading means more stocks are reaching 52-week lows than highs.

It is possible to interpret the number of new highs and lows in equities as a contrarian signal.

For example, during a bear market, when the indicator reaches an extremely low level, it often indicates a major market bottom.

Lastly, you can use the indicator to find divergences. A negative (bearish) divergence occurs when the actual index continues to move higher while fewer stocks are making new highs.

Bonus: Index New High – New Low Indicator

# This indicator uses the Index New highs and Index New lows to help gauge overall Market sentiment. It's a leading indicator.
# Index New High - New Low Indicator
# Mobius
declare lower;
input Symb = {default "NYSE", "NASDQ", "AMEX", "ARCA", "ETF"};
input length = 10;
input OverSold = 20;
input OverBought = 80;
Input AvgType = AverageType.Hull;
def agg = AggregationPeriod.Day;
def NYSEH  = close(Symbol = "$NYHGH", period = agg);
def NYSEL  = close(Symbol = "$NYLOW", period = agg);
def NASDQH = close(Symbol = "$NAHGH", period = agg);
def NASDQL = close(Symbol = "$NALOW", period = agg);
def AMEXH  = close(Symbol = "$AMHGH", period = agg);
def AMEXL  = close(Symbol = "$AMLOW", period = agg);
def ARCAH  = close(Symbol = "$ARHGH", period = agg);
def ARCAL  = close(Symbol = "$ARLOW", period = agg);
def ETFH   = close(Symbol = "$ETFHGH", period = agg);
def ETFL   = close(Symbol = "$ETFLOW", period = agg);
def P;
Switch (Symb){
case "NYSE":
P = NYSEH / (NYSEH + NYSEL) * 100;
case "NASDQ":
P = NASDQH / (NASDQH + NASDQL) * 100; 
case "AMEX":
P = AMEXH / (AMEXH + AMEXL) * 100;
case "ARCA":
P = ARCAH / (ARCAH + ARCAL) * 100;
case "ETF":
P = ETFH / (ETFH + ETFL) * 100;
def price = if isNaN(P) then price[1] else P;
plot data = if isNaN(close) then double.nan else price;
plot avg = MovingAverage(AvgType, data, length);
avg.AssignValueColor(if between(avg, OverSold, OverBought)
                     then Color.yellow
                     else if avg >= OverBought
                          then Color.Green
                          else Color.Red);
plot OB = if isNaN(close) then double.nan else OverBought;
plot OS = if isNaN(close) then double.nan else OverSold;
plot neutral = if isNaN(close) then double.nan else 50;
addCloud(0, OS, CreateColor(250,0,0), CreateColor(250,0,0));
addCloud(OS, neutral, createColor(50,0,0), createColor(50,0,0));
addCloud(neutral, OB, createColor(0,50,0), createColor(0,50,0));
addCloud(OB, 100, CreateColor(0,250,0), createColor(0,250,0));
# End High - Low Index

Happy trading!

Unlock the Power of ThinkorSwim

Get the latest news and updates on TD Ameritrade, ThinkorSwim indicators, thinkScript tutorials, and trading strategies delivered straight to your inbox every week.

We don’t spam! Unsubscribe at anytime.

8 thoughts on “New 52-Week Highs and Lows Indicator for ThinkorSwim

  1. Is it possible to aggregate the exchanges? For example, view the indicator for all of NYSE, NASDAQ, and AMEX?

  2. Great blog post. It appears that recently TOS added more built-in symbols that make this even simpler:

  3. Hi Melvin:

    I’m not using this indicator in the traditional way. I’m wondering if its possible to scan for green bars? I know there would be a million and three hits, but I would use in conjunction with other scan parameters to find certain things. Please let me know. thank you!

  4. Hello came across your script for 52 week high/low i’ve been looking for a script for TOS a cumulative 4 week high/low. some traders that have TC2000 use T2123 seems to show market direction very well mostly when paired down to 15 min and 60 min time frame for swing trading. thanks for any help

Leave a Reply

Your email address will not be published. Required fields are marked *