Thinkorswim EMA Pullback Reclaim Scanner: Confirmed-Bar Stock Hacker Code
Trending stocks often retreat toward a moving average before resuming their advance. This tutorial creates a precise Thinkorswim Stock Hacker filter that finds a bullish EMA reclaim supported by relative volume. It is a candidate-finding tool, not a trading system or a prediction.
Five conditions behind the scan
- Trend: 21-period EMA is above 50-period EMA, while signal-bar close remains above the slow EMA.
- Touch: the preceding candle's low is at or below its 21 EMA, but its close remains above the 50 EMA.
- Reclaim: the preceding candle closes at or below its 21 EMA; the signal candle closes above its own 21 EMA.
- Volume: signal-bar volume is at least 1.20 times its 20-bar simple average volume.
- Price: signal-bar close is at least $5.
EMA is an exponentially weighted average: EMA(t) = α × Close(t) + (1 − α) × EMA(t−1), with α = 2/(N+1). The relative-volume ratio here divides signal-bar volume by the simple 20-bar volume average, including that signal bar. It is not an intraday time-adjusted RVOL measure.

Complete thinkScript: Stock Hacker custom study filter
The code uses one Boolean plot and no secondary aggregation, matching Stock Hacker's custom-study requirements. Copy the entire listing:
# Stock Hacker: EMA pullback reclaim + volume
# Choose Daily aggregation. Exactly one Boolean plot.
input fastLength = 21;
input slowLength = 50;
input volumeLength = 20;
input minRelativeVolume = 1.20;
input minPrice = 5.00;
input useConfirmedBar = yes;
def offset = if useConfirmedBar then 1 else 0;
def fastEMA = ExpAverage(close, fastLength);
def slowEMA = ExpAverage(close, slowLength);
def avgVolume = Average(volume, volumeLength);
def trend = fastEMA[offset] > slowEMA[offset] and
close[offset] > slowEMA[offset];
def pullback = low[offset + 1] <= fastEMA[offset + 1] and
close[offset + 1] > slowEMA[offset + 1];
def reclaim = close[offset] > fastEMA[offset] and
close[offset + 1] <= fastEMA[offset + 1];
def volOK = avgVolume[offset] > 0 and
volume[offset] >= minRelativeVolume * avgVolume[offset];
plot scan = trend and pullback and reclaim and volOK and
close[offset] >= minPrice;
Inputs and sensible adjustments
| Input | Default | Role |
|---|---|---|
| fastLength | 21 | Reclaim reference EMA |
| slowLength | 50 | Trend filter |
| volumeLength | 20 | Average volume baseline |
| minRelativeVolume | 1.20 | Volume multiple |
| minPrice | 5.00 | Minimum closing price |
| useConfirmedBar | yes | Evaluate the last completed bar |
For example, suppose the pullback candle closes at $49.80, below its $50.00 fast EMA, with a $49.40 low and $47.00 slow EMA. The next completed candle closes at $50.70, above its $50.10 fast EMA and $47.20 slow EMA. If volume is 1.5 million versus a 20-bar average of 1.0 million, relative volume is 1.50 and the volume gate passes. This is hypothetical arithmetic, not historical performance evidence.
Install and verify in Thinkorswim
- Open Scan → Stock Hacker, choose a stock universe, then Add filter → Study → Custom.
- Open the thinkScript editor and paste the complete script. Select Day aggregation and save.
- Run the scan and inspect a few returned charts. Check both EMAs, the prior candle, the signal close, and the volume ratio.
- Keep
useConfirmedBar=yesfor previous-session confirmed daily signals. Set it tonoonly if you accept intraday changes to scan membership. - Validate qualifying and nonqualifying examples before relying on results. Compilation and real-market testing have not been performed for this article.
False positives, repainting and risk controls
The pattern is deliberately strict: a candle that merely approaches the fast EMA but never closes below it will not qualify. With confirmed bars enabled, the signal is evaluated at offset [1] and the prior pullback at [2]. The scan does not predict a next-day rally. With the setting disabled, live prices and volume change before bar close, so the result may appear and disappear.
Earnings gaps, low liquidity, wide spreads and abnormal one-day volume can produce unattractive candidates. The scanner contains no entries, exits, stop-loss orders, or backtest statistics. Scan history and data availability depend on aggregation. Stock Hacker custom study filters require exactly one plot and do not support secondary aggregation.
Before trading, review support, nearby resistance, earnings events, spread and position sizing. A hypothetical $51 entry and $49 invalidation imply $2 planned risk per share before slippage; a $200 risk allowance would suggest no more than 100 shares before commissions and gaps. For tailored platform studies, see Custom Trading Software Development Services.
Risk notice: This educational scanner is not investment advice or a verified profitable strategy. Gaps may exceed planned losses. Independently validate all calculations and behavior in your own platform.