# Stocks within 75% of Todays ATR range

#### Chiku83

##### New member
I need to build scanner to find stock which close above 75% of its range. Suppose stocked yesterday moved 100\$ and was close above 75\$ than i want to find that stock. Can someone help with TOS logic.

75% of its range... you didnt specify what range compared to what? what range?

100\$ and was close above 75\$ ... you will have to clarify this.

no suppose stock did move 100\$ in a day ....at the start of the day opening was 200\$ and close was 300\$ ...so stock moved 100\$ ...hence if it closes above 275\$ ,,,that is 75% range.

regular trading hour open to regular trading hour close or open from premarket to close of extended hours?

no suppose stock did move 100\$ in a day ....at the start of the day opening was 200\$ and close was 300\$ ...so stock moved 100\$ ...hence if it closes above 275\$ ,,,that is 75% range.

you want the low to be calculated as well? lets say the stock went below the open for a few dollars and it hit 190... according to your example now the range is 110? you want the low calculated in the range as well?

you want the low to be calculated as well? lets say the stock went below the open for a few dollars and it hit 190... according to your example now the range is 110? you want the low calculated in the range as well?
Low calculate as well

Can you grab a stock from today an plug in the numbers of how you want it to calculate and post back so that way i can see how you came up with the numbers.

Ticker: Baba
Open 231.99
Low: 230
High 239.19
Close 236.26

Range is High-Low = 239.19-230 = 9.19\$

Close delta from low = 236.26-230(low) = 6.26

Hence 100% =9.19

So baba close > 68% of range. I can adjust threshold of 60 % instead of 75%.

@Chiku83 So you want to calculate the range of the previous day and use that for the current trading day?

so 9.19 would be 100% and 6.26 is roughly about 60% (guessing)..... whats the formula to get the percentage that you want compared?

The range you are talking about for future reference is called the ATR in trading.
ATR is above or below X Percentage
Price is at XYZ Percent of Todays ATR

remember to hit that like button if you found my post useful

Code:
``````# ATR is above or below X Percentage
# Price is at XYZ Percent of Todays ATR
# By XeoNoX via usethinkscript.com

input threshold = 60;

def high1 = (high(period = AggregationPeriod.DAY));
def low1 = (low(period = AggregationPeriod.DAY));
def range = (high1 -  low1);

def x = high1 - low1;
def x2= close-low1;

def percentage= (x2/x)*100;

def  scan=  percentage > threshold;

AddLabel (yes, "Price is at " +  round(percentage,2) + "% of Today's ATR" );``````

For the scan u change:

Code:
``def  scan=  percentage > threshold;``

to

Code:
``plot scan=  percentage > threshold;``

and remove or comment out the "addlabel"

Code:
``#AddLabel (yes, "Price is at " +  round(percentage,2) + "% of Today's ATR" );``

Last edited:
Also want to do another script similar to short stock..it would be similar to above but instead greater than 60%....close of stock should be less than 25% of the range.

Eg Roku previous day (12/28) is perfect example
Open
High: 360.99
Open 359.50
Low 339.13
Close:340.33

Range: 360.99-339.13 =21.86

Close from low = 340.33-339.13=1.20 \$

So 21.86 \$ = 100%

1.20 = 58.29 =5.48%

Hence it should be part of scanner for today and can sort on price action..today would be perfect day for ROKU to get sort.

The range you are talking about for future reference is called the ATR in trading.
OK thanks got it. Appreciate it. Hear about it but didn't knew about it..let me try for couple of days and see if it matches my requirements. Thank you once again for all your time and responding to it....tons of thanks

Last edited by a moderator:
@Chiku83 So you want to calculate the range of the previous day and use that for the current trading day?
Yes Ben

I have no clue where you got 58.29 from.... however if you want it below 5% you just change:

input threshold = 5;
plot scan= percentage < threshold;

NOTE: for simplicity sake i kept the aspercent out of the label so you could scan against easier.

Last edited:
Ok...thanks and if I have to plot ATR for previous day i have to add [1]?

Code:
``````# ATR is above or below X Percentage
# Price is at XYZ Percent of Todays ATR
# By XeoNoX via usethinkscript.com

input threshold = 60;

def high1 = (high(period = AggregationPeriod.DAY[B][1])[/B]);
def low1 = (low(period = AggregationPeriod.DAY[B][1][/B]));
def range = (high1 -  low1);

def x = high1 - low1;
def x2= close-low1;

def percentage= (x2/x)*100;

def  scan=  percentage > threshold;

AddLabel (yes, "Price is at " +  round(percentage,2) + "% of Yesterday's ATR" );``````

To get the previous days you would at [1] so that it looks like this:

Code:
``````def high1 = (high(period = AggregationPeriod.DAY)[1]);
def low1 = (low(period = AggregationPeriod.DAY)[1]);``````

you should change your subject header to "Stocks within 75% of Todays ATR range" so others can find it

Thank you so much. Let me try to edit

@XeoNoX Good suggestion. I just did. No need to worry about editing the title post. @Chiku83

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