ThinkOrSwim 52-week Highs/Lows Scanner and Watchlist Column

M

mo2020

New member
is there a ThinkOrSwim 52-DAY Highs/Lows Scanner and Watchlist Column
 
Last edited:
M

mo2020

New member
52-week high/low is the highest and lowest price at which a stock has traded during the previous year. It is a technical indicator used by some traders and investors who view the 52-week high or low as an important factor in determining a stock's current value and predicting future price movement
 
markos

markos

Well-known member
VIP
Try this chart out...
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 2015
 
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
 
markos

markos

Well-known member
VIP
Those are built in columns already in both the scanner and the watchlist.
 
J

Jeff1228

New member
Hi, this is great, can you do a scanner, like scanning stocks at 52 weeks low or 10% above. Also, could you please set a different color in the watchlist column to give a warning message?

Thank you

P.S. Did I miss something? I didn't find it in scanner

PP.S. Sorry for the mess, just found it, it's great! But could you please set it a different color in the scanner and watchlist column if it's oversold or overbought? Thanks
 
Last edited:
J

Jeff1228

New member
Or simply put a percentage there, like, let's say 52 week high is 100, low is 50, now stock is at 60, so (60-50)/(100-50) = 10%, and set it red, how about this?

Thanks
 
T

TonyValenti

New member
Is there a way to do a high/low on a custom date range? For example, Jan1,2020-March31,2020?
 
N

Nikola

New member
I was wondering if it was possible to make a chart label that will show on my charts and tell me the ATH or 52wk high
 
BenTen

BenTen

Administrative
Staff
VIP
@Nikola See this one:

This code creates a custom column for your watchlist that turns green if today is a new 52-week high
Code:
# HINT: right-click on any watchlist column-->>Customize
# click and drag one of the custom choices to add it to your watchlist column choices
# click on ThinkScript tab and replace the code with this code
# BE SURE to give your new column a name and keep the name short enough it will appear on your watchlist at top of the column (ie new 52wk high)
# REMINDER - you can sort your watchlist by this column by clicking on the column header
 
#def allows you to teach ThinkScript new "words" that you can reference later in your code
def newHigh = high is equal to highest(HIGH (period = AggregationPeriod.DAY), 252);
def newLow = low is equal to lowest(LOW (period = AggregationPeriod.DAY), 252);
 
#AddLabel allows you to set conditions such as what words or values will appear when your condition is met.  Yes at the beginning means do show the label ... >=1 or ==1 means when the condition is True then ___ and <=0 or ==) would mean then the condition is False then _____
AddLabel(yes, if newHigh >= 1 then "new 52wk high TODAY" else if newLow >= 1 then "new 52wk low TODAY" else " ");
 
#on a watchlist column AssignBackgroundColor will change the column color when conditions are met.  But AssignBackgroundColor when used in a chart Study or Strategy will change entire chart background
AssignBackgroundColor (if newHigh >= 1 then color.GREEN else if NewLow >= 1 then color.RED else color.LIGHT_GRAY);
 
# end custom column code ------------------
 
N

Nikola

New member
i was looking more for a chart label so when im charting AH or weekends i can see what 52wk high is or ATH is
 
BenTen

BenTen

Administrative
Staff
VIP
@Nikola I remember seeing @markos using one. I'm going to tag him in here.
 
evanevans

evanevans

Member
i was looking more for a chart label so when im charting AH or weekends i can see what 52wk high is or ATH is
Did you try the code? It is supposed to put a LABEL up just as you described.
 

Similar threads

Top