Thinkorswim Gap-Down Recovery Scanner: Completed-Session Gap Fill Quality with Relative Volume

Beginner Trading Tutorial | thinkScript | Stock Hacker

A gap-down opening can lead to continued selling, a brief bounce, or a meaningful recovery. Rather than assuming that every gap will close, this practical Stock Hacker scan asks three testable questions: Was yesterday's opening gap large enough? Did that completed session recover a meaningful fraction of the gap? Was its trading volume higher than its recent baseline?

The distinctive feature is timing. The scan intentionally evaluates the last completed daily candle, not today's changing candle. It is a retrospective screening tool for finding candidates for further chart review, not a forecast or automated order entry system.

1. Three gates, one Boolean result

Gate A — gap magnitude. Compare yesterday's opening price with the closing price two trading sessions ago. Gap percent = 100 × (previous close − yesterday's open) / previous close. A positive number represents a gap down. Default threshold: 1%.

Gate B — recovery quality. Divide the rise from yesterday's open to yesterday's close by the initial gap size. Recovery percent = 100 × (yesterday's close − yesterday's open) / (previous close − yesterday's open). A 40% recovery means price recovered 40% of the opening gap by the close. This implementation deliberately excludes an overshoot above the pre-gap close; that is a design choice, not a universal trading rule.

Gate C — participation. Relative volume = yesterday's volume / average volume over the 20 sessions ending two sessions ago. Excluding yesterday from the baseline avoids letting the signal session inflate its own comparison. Default minimum: 1.10.

Thinkorswim Gap-Down Recovery Scanner: Completed-Session Gap Fill Quality with Relative Volume
Figure: three independent checks—opening gap, closing recovery, and volume participation—must all pass before the scanner returns true. Diagram is conceptual, not a price forecast.

2. Complete thinkScript for Stock Hacker

Copy the full code below into a custom Stock Hacker study filter. The single output is plot scan, as required for a Boolean scan.

# Thinkorswim Stock Hacker: completed-session gap-down recovery
# Use DAILY aggregation in Stock Hacker.
# The scan evaluates yesterday [1] against the day before [2].
input minGapPct = 1.0;
input minRecoveryPct = 40.0;
input minRelativeVolume = 1.10;
input averageVolumeLength = 20;
input minPriorClose = 5.0;

def priorClose = close[2];
def signalOpen = open[1];
def signalClose = close[1];
def signalVolume = volume[1];
def baselineVolume = Average(volume[2], averageVolumeLength);

def gapSize = priorClose - signalOpen;
def gapPct = if priorClose > 0 then 100 * gapSize / priorClose else 0;
def recoveryPct = if gapSize > 0 then
    100 * (signalClose - signalOpen) / gapSize
    else 0;
def relativeVolume = if baselineVolume > 0 then
    signalVolume / baselineVolume else 0;

def validGap = priorClose >= minPriorClose and gapPct >= minGapPct;
def recovery = signalClose > signalOpen and
    signalClose <= priorClose and
    recoveryPct >= minRecoveryPct;
def participation = relativeVolume >= minRelativeVolume;

plot scan = validGap and recovery and participation;

3. Worked numerical example

Suppose the pre-gap close was $100, yesterday opened at $97, and closed at $98.50. The opening gap was $3, or 3%. The recovery was $1.50 / $3 = 50%, so the 40% recovery threshold passes. If yesterday traded 1.5 million shares and the prior 20-session average was 1.2 million, relative volume was 1.25. All three gates pass, assuming the prior close is above $5.

Now change the closing price to $97.60. Recovery drops to 20%, so the scan fails even if volume is high. Conversely, a $99 close with relative volume of 0.85 also fails. These examples show why combining conditions is more selective than a gap-size filter alone.

4. Installation and settings

  1. Open Thinkorswim Stock Hacker and add a Study filter.
  2. Choose a custom study, open the thinkScript editor, replace its contents with the program above, and save.
  3. Set the filter aggregation to Day. The [1] and [2] references are daily bars only when the study runs on daily aggregation.
  4. Start with minGapPct = 1, minRecoveryPct = 40, minRelativeVolume = 1.10, averageVolumeLength = 20, and minPriorClose = 5.
  5. Run the scan after the daily session closes, then inspect matching charts for liquidity, news, spread, and broader market context.

The minimum prior-close input is a crude price filter, not a substitute for a liquidity or market-cap requirement. Stock Hacker availability and scan behavior can depend on the account, data permissions, session settings, and symbol universe.

5. Common mistakes and limitations

Misreading [1]. This scan deliberately evaluates yesterday, so a result appearing today does not mean a fresh signal is forming today. On holidays or illiquid symbols, the latest completed bar may not correspond to the previous calendar day.

Mixing session definitions. Extended-hours data, corporate actions, adjusted history, and instrument-specific sessions can change gap calculations. Compare scan results with a chart using consistent daily-session settings.

Confusing recovery with reversal. A strong close after a gap down does not establish that a trend has reversed. News, low-float activity, earnings gaps, and overnight liquidity can produce misleading setups.

Relative volume is not buying pressure. Volume measures participation, not the identity or intention of buyers and sellers. A high-volume recovery can still fail on the next session.

Historical stability. Using [1] and [2] reduces incomplete-bar changes, but it does not eliminate data revisions, split adjustments, or differences between historical and live market data. Do not call this a guaranteed non-repainting trading system.

6. Practical validation checklist

Test at least 20 symbols across liquid and illiquid names. For each candidate, manually verify the previous close, yesterday's open and close, yesterday's volume, and the 20-bar baseline. Check both passing and failing examples. Repeat on earnings days and after stock splits. Record how often the next session continues the recovery versus retraces, and include spreads, slippage, and transaction costs in any strategy evaluation.

7. Sensible extensions

Possible future additions include an average dollar-volume floor, a sector-relative filter, a maximum gap cap, and a separate chart study that marks the recovery session. Keep the scanner's Boolean output simple; adding too many gates can overfit a small sample. If you need a version integrated with custom alerts, portfolio screening, or a platform-specific workflow, see Custom Trading Software Development Services.

Educational use only. This scan does not predict future returns or constitute personalized investment advice. Verify code and settings in your own environment before relying on any signal.

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.