# Close Within x% Of High-Low Range For ThinkOrSwim

#### Drum Rocker

##### Member
VIP
Looking for help coding a study that will mark a price bar (any time frame) that has a close in the top 10% of it's range, or a close in the bottom 10% of it's range. For marking the bar that meets these conditions I am thinking a green dot above the price bar for a close in the top 10% of it's range and a red dot below the bar that closes in the bottom 10% of it's range. See image below.

The math for a top 10% close is: High - ((High - Low) * .10). Mark bar if close is equal to or greater than this result.
The math for a bottom 10% close is: Low + ((High - Low) * .10). Mark bar if close is equal to or less than this result.

Thanks in advance for any help with this study!

Last edited by a moderator:
here you go:
IDENTIFY BARS/CANDLES THAT HAVE CLOSED WITHIN XYZ% FROM ITS HIGHER (TOP) and LOWER (BOTTOM) HIGH-LOW RANGE v2.0
Code:
``````#IDENTIFY BARS/CANDLES THAT HAVE CLOSED WITHIN XYZ% FROM ITS HIGHER (TOP) and LOWER (BOTTOM) HIGH-LOW RANGE) v2.0
#via request By XeoNoX via usethinkscript.com 07/06/2024
#change input candle percent to whatever percent you would like
input CandlePercent = 10;
plot TopPercent= close>High - ((High - Low) * (CandlePercent*.01));
plot BottomPercent = close<Low + ((High - Low) * (CandlePercent*.01));
TopPercent.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
TopPercent.SetDefaultColor(Color.green);
TopPercent.SetLineWeight(2);
BottomPercent.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
BottomPercent.SetDefaultColor(Color.RED);
BottomPercent.SetLineWeight(2);``````

Last edited by a moderator:
here you go:
IDENTIFY BARS/CANDLES THAT HAVE CLOSED WITHIN XYZ% FROM ITS HIGHER (TOP) and LOWER (BOTTOM) HIGH-LOW RANGE v2.0
Code:
``````#IDENTIFY BARS/CANDLES THAT HAVE CLOSED WITHIN XYZ% FROM ITS HIGH-LOW RANGE) v1.0
#via request By XeoNoX via usethinkscript.com 07/06/2024
input CandlePercent = 10;
plot top10 = close>High - ((High - Low) * (CandlePercent*.01));
plot bottom10 = close<Low + ((High - Low) * (CandlePercent*.01));
top10.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
top10.SetDefaultColor(Color.green);
top10.SetLineWeight(2);
bottom10.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
bottom10.SetDefaultColor(Color.RED);
bottom10.SetLineWeight(2);``````
Works perfectly. Thank you, @XeoNoX

Last edited by a moderator:

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