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

ThinkOrSwim 52-week Highs/Lows Scanner and Watchlist Column

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.

"Paris: Here's a watchlist you can use for percentage off 52 week high. For 52 week low, you can modify this."

Code:
# Percentage Off 52 Week High Watchlist
# Nick Name NAG®
# 11.02.2015

# This assumes a daily aggregation.  You will need to use
# daily or higher, adjust the 252 length as needed.

Round((close / Highest(high, 252) - 1) * 100)
 
Last edited:

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
2t1VzHB.png


Those are built in columns already in both the scanner and the watchlist.
 

Superfast

New member
I'd like to create a column on my watchlist that shows the % difference between the last price and the 52 week low. E.g. if the last price of BA is 355 and the 52 week low is 300, I'd like to have a column on my watchlist that shows the % difference between 355 and 300 i.e. 55/300 = 18.33%. Thanks.
 

Kimberly

New member
Hi everyone,

I am trying to figure out how to be alerted when a stock in my watch list hits a new 52 week high or low. I can't figure it out. Can anyone help?

Thanks.
 

tomsk

Well-known member
VIP
Here is a scan for stocks hitting 52-week high. Loading this into the scanner on a daily aggregation on the S&P 500, I get 16 results. There were no results for stocks hitting 52 weeks low on the S&P 500

Code:
High == Highest(High(period = "DAY"), 252)
 

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

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
 
Last edited:

stockalerts72

New member
Does anyone have a code for % off 52 week high for a watchlist, search or chart?

This one is for charts:

Code:
# Pct_off _52High_52Low_Chart
# Tos Chatroom, 101615
 
#Percentage Off 52 Week High
#Percentage Off 52 week Low
#ESP 09.08.2015
 
def C = Close;
def FiftyTwoWeekHigh = Highest(High,252);
def FiftyTwoWeekHighPercent = 100-(C /FiftyTwoWeekHigh)*100;
def FiftyTwoWeekLow = Lowest(Low,252);
def FiftyTwoWeekLowPercent = (C/FiftyTwoWeekLow)*100-100;
 
addlabel(1, "% off 52-week high: " + round(fiftytwoweekhighPercent,2), color.dark_orange);
addlabel(1, "% off 52-week low: " + round(fiftytwoweeklowPercent,2), color.dark_orange);
 

Advancing

New member
VIP
Hello,
Looking to plot 52 week high and 52 week low once and not dynamically update (recalculate) with each tick.

Code:
def Start;
def Finish;

if (GetUnderlyingSymbol() == GetSymbol())
{
    Start = Highest(high, 252);
    Finish = Lowest(low, 252);
}
else
{
    Start = Double.NaN;
    Finish = Double.NaN;
}
 

mikehardy03

New member
I am trying to figure out how to make a script for 2 columns in my watchlist. i need one that takes 52 week high and divides it by 52 week low. the 2nd i need is dividing the Float by the average daily volume for a period of 3 months (90) days. i have been trying to figure it out with tutorials online but not having much luck. also are this functions possible in TOS? I know you can do this with TC2000 platform. all help is greatly appreciated!!
 

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

Nikola

Member
Using this to show a dashed line for 52wk high, how can i add a price bubble to show on the right axis

Code:
def a = Highest(high, 252);
def barNumber = barNumber();
def bar = if IsNaN(a)
then Double.NaN
else BarNumber();
def ThisBar = HighestAll(bar);
def Line = if bar == ThisBar
then a
else Double.NaN;
plot P = if ThisBar
then HighestAll(Line)
else Double.NaN;
P.SetStyle(Curve.Short_Dash);
P.SetLineWeight(1);
P.SetDefaultColor(CreateColor(75,250,150));
 

Similar threads

Top