Exhaustion Gap Reversal for ThinkorSwim

BenTen

Administrative
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:

We1AdI4.png


R5jYQnP.png


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:

29TSVkY.png


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:

Tradervic

Member
VIP
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:

BenTen

Administrative
Staff member
Staff
VIP
@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.
 

Similar threads

Top