# Highest Bar within 10 bars ago

##### Member
Trying to get a code that will plot this example:

The bar (high) three bars ago is higher than the highs 20 bars prior (20 bars ago)

Trying to figure that out.

Solution
Trying to get a code that will plot this example:

The bar (high) three bars ago is higher than the highs 20 bars prior (20 bars ago)

Trying to figure that out.

This should help

Code:
``````def cond = high[3] > high[20];
AddLabel(1, "Is H3:" + high[3] + " > H20: " + high[20] + "? = " +
if cond then "Yes" else "No",
Color.YELLOW );
#Test
input test = yes;
def bn = BarNumber();
def lastbn = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then bn else Double.NaN);
AddVerticalLine(test and bn == lastbn - 3, high, Color.WHITE);
AddVerticalLine(test and bn == lastbn - 20, high, Color.WHITE);

#``````
Trying to get a code that will plot this example:

The bar (high) three bars ago is higher than the highs 20 bars prior (20 bars ago)

Trying to figure that out.

This should help

Code:
``````def cond = high[3] > high[20];
AddLabel(1, "Is H3:" + high[3] + " > H20: " + high[20] + "? = " +
if cond then "Yes" else "No",
Color.YELLOW );
#Test
input test = yes;
def bn = BarNumber();
def lastbn = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then bn else Double.NaN);
AddVerticalLine(test and bn == lastbn - 3, high, Color.WHITE);
AddVerticalLine(test and bn == lastbn - 20, high, Color.WHITE);

#``````

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