# Exhaustion Gap Reversal for ThinkorSwim

#### BenTen

Staff member
Staff
VIP
The concept of this indicator is simple. We look for exhaustion in gap up and gap down. Look for potential trade ideas the following day.
• Stock gapped up but ended the day red. This indicates a potential bearish move.
• Stock gapped down but ended the day green. This indicates a potential bullish move.
Whenever there is a gap up or gap down, the indicator will also plot the day's high and low levels onto the next trading day. Remember, the idea of this indicator isn't to trade on the day of the gap but the following day. We want to know if there is enough momentum/pressure to maintain the direction of the gap. If there isn't, it means a potential reversal play is in place.

Some examples:

### thinkScript Code

Code:
``````# Exhaustion Gap Reversal
# Assembled by BenTen at UseThinkScript.com

input aggregationPeriod = AggregationPeriod.DAY;
def open = open(period = aggregationPeriod);
def close = close(period = aggregationPeriod);
def h1 = high(period = aggregationPeriod)[1];
def l1 = low(period = aggregationPeriod)[1];
def prev_close = close(period = aggregationPeriod)[1];

def o = open;
def c = prev_close;

def gu = o > c;
def gd = o < c;

def diff = o - c;
def av = (o + c) / 2;
def d = (diff / av) * 100;

def gapup = gu and d > 1;
def gapdown = gd and d < -1;

def IsUp = close > open;
def IsDown = close < open;

AssignPriceColor(if gapdown and isUp then color.green else if gapup and isdown then color.red else color.gray);

def condition = gapdown[1] and isUp[1] or gapup[1] and isdown[1];

plot preh = if condition then h1 else double.nan;
preh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot prel = if condition then l1 else double.nan;
prel.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);``````

### Scanner

Code:
``````# Exhaustion Gap Reversal
# Assembled by BenTen at UseThinkScript.com

input aggregationPeriod = AggregationPeriod.DAY;
def open = open(period = aggregationPeriod);
def close = close(period = aggregationPeriod);
def h1 = high(period = aggregationPeriod)[1];
def l1 = low(period = aggregationPeriod)[1];
def prev_close = close(period = aggregationPeriod)[1];

def o = open;
def c = prev_close;

def gu = o > c;
def gd = o < c;

def diff = o - c;
def av = (o + c) / 2;
def d = (diff / av) * 100;

def gapup = gu and d > 1;
def gapdown = gd and d < -1;

def IsUp = close > open;
def IsDown = close < open;

plot bullish = gapdown and isUp;
bullish.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_Up);
plot bearish = gapup and isdown;
bearish.SetPaintingStrategy(PaintingStrategy.Boolean_arrow_DOWN);``````

Add the script above as an indicator, then switch over to the Scan tab and set up your scanner to something like this:

The timeframe of your scanner should be set to D (Daily).

Keep in mind that this indicator does not specify the value of the gap. You may find some edge or increase your probability if you look for notable gap ups or gap downs. Small gaps tend to decrease the chance of a follow-through day. I hope that helps.

Last edited:
Hey Ben: Looks like a good indicator. Question on scanning. I setup the indicator using the Thinkscript Code and when I try to set up the scanner, under Plot, I only get two choices which is "preh, and prel". I don't see "bullish" like in your example. Am I missing something? You have the code for the scanner......am I supposed to use this? If so, how? Thanks in advance.
I also inserted your scanner code in the Thinkscript Editor in the scanner, but I get a message below saying "exactly one plot expected" and it won't let me click OK.

Last edited:
@Tradervic There are two separate scripts. I included them both in the thread above. Use the second script if you want to run it as your scanner.

How do u upload the scan code?

@APOT7 Add it as an indicator first. See the video below:

87k+ Posts
299 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?