Gap Up & Gap Down Scanner for ThinkorSwim


2019 Donor
Prior the the "orb scanner" I think this is great but how about a gap potential or open window of opportunity. I've used the previous day closing gap but rather difficult to use since what's done is done leads to a 50/50 chance trade for opening new wedge gap
ThinkorSwim already provide users with their own Gap up and Gap down scanners.



  • isXgMHL.png
    155 KB · Views: 261
@Likos the rules have changed on how Gaps work according to two former portfolio managers for William O'Neill and company. In this case, Google really IS your friend. Please search for "take the fear out of buying big gaps" that was published March 11, 2013 by Gil Morales and Dr. Chris Kacher.
They wrote more than one article but that is the only one that I have printed out. Sorry I don't have the name of the publication.

Also, see a website called Those two gentlemen might have some information on that site, as they are the ones that run it. On there they call them "BGU's". It will take some research but it's the only place I know of that has firm rules on purchasing Gap Ups.

After you have reviewed that, you will have better odds of winning on a trade using the scanner that @BenTen pointed to above.
Good investing, Markos
After you do your Pareto Analysis, good idea to put your links somewhere so that your helpers can send people to it. Apparently reading & watching "How to drive the scanner" is difficult to do. btw, excellent job with the video!
Thanks, Sir

Mr @BenTen, question Bookmarks, is the same as favorites? how to save my favorites post or scripts

If I want just scan for gaps up or down for the etf components: SPY, QQQ, DIA is possible? thanks
@wilmanv Please contact support and set up a time for your Free Tour. Have 10 questions written down to ask so that your particular questions get answered.

Also, please spend some time reading in our Tutorial Section. You will find many answers to your questions above.

Your question may have already been asked, please use the Search Box above to check that out.

Thanks, Markos
Last edited:
@wilmanv Bookmarking is like saving a comment or post.

Whatever ToS provides in their default scanner is what you can use. You can also create your own set of watchlist.
This is a pretty common setup but I'm not sure which TOS scan to use to find this potential set up through the morning.

I'm looking at a 5-minute chart. The image attached shows more detail. Price eventually doesn't make a new high on the next candle. Once that happens we are looking for consolidation candles of 3 or more without the price pulling back percentage X. This should alert me of stocks with this pattern.

Here are the rules.
1. Stock must have gapped up or down at least 1% from previous days close.
2. It doesn't take into account pre or post-market activity.
3. Many can consider this a bull or bear flag type of setup.
4. We are however looking for tight consolidation without too much pullback.


I'd appreciate anyone's input on this.

Last edited by a moderator:
Hi Guys,

I need help with building a gap up scanner and as well the opening range breakout scanner. I want those gap up stocks to go through opening range breakout as well(only stocks that appeared in gap up) to enter a long position. I have used the gap up scanner and opening range scanner combined from our site but nothing shows up in the scanner. Can i do it like that. Need help guys.
So I have this code that says need one defined plot when I upload it I was hoping that someone could help with this code and make it work

# choose to scan up down gaps
# 1 = Only up gaps
# 2 = Only down gaps
# 3 = BOTH up and down gaps

input GapDirection = 3;

#set min max gap size you would like.
input minimumPercentFromPriorClose = 1.0;
input minimumDollarsFromPriorClose = 1.0;
input MaximumPercentFromPriorClose = 100.0;
input MaximumDollarsFromPriorClose = 100.0;

# makes sure there is a gap between the currentprice and the prior High/low, not just from the prior close

input OutsideYesterdaysRange = no;

#Looks for only gaps that are gapping up over red candle or gapping downsideGapThreeMethods under green candle, in addition the other criteria, Some people believe this adds "shock value" and forces people to cover their positions, adding momentum in the direction of the gap.

input GapAboveRedOrBeLowGreen = no;

# choose to only look for gapsthat havent filled yet interday
input OnlyGapsThatHaventFilled = no;

# if set to yes then scan will only consider a gap to be filled id the current days price action has touch previous days close.
input GapIsOnlyFilledAtClose = yes;

#Only change these if you are dealing with special marketor know what your doing
input MarketOpenTime = 0930;
input MarketCloseTime = 1600;
Last edited by a moderator:
Thans. This is another problem I could not use these type of TOS link. Every time I click it asks me to install TOS in which already I have open in my computer. Is there any other way I can get the script or advise how to use this link while you already have TOS open. Thanks
Let me know anything that you find interesting about it, I use a 1 min chart with a 4 hour aggregation period

# Average Price Movements
# Assembled by BenTen at
# Converted from

input aggregationPeriod = AggregationPeriod.DAY;
def open = open(period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);
def dayrange = (high - low);

def r1 = dayrange[1];
def r2 = dayrange[2];
def r3 = dayrange[3];
def r4 = dayrange[4];
def r5 = dayrange[5];
def r6 = dayrange[6];
def r7 = dayrange[7];
def r8 = dayrange[8];
def r9 = dayrange[9];
def r10 = dayrange[10];

def adr_10 = (r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8 + r9 + r10) / 10;
def adr_5 = (r1 + r2 + r3 + r4 + r5) / 5;

def hl1 = (OPEN + (adr_10 / 2));
def ll1 = (OPEN - (adr_10 / 2));
def hl2 = (OPEN + (adr_5 / 2));
def ll2 = (OPEN - (adr_5 / 2));

plot h1 = hl1;
plot l1 = ll1;
plot h2 = hl2;
plot l2 = ll2;

addCloud(h1, h2, color.RED, color.RED);
addCloud(l1, l2, color.GREEN, color.GREEN);

K.O Trader, much respect to you!! Thanks for sharing the code too! The other component that we are looking for is the SCAN to find surging stocks in the first few minutes of opening of regular trading day toward either of the two "zones". There are too many stocks to search individually in the beginning of the trading day to do this manually. Is it possible to have a SCAN to bring to the forefront these surging stocks in the very start of the trading day???
K.O Trader, much respect to you!! Thanks for sharing the code too! The other component that we are looking for is the SCAN to find surging stocks in the first few minutes of opening of regular trading day toward either of the two "zones". There are too many stocks to search individually in the beginning of the trading day to do this manually. Is it possible to have a SCAN to bring to the forefront these surging stocks in the very start of the trading day???
I"m working on finding one, I will post it if/when I find one. BTW I've switched my aggregation period to 1WK. I believe this is the same stradegy that uses

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
349 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.