Thinkorswim ATR Compression Breakout Scanner with Relative Volume Confirmation

This free thinkScript Stock Hacker scanner looks for a breakout after a quieter volatility regime, supported by higher-than-average volume. It is a candidate-selection tool, not a trade recommendation or automated order system.

Exact calculation

The resistance threshold is the highest high among the previous 20 bars: Highest(high[1], 20). The preceding bar's ATR(14) must be below 85% of the average ATR(14) across the previous 30 bars. The current close must exceed resistance while the prior close was at or below resistance. Current volume must exceed 130% of the average of the previous 20 bars, and the current close must be at least $5. Historical data must be available for every test.

Thinkorswim ATR Compression Breakout Scanner with Relative Volume Confirmation
Schematic illustration, not historical market data. Blue represents price; royal blue marks prior resistance; green bars indicate elevated volume. The graphic illustrates breakout geometry, not ATR values.

Complete thinkScript source code

The script produces a single Boolean plot called scan, suitable for a Stock Hacker custom study filter.

# Stock Hacker ATR Compression Breakout Scanner
input breakoutLookback = 20;
input atrLength = 14;
input atrBaselineLength = 30;
input compressionFactor = 0.85;
input volumeLength = 20;
input volumeMultiplier = 1.30;
input minimumPrice = 5.0;

def atrValue = ATR(length = atrLength);
def priorATRMean = Average(atrValue[1], atrBaselineLength);
def priorResistance = Highest(high[1], breakoutLookback);
def priorVolumeMean = Average(volume[1], volumeLength);
def compressed = atrValue[1] < priorATRMean * compressionFactor;
def breakout = close > priorResistance and close[1] <= priorResistance;
def volumeConfirmed = volume > priorVolumeMean * volumeMultiplier;
def priceFilter = close >= minimumPrice;
def ready = !IsNaN(priorResistance) and !IsNaN(priorATRMean)
            and !IsNaN(priorVolumeMean) and priorVolumeMean > 0;
plot scan = ready and compressed and breakout and volumeConfirmed and priceFilter;

Installation and settings

  1. Open thinkorswim, choose Scan > Stock Hacker.
  2. Add a Study filter, choose Custom, and paste the full script.
  3. Select daily aggregation and run the scan. Match the aggregation and extended-hours settings to your chart.
  4. Change the 20-bar breakout lookback, ATR length 14, baseline 30, compression factor 0.85, volume lookback 20, volume multiplier 1.30, or $5 price floor as appropriate.

Worked example

If the prior 20-bar high is $48, the previous close $47.50, and the current close $48.40, the breakout test passes. If prior ATR is $1.10 and the prior 30-bar ATR average is $1.40, then $1.10 < 0.85 × $1.40 = $1.19, so compression passes. If current volume is 1.6 million shares versus 1.1 million average, then 1.6 million > 1.30 × 1.1 million = 1.43 million, so volume passes.

Bar timing, false signals, and limitations

ATR compression uses the preceding completed bar, but current close and volume remain provisional until the active bar closes. Intraday scan results can appear and disappear; run after the session close for confirmed daily signals. The resistance calculation excludes the current bar and uses no future data. Failed breakouts, earnings gaps, thin trading, and regime shifts can produce false positives. This scan is intentionally selective and will miss some legitimate breakouts.

Validation checklist

Confirm one Boolean plot, sufficient history, the intended aggregation, exclusion of the active bar from resistance, and consistency between scan hits and charts. Inspect at least ten candidates and evaluate parameter stability on out-of-sample symbols. The logic has not been compiled or live-tested here.

Interested in customizing or extending this free scanner? Discuss your requirements through our Custom Trading Software Development Services.

Educational information only; no guarantee of results. Consider transaction costs, slippage, position sizing, and trading risk.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.