- Building Average True Range Scanners in ThinkOrSwim
- High ATR Scanner Implementation
- ATR Compression Scanner Development
- Timeframe and Market Condition Optimization
- Implementation Strategy and Alert Setup
- Risk Management and Position Sizing
- Advanced Filtering and Integration
- Performance Tracking and Continuous Improvement
Master ATR-Based Stock Scanning in ThinkOrSwim
Discover how to build sophisticated Average True Range scanners that automatically identify high-probability trading setups based on volatility patterns and price compression.
In this detailed tutorial, you’ll learn to create 2 essential ATR scanners:
- High ATR Scanner – Identifies stocks with above-average volatility
- ATR Compression Scanner – Finds stocks compressing near key moving averages
These scanners help you spot stocks primed for significant moves by analyzing volatility patterns that often precede major price breakouts and momentum shifts.
Building Average True Range Scanners in ThinkOrSwim
Average True Range (ATR) scanners provide a systematic approach to identifying stocks with specific volatility characteristics that often precede significant price movements. By focusing on volatility patterns rather than just price action, you can spot high-probability trading opportunities before they become obvious to other traders.
ATR, developed by J. Welles Wilder Jr., measures market volatility by calculating the average range between high and low prices over a specified period. Unlike directional indicators, ATR focuses purely on the magnitude of price movement, making it valuable for both opportunity identification and risk management.
High ATR Scanner Implementation
The first scanner identifies stocks where current ATR exceeds the 50-day moving average of ATR values. This approach filters for stocks experiencing above-normal volatility, which often correlates with emerging institutional activity and breakout potential.
def ATR = ATR();
def averageATR = Average(ATR, 50);
plot signal = ATR > averageATR;
This scanner identifies stocks experiencing increased institutional activity, breakout candidates with expanding volatility, and opportunities for momentum-based strategies. The logic is straightforward: when current volatility exceeds the recent average, it often signals that something significant is happening with the stock.
For optimal implementation, run this scan during market hours for real-time alerts. Add basic liquidity filters in Stock Hacker: minimum stock price above $10 and average volume above 2 million shares. This ensures you’re working with liquid stocks that won’t gap against you unexpectedly.
The 50-day average provides a good balance between responsiveness and stability. Shorter periods (20-30 days) will give more signals but may include more false positives. Longer periods (100+ days) will be more selective but may miss shorter-term opportunities.
ATR Compression Scanner Development
The compression scanner is more sophisticated, designed to identify stocks in tight trading ranges near key moving averages. This pattern often precedes significant breakouts as volatility contracts before expanding in major moves.
The scanner combines three key technical components that work together to identify high-probability compression patterns:
Range Compression Analysis: Calculate the 10-day high-low range and compare it to current ATR values. When the recent range is tight relative to normal volatility, it suggests accumulation or distribution activity:
def highestHigh = Highest(high, 10);
def lowestLow = Lowest(low, 10);
def range = highestHigh - lowestLow;
def rangeCompression = range <= ATR * 2;
The multiplier of 2 works well for most stocks, but you can adjust based on market conditions. During high volatility periods, increase to 2.5 or 3. During quiet markets, reduce to 1.5 to capture more opportunities.
Moving Average Structure: The scanner requires specific moving average alignment to confirm trend structure. This ensures you're finding compression patterns within established trends rather than directionless consolidation:
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;
This moving average hierarchy ensures you're only finding compression patterns in stocks with bullish structure. For bearish setups, reverse the conditions. You can also remove the SMA200 condition if you want a larger universe of stocks.
Proximity to Key Levels: The final component ensures price is trading within a specified percentage of the 50-day simple moving average:
input pct = 0.03;
def pctWithinSMA = close >= (SMA50 * (1 - pct)) and close <= (SMA50 * (1 + pct));
The 3% range works well for most stocks, but you can adjust based on your preferences. Tighter ranges (1-2%) will find stocks very close to the moving average, while wider ranges (4-5%) will capture more opportunities but may be less precise.
Timeframe and Market Condition Optimization
These scanners adapt well to different timeframes and market conditions with proper parameter adjustments.
Timeframe Adaptation: For day trading, apply the scanners to 5-15 minute charts and reduce the ATR period to 10 bars. For swing trading, daily charts work best with the standard 14-period ATR. For position trading, consider weekly charts with 20-period ATR.
Market Condition Adjustments: During high volatility markets (VIX above 25), increase the ATR multiplier in the compression scanner to 2.5 or 3 to avoid false signals. In quiet markets (VIX below 15), reduce the multiplier to 1.5 to capture more opportunities.
Sector Considerations: Technology stocks often require higher ATR thresholds due to their inherent volatility. Utilities and consumer staples may trigger signals with lower multipliers. Consider creating sector-specific scanner versions.
Implementation Strategy and Alert Setup
Effective ATR scanning requires a systematic approach to maximize opportunities while minimizing false signals.
Alert Configuration: Set up real-time alerts by saving your scans in Stock Hacker and enabling "Alert when scan results change." Configure both sound and mobile notifications through the ThinkOrSwim mobile app. This ensures immediate notification when new opportunities emerge during market hours.
Scan Execution Timing: Run the high ATR scanner during market hours for immediate momentum opportunities. Execute the compression scanner after market close to prepare your watchlist for the following day. This approach lets you research potential setups when markets are closed.
Result Filtering: Always verify scanner results with additional analysis. Check for recent news, earnings announcements, and overall chart structure. Volume confirmation is crucial - look for above-average volume to validate the scanner signals.
Risk Management and Position Sizing
ATR values from your scans provide excellent guidance for risk management decisions.
Stop Loss Placement: Use ATR values to set initial stop losses. A common approach is placing stops at 1.5-2x the current ATR below your entry price for long positions. This accounts for normal volatility while providing meaningful protection.
Position Sizing: Higher ATR stocks require smaller position sizes to maintain consistent risk levels. Consider using the formula: Position Size = Risk Amount / (ATR × Stop Loss Multiplier). This automatically adjusts your position size based on the stock's volatility.
Profit Targets: Set initial profit targets at 2-3x the ATR from your entry point. This provides realistic expectations based on the stock's normal movement patterns.
Advanced Filtering and Integration
Volume Confirmation: Add volume filters to ensure adequate liquidity. Minimum average volume of 1-2 million shares helps avoid thin stocks that might gap unexpectedly. Also look for above-average volume on the day stocks appear on your scanner.
Earnings Calendar Integration: Be aware of upcoming earnings announcements, as these can cause volatility spikes unrelated to technical patterns. Consider excluding stocks with earnings within 3-5 days, or create separate scans specifically for earnings plays.
Integration with Other Indicators: Combine ATR scanners with momentum indicators like RSI or MACD for timing entries. Use volume analysis to confirm signals, and check support/resistance levels from the scanner results.
Performance Tracking and Continuous Improvement
Track your scanner performance to optimize parameters and improve results over time.
Hit Rate Analysis: Monitor how often scanner results lead to profitable trades. Track this data by scanner type, market condition, and timeframe to identify the most effective applications.
Parameter Testing: Test different ATR multipliers, timeframes, and additional filters. Keep detailed records of parameter changes and their impact on results. What works in trending markets may not work in range-bound conditions.
False Signal Reduction: Identify common characteristics of false signals and add filters to reduce them. This might include minimum volume requirements, price action confirmations, or additional technical indicators.
Successful ATR scanning requires patience and discipline. These scanners identify potential opportunities, not guaranteed profits. Always combine scanner results with proper risk management, market context analysis, and confirmation techniques. Start with the basic high ATR scanner to understand volatility-based opportunity identification, then gradually incorporate the more sophisticated compression scanner as you gain experience.
# Average True Range Scanners for ThinkOrSwim
# Generated by TOS Indicators
# Full tutorial: tosindicators.com/scans/average-true-range
# Scanner 1: High ATR Detection
# Identifies stocks with ATR above 50-day average
// ... 33 more lines ...Here are some resources that you may find useful: