Average True Range Scans
Build two Average True Range scans in ThinkOrSwim, that let you find stocks with both high and low volatility.
Introduction
In today's tutorial, we'll walk you through the process of building Average True Range (ATR) scans in ThinkOrSwim.
This guide will cover the basics of ATR, how to set up scans for high ATR values, and more advanced scans for stocks compressing near a specific moving average.
By the end of this tutorial, you'll have a solid understanding of how to leverage ATR in ThinkOrSwim, to build your own custom scans.
Volatility Box Invite
We are TOS Indicators.com, home of the Volatility Box.
The Volatility Box is our secret tool, to help us consistently profit from the market place. We’re a small team, and we spend hours every day, after the market close, doing nothing but studying thousands of data points to keep improving and perfecting the Volatility Box price ranges.
We have two different Volatility Boxes - a Futures Volatility Box and a Stock Volatility Box.
Futures Volatility Box - Trade Major Markets With an Edge
Designed For: Futures, Micro-Futures and Index Market Traders
Supported Models: Hourly Volatility Box models
Supported Markets: 10 Major Futures Markets
The Futures Volatility Box comes with:
- 5 Volatility Models for each market
- Support for 10 Futures Markets (/ES, /NQ, /YM, /RTY, /CL, /GC, /SI, /ZB, /HG, /NG)
- Video Setup Guide
- Trade Plan
- Access to all members-only resources, including Squeeze Course
Learn More About the Futures Volatility Box
Trade futures and micro futures with a consistent volatility edge
Stock Volatility Box - Powerful Web Based Volatility Platform
Designed For: Stock and Options Traders
Supported Models: Hourly and Daily Volatility Box models
Supported Markets: 10,000+ Stocks and ETFs (new markets added frequently)
A Stock Volatility Box membership includes access to:
- Live Scanner - A powerful scanner we've built from scratch, to scan 10,000 symbols every 2 seconds for new volatility breaches
- Dashboard - A quick and easy way to view daily volatility model levels online
- Short Interest Scanner - Short interest, Squeeze, and EMA data to find short squeezes
- Squeeze Course - All of our proprietary squeeze tools, including robust backtesters
- All Members Only Indicators - We don't nickel and dime you. Everything really is included.
- And much more!
Learn More About the Stock Volatility Box
Trade stocks and options with a consistent volatility edge
What is Average True Range (ATR)?
The Average True Range (ATR) is a technical analysis indicator developed by J. Welles Wilder. It measures market volatility by decomposing the entire range of an asset price for a given period.
Unlike other volatility indicators, ATR does not provide an indication of price direction. Instead, it is used to measure the degree of price movement, which can be helpful in identifying potential trading opportunities.
ATR is calculated as follows:
- True Range (TR): The greatest of the following three values:
- Current high minus the current low
- Absolute value of the current high minus the previous close
- Absolute value of the current low minus the previous close
- Average True Range (ATR): The moving average of the True Range over a specified period, typically 14 days.
Why Use ATR in Trading?
ATR is widely used by traders to identify and measure volatility. High ATR values indicate high volatility, while low ATR values indicate low volatility. This can be particularly useful for:
- Setting Stop-Loss Orders: ATR can help determine appropriate stop-loss levels by accounting for market volatility.
- Identifying Breakouts: ATR can be used to identify potential breakouts by detecting periods of high volatility.
- Filtering Scans: Traders can use ATR to filter scans and identify stocks with specific volatility characteristics.
Scan 1: Stocks With High ATR
The first scan we'll build is designed to identify stocks with high ATR values.
This scan is straightforward and helps you get a feel for referencing ATR in ThinkOrSwim.
Step 1: Setting Up Basic Filters
To begin, we'll add two basic liquidity filters to ensure our scan results are actionable:
- Stock Price Filter: We'll set a minimum stock price of $10 to exclude low-priced stocks that may be less reliable.
- Volume Filter: We'll set the average volume to be greater than 2 million shares to ensure sufficient liquidity and avoid execution timeout errors.
Here's how you can set these filters in ThinkOrSwim:
- Open the Scan tab.
- Add a filter for stock price: Select "Stock" and set the "Last" field to "Greater than" $10.
- Add a filter for volume: Select "Study," then choose "Volume" and set the "Average Volume" field to "Greater than" 2 million shares.
Step 2: Adding the ATR Condition
Next, we'll add a study filter to reference the ATR. We want to identify stocks where the current ATR value is higher than the 50-bar average ATR. This helps us pinpoint stocks experiencing higher than usual volatility.
Here's the ThinkScript code for this scan:
## ATR def ATR = ATR(); ## Average ATR def averageATR = Average(ATR, 50); ## Plot Condition plot signal = ATR > averageATR;
This code calculates the current ATR and compares it to the 50-bar average ATR. The plot signal
line triggers when the current ATR exceeds the average ATR, filtering for stocks with higher than usual volatility.
Step 3: Running the Scan
Run the scan to filter the list of stocks based on the ATR condition. This will give you a list of stocks with higher than average ATR values, indicating higher volatility and potential trading opportunities.
Scan 2: Identifying Compression Near Moving Averages
The second scan is more advanced and focuses on identifying stocks that are compressing near a specific moving average. Compression indicates a potential breakout, making this scan useful for traders looking to capitalize on such moves.
Step 1: Define Compressed Range
First, we'll define a compressed range by calculating the highest high and lowest low over the past 10 bars. We'll compare this range to the ATR value to identify compression.
Here's the ThinkScript code for the compressed range:
## Highest High and Lowest Low def highestHigh = Highest(high, 10); def lowestLow = Lowest(low, 10); def range = highestHigh - lowestLow; ## Range Compression def rangeCompression = range <= ATR * 2;
This code calculates the range of the highest high and lowest low over the past 10 bars and checks if this range is less than or equal to twice the ATR value, indicating compression.
Step 2: Add Moving Averages
Next, we'll add conditions for moving averages to ensure we're looking at stocks with a specific trend structure. We'll define the 8 EMA, 34 EMA, 50 SMA, and 200 SMA, and set conditions for their relationships.
Here's the ThinkScript code for moving averages:
## Moving Averages def EMA8 = ExpAverage(close, 8); def EMA34 = ExpAverage(close, 34); def SMA50 = SimpleMovingAvg(close, 50); def SMA200 = SimpleMovingAvg(close, 200); ## Moving Average Condition def movingAverageCondition = EMA8 > EMA34 and EMA34 > SMA50 and SMA50 > SMA200;
This code defines the moving averages and sets a condition to ensure that the 8 EMA is greater than the 34 EMA, the 34 EMA is greater than the 50 SMA, and the 50 SMA is greater than the 200 SMA. This condition helps identify stocks in a specific trend structure.
Step 3: Define Proximity to 50 SMA
We'll create a condition to check if the stock price is within a certain percentage of the 50 SMA. This helps us identify stocks that are close to this moving average, indicating potential compression.
Here's the ThinkScript code for the proximity to the 50 SMA:
## Percentage Within SMA input pct = 0.05; def pctWithinSMA = close >= (SMA50 * (1 - pct)) and close <= (SMA50 * (1 + pct));
This code defines an input percentage (pct
) and checks if the closing price is within that percentage range of the 50 SMA.
Step 4: Combine All Conditions
Finally, we'll combine the range compression, moving average conditions, and proximity to the 50 SMA to create our complete scan.
Here's the full ThinkScript code:
## Inputs input pct = 0.05; ## ATR def ATR = ATR(); ## Compressed Range def highestHigh = Highest(high, 10); def lowestLow = Lowest(low, 10); def range = highestHigh - lowestLow; def rangeCompression = range <= ATR * 2; ## Moving Averages def EMA8 = ExpAverage(close, 8); def EMA34 = ExpAverage(close, 34); def SMA50 = SimpleMovingAvg(close, 50); def SMA200 = SimpleMovingAvg(close, 200); def movingAverageCondition = EMA8 > EMA34 and EMA34 > SMA50 and SMA50 > SMA200; ## Pct Within SMA def pctWithinSMA = close >= (SMA50 * (1 - pct)) and close <= (SMA50 * (1 + pct)); ## Final Scan plot signal = rangeCompression and movingAverageCondition and pctWithinSMA;
This scan will filter stocks based on their compression near the 50 SMA, considering their ATR and moving average conditions.
Practical Examples
Let's apply these scans to some real-world examples to see how they work in practice.
Example 1: High ATR Scan
After running the high ATR scan, let's look at some of the results. For instance, NVIDIA might come up at the top of the list.
By examining a chart of NVIDIA, you can see that its current ATR value is indeed higher than the 50-bar average ATR, indicating increased volatility.
Example 2: Compression Near 50-period Simple Moving Average
Next, let's apply the compression near moving average scan.
Suppose Micron Technology appears on the list. By looking at its chart, you can see that the stock price is compressing near the 50 SMA, and the moving averages (8 EMA, 34 EMA, 50 SMA, and 200 SMA) are in the desired order.
This suggests a potential breakout opportunity.
Conclusion
By following this comprehensive guide, you should now have a solid understanding of how to use ATR in ThinkOrSwim to build effective trading scans.
Whether you're looking for high volatility stocks or those poised for potential breakouts, these scans will help you identify trading opportunities more effectively.
downloads
Download the Average True Range Scans for ThinkorSwim.
The download contains a text file with two ThinkOrSwim shared links, to import into your platform.
Download Scan
Download the Average True Range Scans for ThinkorSwim.
The download contains a text file with two ThinkOrSwim shared links, to import into your platform.