52-week Highs/Lows For ThinkOrSwim

Hey, how did you get the color codes on the right hand side like that?
Hi MourningWood. I used a script provided by @BenTen on page 1 of this thread to add a column to my scanner results that is red when at 52 wk low, green at 52 week high and yellow for in-between (BenTen's script uses gray instead of yellow). I have pasted the script below, but if you click back 1 page you will see the original post. Again, credit to @BenTen

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.YELLOW);

# end custom column code ------------------
 
Hi there - Could anyone help me with ToS screener which lists the stocks which have a new ATH after 1, 2yrs etc consolidation ?

Thanks
 
@vamsu A new ATH after a full year? Can you define this? From what you are saying is, the candle from 1 year ago, then see if its at all time highs? that wouldn't be all time highs. I assume you mean stocks that are at a 1 year high or 2 year high but you would have to clarify. If that's what you mean that can be found in the default built in scan in think or swim under <price performance>
 
I meant I want to find stocks which are breaking out to new ATH after 1,2+ years consolidations. For example, recently GM made a new high after 2 yr.

Basically, I want to find stocks which are making new highs after a long consolidation. Thanks for the help!
 
you can find quite a few on the forums that fit you the best, then just set it after with the built in TOS scan for price at 12 or 24 month high
 
LOVE THIS CODE. i use a white background and the font shows up white. anyway to keep the red and green background, but how would i change the font to black?

also on this code, how do i make sure digits are rounded to nearest hundredth digits? on some stocks, it goes to 4 digits. not sure why.

Capture4r.jpg
 
Can you help me in figuring out where the round function goes? Cant figure it out. when I added it before the color, I get errors :(

Code:
#CODE BELOW
AddLabel(1, "52Week HIGH = " + Highest(high(period = AggregationPeriod.Week),52), Round(close, 2), Color.green);
AddLabel(1, "52Week LOW = " + Lowest(low(period = AggregationPeriod.Week),52), Round(close, 2), Color.red);
#END CODE
 
Ok after extensive research, I have figured it out if anyone is interested...

Code:
def hi52 = Highest(high(period = AggregationPeriod.Week),52);
addlabel(1, "52Wk HI: $" + Round(hi52, 2), color.green);

def low52 = Lowest(low(period = AggregationPeriod.Week),52);
addlabel(1, "52Wk LOW: $" + Round(low52, 2), color.red);

This code rounds to nearest 2 digits after decimal and adds a "$".

Thanks guys!
 
Hi all, Im brand new at thinkscript so any help is appreciated!
Im looking to create a code to find stocks that are trading within 5% of their 52 week high. Can anyone help?
 
@KELTON98 ThinkOrSwim has a built in scan for that. Add filter, select Study. Then for the study type, in Price Performance select Near_Highs_Lows and change the default 3% to 5%..
 
has anyone seen a tos script that draws a line to mark a defined percentage below the chart high bubble? For instance, on SPX the current 52 week high is 3894.56 and if price were to drop 5% the value would be 3699.83. Looking for a script that can draw and update the 5% line as price moves up. Thanks!
 
vertical or horizontal line? and to understand you... you want the line drawn 5% below the 52 week high or all time high?
 
Try this code...

Ruby:
#PlotPctDiffDays
#plot price percent above or below close
#days: 5 = week, 22 = month, 252 = year
#pct positive for above, negative for below
#Change Highest to Lowest for finding lowest low
#Coded by rad14733 for usethinkscript.com
#v1.0 : 2021-02-06 : Initial Release

input days = 252;
input price = high;
input pct = 5;

plot data = Highest(price, days) * (1 + (pct / 100));

#END - PlotPctDiffDays
 
@MarcVUM welll i already put the time into it, so figured ide post it anyways, here is a slighly different version of what you requested

Draws Line at the SPECIFIED DAY/WEEK/MONTH HIGH
Draws Secondary Line XYZ Percent away from the SPECIFIED HIGH

DEFAULT IS DRAWS LINE AT 12 MONTH HIGH and ANOTHER LINE AT -5% AWAY
Plots on different time frames
Remember to like if you found this post useful

8aY6AX4.png



Code:
#By XeoNoX via usethinkscript.com
#Draws Line at the SPECIFIED DAY/WEEK/MONTH HIGH
#Draws Secondary Line XYZ Percent away from the SPECIFIED HIGH
#DEFAULT IS  DRAWS LINE AT 12 MONTH HIGH and ANOTHER LINE AT -5% AWAY
input baseperiod =  {default MONTH, WEEK, DAY};
# Specify The number number of basePeriod periods to go back
Input ago = 12;
#Specify The Percent value you want to draw your secondary line
Input percent_away_to_draw = -5;
Input ShowPercentlabel = yes;
Input ShowMainLabel = yes;
plot PriceValue = HighestAll(if IsNaN(Highest(high(period=BasePeriod), ago)[-1]) and !IsNaN(Highest(high(period = BasePeriod), ago)) then Highest(high(period = BasePeriod), ago) else Double.NaN);
Plot PriceValuePercent = (PriceValue * (.01*percent_away_to_draw)) + pricevalue ;
AddLabel (ShowPercentlabel,  Round(PriceValuePercent,2) +" is " +percent_away_to_draw + "% from" + ago +" "+ baseperiod  + " High" );
AddLabel (ShowMainlabel, ago + " " + BasePeriod + " High:  " + round(PriceValue,2) );
PriceValue.SetDefaultColor(Color.Cyan);
PricevaluePercent.SetDefaultColor(Color.yellow);
 
Anyone know how to do this one? On Fidelity Investments, I noticed that it shows next to the stock, the current price relative to the 52 week price range.

2021-02-15-17-00-59.jpg
 

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

Thread starter Similar threads Forum Replies Date
inthefutures New Intraday Highs and Lows For ThinkOrSwim Indicators 0

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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