• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

New High vs. New Low Index Indicator for ThinkorSwim

markos

Well-known member
VIP
A leading indicator that compares stocks hitting new highs and new lows within the stock market. The Chart below is of the Market Meltdown in January, 2016. It's hard to be Bearish on the Market as a whole when new highs are breaking out!

jBKewag.png


Code:
#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 v2018-March from JQ's OneNote
#After loading, pull it to the upper chart!

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;
data.EnableApproximation();
data.SetDefaultColor(Color.Cyan);
plot avg = MovingAverage(AvgType, data, length);
avg.EnableApproximation();
avg.AssignValueColor(if between(avg, OverSold, OverBought)
                     then Color.yellow
                     else if avg >= OverBought
                          then Color.Green
                          else Color.Red);
avg.SetLineWeight(2);

plot OB = if isNaN(close) then double.nan else OverBought;
OB.SetDefaultColor(Color.Red);

plot OS = if isNaN(close) then double.nan else OverSold;
OS.SetDefaultColor(Color.Green);

plot neutral = if isNaN(close) then double.nan else 50;
neutral.SetdefaultColor(Color.Dark_Gray);

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

Shared link https://tos.mx/VhAvab
 
Last edited by a moderator:

joshua74133

Member
VIP
Is there a way to make a scanner that shows how many times a stock has made a new high on the day? Sure would be nice to look 30 min in and see a stock has made 20 new highs
 

gamgoum

New member
New High New Low Indicator

Code:
declare upper;

input length      = 252;

def highestHigh   = fold highIdx = 1 to length with sHigh = high do if sHigh > GetValue( high, highIdx, length + 1 ) then sHigh else GetValue( high, highIdx, length + 1 );
plot NewHigh      = if highestHigh > highestHigh[1] then high else Double.NaN;

def lowestLow     = fold lowIdx = 1 to length with sLow = low do if sLow < GetValue( low, lowIdx, length + 1 ) then sLow else GetValue( low, lowIdx, length + 1 );
plot NewLow       = if lowestLow < lowestLow[1] then low else Double.NaN;

#===============================[ Look & Feel ]================================
NewHigh.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN );
NewHigh.SetDefaultColor( Color.PLUM );
NewHigh.SetLineWeight( 3 );
NewLow.SetPaintingStrategy( PaintingStrategy.ARROW_UP );
NewLow.SetDefaultColor( Color.BLUE );
NewLow.SetLineWeight( 3 );
 

boogieG

New member
I was wondering if it was possible to pull Hi/Lo data for an indicator's value rather than price. I am wanting to scan for new highs on the built in relative strength indicator. Thank you
 

RNFL

New member
Is there a way to scan "Stock that made new highs in the last 3 months and with in a certain % of 3 month lows"?

Code by Mobius

Code:
if high == highest(high, 63) within 63 bars and
   low == lowest(low, 63) * .9
then 1
else double.nan


By RCG3:
input pct= .5
def condition= highest(high, 3) == highestall(high);
def condition2= lowest(low, 3) = lowestall(low) * (1+pct);
plot scan= condition and condition2;
 

Trading51

Active member
2019 Donor
A leading indicator that compares stocks hitting new highs and new lows within the stock market. The Chart below is of the Market Meltdown in January, 2016. It's hard to be Bearish on the Market as a whole when new highs are breaking out!

jBKewag.png


Code:
#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 v2018-March from JQ's OneNote
#After loading, pull it to the upper chart!

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;
data.EnableApproximation();
data.SetDefaultColor(Color.Cyan);
plot avg = MovingAverage(AvgType, data, length);
avg.EnableApproximation();
avg.AssignValueColor(if between(avg, OverSold, OverBought)
                     then Color.yellow
                     else if avg >= OverBought
                          then Color.Green
                          else Color.Red);
avg.SetLineWeight(2);

plot OB = if isNaN(close) then double.nan else OverBought;
OB.SetDefaultColor(Color.Red);

plot OS = if isNaN(close) then double.nan else OverSold;
OS.SetDefaultColor(Color.Green);

plot neutral = if isNaN(close) then double.nan else 50;
neutral.SetdefaultColor(Color.Dark_Gray);

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

Shared link https://tos.mx/VhAvab
Could I add Russell2000 if so what would be the Rut input ?
 

njsailor748

New member
VIP
Could I add Russell2000 if so what would be the Rut input ?
A leading indicator that compares stocks hitting new highs and new lows within the stock market. The Chart below is of the Market Meltdown in January, 2016. It's hard to be Bearish on the Market as a whole when new highs are breaking out!

jBKewag.png


Code:
#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 v2018-March from JQ's OneNote
#After loading, pull it to the upper chart!

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;
data.EnableApproximation();
data.SetDefaultColor(Color.Cyan);
plot avg = MovingAverage(AvgType, data, length);
avg.EnableApproximation();
avg.AssignValueColor(if between(avg, OverSold, OverBought)
                     then Color.yellow
                     else if avg >= OverBought
                          then Color.Green
                          else Color.Red);
avg.SetLineWeight(2);

plot OB = if isNaN(close) then double.nan else OverBought;
OB.SetDefaultColor(Color.Red);

plot OS = if isNaN(close) then double.nan else OverSold;
OS.SetDefaultColor(Color.Green);

plot neutral = if isNaN(close) then double.nan else 50;
neutral.SetdefaultColor(Color.Dark_Gray);

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

Shared link https://tos.mx/VhAvab
Thanks for the script.....I am a new member and would like to thank you for your contributions - I see a lot of your work on here while I am looking around.
 

trendr

Member
Could I add Russell2000 if so what would be the Rut input ?
Same question I have here. I love the indicator I have been using it for swing trades and to get a feel for market sentiment for the last couple months. Kept me out of this pull back using the Nasdaq as the input.
 

Similar threads

Top