Recent All Time Highs?

Airtower

New member
Hello, I have found some coding that is close to what I am looking for but not sure how to incorporate the recency of hitting an All Time High.
Simply put, I am just looking to create a script that checks a Daily chart over the last 500 trading days, that is looking for an New All Time High created in the last 15 days. I sued this code from a previous post to find if a stock is close to the All Time High but not sure how I can modify it (or create a new custom code) to find what i am looking for above...

Code:
# Cond = at least 95%-99% of all time high that is from at least 6 to 52 weeks ago....and is now advancing towards all time high again.
def thisBar = if isNaN(close[-1]) and !isNaN(close)
then barNumber()
else thisBar[1];
def hhBar = if high == highest(high, 350)
then barNumber()
else hhBar[1];
def hh = if high == highest(high, 350)
then high
else hh[1];
plot Cond = highestAll(thisBar) - highestAll(hhBar) > 5 and
between(close, hh * .975, hh * .9995) and
isAscending(close, 5);
 
Solution
Hello, I have found some coding that is close to what I am looking for but not sure how to incorporate the recency of hitting an All Time High.
Simply put, I am just looking to create a script that checks a Daily chart over the last 500 trading days, that is looking for an New All Time High created in the last 15 days. I sued this code from a previous post to find if a stock is close to the All Time High but not sure how I can modify it (or create a new custom code) to find what i am looking for above...

Code:
# Cond = at least 95%-99% of all time high that is from at least 6 to 52 weeks ago....and is now advancing towards all time high again.
def thisBar = if isNaN(close[-1]) and !isNaN(close)
then barNumber()
else thisBar[1];
def...
Hello, I have found some coding that is close to what I am looking for but not sure how to incorporate the recency of hitting an All Time High.
Simply put, I am just looking to create a script that checks a Daily chart over the last 500 trading days, that is looking for an New All Time High created in the last 15 days. I sued this code from a previous post to find if a stock is close to the All Time High but not sure how I can modify it (or create a new custom code) to find what i am looking for above...

Code:
# Cond = at least 95%-99% of all time high that is from at least 6 to 52 weeks ago....and is now advancing towards all time high again.
def thisBar = if isNaN(close[-1]) and !isNaN(close)
then barNumber()
else thisBar[1];
def hhBar = if high == highest(high, 350)
then barNumber()
else hhBar[1];
def hh = if high == highest(high, 350)
then high
else hh[1];
plot Cond = highestAll(thisBar) - highestAll(hhBar) > 5 and
between(close, hh * .975, hh * .9995) and
isAscending(close, 5);

here is something to experiment with

Code:
declare lower;
input days_back = 500;
input within_days = 15;
def x = GetMaxValueOffset(high, days_back);
plot z = x <= within_days;
addchartbubble(0, -.3, x, color.yellow, no);
#
 

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

Hello, I have found some coding that is close to what I am looking for but not sure how to incorporate the recency of hitting an All Time High.
Simply put, I am just looking to create a script that checks a Daily chart over the last 500 trading days, that is looking for an New All Time High created in the last 15 days. I sued this code from a previous post to find if a stock is close to the All Time High but not sure how I can modify it (or create a new custom code) to find what i am looking for above...

Code:
# Cond = at least 95%-99% of all time high that is from at least 6 to 52 weeks ago....and is now advancing towards all time high again.
def thisBar = if isNaN(close[-1]) and !isNaN(close)
then barNumber()
else thisBar[1];
def hhBar = if high == highest(high, 350)
then barNumber()
else hhBar[1];
def hh = if high == highest(high, 350)
then high
else hh[1];
plot Cond = highestAll(thisBar) - highestAll(hhBar) > 5 and
between(close, hh * .975, hh * .9995) and
isAscending(close, 5);

why mention 500 days, if you only care about the last 15 days?
forget my previous post. i had an idea, but didn't test it thoroughly.

here is a version that works
it looks at the past 15 bars and draws 2 pulse lines, that go to 1.
. higher , =1 each time a new high happens
. recenthi , =1 when a new high happens in the last 15 bars


Code:
declare lower;
def na = double.nan;
def bn = barnumber();
#input bars_back = 500;
input within_bars = 15;
def hi = if bn == 1 then high
 else max(high, hi[1]);

def higher = if bn == 1 then 0
 else (hi != hi[1]);
def recenthi = sum(higher,within_bars)>0;

plot z = higher;
plot y = recenthi;
#
 

Attachments

  • Capture.JPG
    Capture.JPG
    70.4 KB · Views: 14
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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