# Three days tight based on average range

#### esti0000

##### New member
In a recent interview with Richard Molgen Pradeep Bonde talked about how he likes to scan for three consecutive consolidation days. I was wondering if anyone has build a custom scan to be able to do this?

I was thinking one way to do this might be to ask TOS to look for three consecutive days with the high/low range was a percentage of the stocks Average Daily Range (ADR).

For example: scan for stocks with three consecutive days where the range was less then 70% of the ADR on all three days. I have some script for how to calculate the ADR which is below but I am not sure how to write the rest of the script.

I would appreciate any assistance

Code:
``````#Calculate ADR Perc for last 20 days

input len = 20;

def ADR_perc = 100 * (Average(high, len) / Average(low, len) -1);``````

Hello,

I am trying to create a scan to look for a stock that has three consecutive days where the Daily True Range (DTR) is less then the Average True Range (ATR) for the last 20 days. I know how to define the ATR and the DTR for a day, but not sure how to convert this into a scan and to have it look at the last three days.

Code:
``````input AtrAvgLength = 20;

def ATR = WildersAverage(TrueRange(high(period = aggregationPeriod.DAY), close(period = aggregationPeriod.DAY), low(period = aggregationPeriod.DAY)), AtrAvgLength);

def TodayHigh = Highest(high(period = aggregationPeriod.DAY), 1);
def TodayLow = Lowest(low(period = aggregationPeriod.DAY), 1);

def DTR = TodayHigh - TodayLow;``````

@esti0000 Something like the following perhaps...

Ruby:
``def sqz3 = DTR < ATR and DTR[1] < ATR[1] and DTR[2] < ATR[2];``

@esti0000 Something like the following perhaps...

Ruby:
``def sqz3 = DTR < ATR and DTR[1] < ATR[1] and DTR[2] < ATR[2];``
Thanks when I put all this code together it wont let me hit ok is there something I am missing to complete the code? Sorry if this is really basic.

Code:
``````input AtrAvgLength = 20;

def ATR = WildersAverage(TrueRange(high(period = aggregationPeriod.DAY), close(period = aggregationPeriod.DAY), low(period = aggregationPeriod.DAY)), AtrAvgLength);

def TodayHigh = Highest(high(period = aggregationPeriod.DAY), 1);
def TodayLow = Lowest(low(period = aggregationPeriod.DAY), 1);

def DTR = TodayHigh - TodayLow;

def sqz3 = DTR < ATR and DTR[1] < ATR[1] and DTR[2] < ATR[2];``````

@esti0000 Change the def in the line I provided to a plot... You will most likely need additional scan filters to reduce the number of results...

In a recent interview with Richard Molgen Pradeep Bonde talked about how he likes to scan for three consecutive consolidation days. I was wondering if anyone has build a custom scan to be able to do this?

I was thinking one way to do this might be to ask TOS to look for three consecutive days with the high/low range was a percentage of the stocks Average Daily Range (ADR).

For example: scan for stocks with three consecutive days where the range was less then 70% of the ADR on all three days. I have some script for how to calculate the ADR which is below but I am not sure how to write the rest of the script.

I would appreciate any assistance

Code:
``````#Calculate ADR Perc for last 20 days

input len = 20;

def ADR_perc = 100 * (Average(high, len) / Average(low, len) -1);``````
I as well as others have been and had been in stockbee community for long time. Study intense learn to trade the right way community,.....there are many scans and ideas shared, join.

You could also use the TTM_Squeeze study and set it for 3d.

In a recent interview with Richard Molgen Pradeep Bonde talked about how he likes to scan for three consecutive consolidation days. I was wondering if anyone has build a custom scan to be able to do this?

I was thinking one way to do this might be to ask TOS to look for three consecutive days with the high/low range was a percentage of the stocks Average Daily Range (ADR).

For example: scan for stocks with three consecutive days where the range was less then 70% of the ADR on all three days. I have some script for how to calculate the ADR which is below but I am not sure how to write the rest of the script.

I would appreciate any assistance

Code:
``````#Calculate ADR Perc for last 20 days

input len = 20;

def ADR_perc = 100 * (Average(high, len) / Average(low, len) -1);``````

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