Identify Gap-Up Pattern

shakib3585

Active member
Hello All,

I am requesting a ThinkScript code to
  • identify a candle where the low of the candle two positions ahead has a gap up from the high of the current candle.
  • The identified candle should be marked with a downward arrow, and
  • this script should be applicable to any aggregation period.

I have attached an image showing that candle 3 has a "low" price value that is higher than the "high" price value of candle 1. Also, they have a "gap" between them. If this condition is met, I would like to request a script that places an arrow pointing to candle 1, which has a "high" price value lower than and gapped from the "low" price value of the candle positioned two candles ahead (candle 3). This should be applicable at any aggregation period

1716361745578.png

Thank you in advance
 
Last edited:
Solution
Hello All,

I am requesting a ThinkScript code to
  • identify a candle where the low of the candle two positions ahead has a gap up from the high of the current candle.
  • The identified candle should be marked with a downward arrow, and
  • this script should be applicable to any aggregation period.

I have attached an image showing that candle 3 has a "low" price value that is higher than the "high" price value of candle 1. Also, they have a "gap" between them. If this condition is met, I would like to request a script that places an arrow pointing to candle 1, which has a "high" price value lower than and gapped from the "low" price value of the candle positioned two candles ahead (candle 3). This should be applicable at...
Hello All,

I am requesting a ThinkScript code to
  • identify a candle where the low of the candle two positions ahead has a gap up from the high of the current candle.
  • The identified candle should be marked with a downward arrow, and
  • this script should be applicable to any aggregation period.

I have attached an image showing that candle 3 has a "low" price value that is higher than the "high" price value of candle 1. Also, they have a "gap" between them. If this condition is met, I would like to request a script that places an arrow pointing to candle 1, which has a "high" price value lower than and gapped from the "low" price value of the candle positioned two candles ahead (candle 3). This should be applicable at any aggregation period


Thank you in advance

Code:
# gap_future_xbars
#https://usethinkscript.com/threads/identify-gap-up-pattern.18790/
#Identify Gap-Up Pattern
def na = double.nan;
def bn = barnumber();

input gap_future_bars = 2;

def isgap = if isnan(getvalue(low, -gap_future_bars)) then 0
 else if getvalue(low, -gap_future_bars) > high then 1
 else 0;

def y = 1.0004;
plot arrow = if isgap then high * y else na;
arrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow.SetDefaultColor(Color.green);
arrow.setlineweight(3);
arrow.hidebubble();
#
 
Solution

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

Code:
# gap_future_xbars
#https://usethinkscript.com/threads/identify-gap-up-pattern.18790/
#Identify Gap-Up Pattern
def na = double.nan;
def bn = barnumber();

input gap_future_bars = 2;

def isgap = if isnan(getvalue(low, -gap_future_bars)) then 0
 else if getvalue(low, -gap_future_bars) > high then 1
 else 0;

def y = 1.0004;
plot arrow = if isgap then high * y else na;
arrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow.SetDefaultColor(Color.green);
arrow.setlineweight(3);
arrow.hidebubble();
#
Thanks much, @halcyonguy. Two more requests, please.

1) Can you please plot a green cloud within the "gap" to represent a "bullish" sentiment?

2) Using the same method, but if there's a downward "gap" ,could you color the cloud red to indicate a "bearish" sentiment?

Thank you so much
 
Thanks much, @halcyonguy. Two more requests, please.

1) Can you please plot a green cloud within the "gap" to represent a "bullish" sentiment?

2) Using the same method, but if there's a downward "gap" ,could you color the cloud red to indicate a "bearish" sentiment?

Thank you so much
1 - yes
2 - yes
but , when programming, you have to think about worst cases.
what if there are 3 up gaps in a row? just drawing lines and clouds , on each bar the lines would be shifted up to the next gap values.
how do you draw multiple, overlapping horizontal lines, spanning 3+ bars?
you have to keep track of a lot of variables
..
working on something
in the meantime, think about you next questions
 
The author states:
The reason I am going for the gaps between three bars only is because I saw the strategy "The Fair Value Gap" theory and I found it helpful. So, I wanted to see how well it works for trading. Thank you so much for your precious time!

here you go
add down gap signals
i set the offset to be 2, so it looks at 3 bar groups and checks for a gap between the 1st and 3rd bars.
add horizontal lines and clouds, in the gap areas.
(count gaps and draw with multiple plots, so the clouds of adjacent gaps don't interact)
changed the arrows to point in the direction of gaps. they appear on 1st bar.
can turn arrows off

https://usethinkscript.com/threads/identify-gap-up-pattern-for-thinkorswim.20299/
1716478188955.png
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
218 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.
Back
Top