# Script that finds a study's last high or low?

#### TOS2221

##### New member
Is there a script that finds the latest, not the day's or n-bars ago, high or low (reversal?) of a study?

Please refer to the attached image that shows study lows at their respective time.

My goal is to determine when the study breaks its latest hi/lo. Maybe I'm not approaching it correctly. Suggestions are welcome.

Solution
Is there a script that finds the latest, not the day's or n-bars ago, high or low (reversal?) of a study?

Please refer to the attached image that shows study lows at their respective time.

My goal is to determine when the study breaks its latest hi/lo. Maybe I'm not approaching it correctly. Suggestions are welcome.

start over and start at the beginning,
high and low are properties of a candle. using them to describe something else is confusing.
use different words, like peak and valley.
what defines a peak, what defines a valley?
latest is confusing. do you mean previous peak?

rough code outline,
def peak = (some formula that is true or false)
def peak_level = if peak then high else peak_level[1];
plot z = peak_level...
Is there a script that finds the latest, not the day's or n-bars ago, high or low (reversal?) of a study?

Please refer to the attached image that shows study lows at their respective time.

My goal is to determine when the study breaks its latest hi/lo. Maybe I'm not approaching it correctly. Suggestions are welcome.

start over and start at the beginning,
high and low are properties of a candle. using them to describe something else is confusing.
use different words, like peak and valley.
what defines a peak, what defines a valley?
latest is confusing. do you mean previous peak?

rough code outline,
def peak = (some formula that is true or false)
def peak_level = if peak then high else peak_level[1];
plot z = peak_level;
... if close > peak_level then draw an arrow

87k+ Posts
372 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?