Identify Gap-Up Pattern

shakib3585

Active member
VIP
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
 
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

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


Code:
# gap_future_xbars_02

#https://usethinkscript.com/threads/identify-gap-up-pattern.18790/
#Identify Gap-Up Pattern
#identify a candle where the low of the candle two positions ahead has a gap up from the high of the current candle.

def na = double.nan;
def bn = barnumber();

def gap_bar_offset = 2;

def uptop = getvalue(low, -gap_bar_offset);
def upbot = high;
def dwntop = low;
def dwnbot = getvalue(high, -gap_bar_offset);

def isgapup = if isnan(uptop) then 0
 else if uptop > high then 1
 else 0;

def isgapdwn = if isnan(dwnbot) then 0
 else if dwnbot < low then 1
 else 0;

def y = 0.0004;
input arrows = yes;
plot zup = if arrows and isgapdwn then (high * (1+y)) else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zup.SetDefaultColor(Color.red);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if arrows and isgapup then (low * (1-y)) else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zdwn.SetDefaultColor(Color.green);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-----------------------
#  up gaps

# count all up gaps
def upcnt = if bn == 1 then 0 else if isgapup then upcnt[1] + 1 else upcnt[1];

# look at gap ups between first and last bars, in a 3 bar group
# since 3 bars, need 3+1 lines , so the 1st and 3rd lines don't diagonally connect
# create true signals for 4 counters.  compare remainders
def upcnt1 = (upcnt % 4) == 0; 
def upcnt2 = (upcnt % 4) == 1; 
def upcnt3 = (upcnt % 4) == 2; 
def upcnt4 = (upcnt % 4) == 3; 

def u1startbn = if upcnt[1] != upcnt and upcnt1 then bn else u1startbn[1];
def u1stopbn = if upcnt[1] != upcnt and upcnt1 then bn+gap_bar_offset else u1stopbn[1];

def u2startbn = if upcnt[1] != upcnt and upcnt2 then bn else u2startbn[1];
def u2stopbn = if upcnt[1] != upcnt and upcnt2 then bn+gap_bar_offset else u2stopbn[1];

def u3startbn = if upcnt[1] != upcnt and upcnt3 then bn else u3startbn[1];
def u3stopbn = if upcnt[1] != upcnt and upcnt3 then bn+gap_bar_offset else u3stopbn[1];

def u4startbn = if upcnt[1] != upcnt and upcnt4 then bn else u4startbn[1];
def u4stopbn = if upcnt[1] != upcnt and upcnt4 then bn+gap_bar_offset else u4stopbn[1];


def u1top = if u1startbn[1] != u1startbn then uptop
 else if bn >= u1startbn and bn <= u1stopbn then u1top[1]
 else na;
def u1bot = if u1stopbn[1] != u1stopbn then upbot
 else if bn >= u1startbn and bn <= u1stopbn then u1bot[1]
 else na;

def u2top = if u2startbn[1] != u2startbn then uptop
 else if bn >= u2startbn and bn <= u2stopbn then u2top[1]
 else na;
def u2bot = if u2stopbn[1] != u2stopbn then upbot
 else if bn >= u2startbn and bn <= u2stopbn then u2bot[1]
 else na;

def u3top = if u3startbn[1] != u3startbn then uptop
 else if bn >= u3startbn and bn <= u3stopbn then u3top[1]
 else na;
def u3bot = if u3stopbn[1] != u3stopbn then upbot
 else if bn >= u3startbn and bn <= u3stopbn then u3bot[1]
 else na;

def u4top = if u4startbn[1] != u4startbn then uptop
 else if bn >= u4startbn and bn <= u4stopbn then u4top[1]
 else na;
def u4bot = if u4stopbn[1] != u4stopbn then upbot
 else if bn >= u4startbn and bn <= u4stopbn then u4bot[1]
 else na;


plot z1u = u1top;
z1u.SetPaintingStrategy(PaintingStrategy.LINE);
z1u.SetDefaultColor(Color.green);
#z1u.setlineweight(1);
z1u.hidebubble();
plot z2u = u1bot;
z2u.SetPaintingStrategy(PaintingStrategy.LINE);
z2u.SetDefaultColor(Color.green);
#z2u.setlineweight(1);
z2u.hidebubble();

plot z3u = u2top;
z3u.SetPaintingStrategy(PaintingStrategy.LINE);
z3u.SetDefaultColor(Color.green);
#z4u.setlineweight(1);
z3u.hidebubble();
plot z4u = u2bot;
z4u.SetPaintingStrategy(PaintingStrategy.LINE);
z4u.SetDefaultColor(Color.green);
#z4u.setlineweight(1);
z4u.hidebubble();

plot z5u = u3top;
z5u.SetPaintingStrategy(PaintingStrategy.LINE);
z5u.SetDefaultColor(Color.green);
#z5u.setlineweight(1);
z5u.hidebubble();
plot z6u = u3bot;
z6u.SetPaintingStrategy(PaintingStrategy.LINE);
z6u.SetDefaultColor(Color.green);
#z6u.setlineweight(1);
z6u.hidebubble();

plot z7u = u4top;
z7u.SetPaintingStrategy(PaintingStrategy.LINE);
z7u.SetDefaultColor(Color.green);
#z7u.setlineweight(1);
z7u.hidebubble();
plot z8u = u4bot;
z8u.SetPaintingStrategy(PaintingStrategy.LINE);
z8u.SetDefaultColor(Color.green);
#z8u.setlineweight(1);
z8u.hidebubble();

addcloud(z1u,z2u,color.green);
addcloud(z3u,z4u,color.green);
addcloud(z5u,z6u,color.green);
addcloud(z7u,z8u,color.green);


#-----------------------
#  down gaps

# count all up gaps
def dwncnt = if bn == 1 then 0 else if isgapdwn then dwncnt[1] + 1 else dwncnt[1];

# look at gap downs between first and last bars, in a 3 bar group
# since 3 bars, need 3+1 lines , so the 1st and 3rd lines don't diagonally connect
# create true signals for 4 counters.  compare remainders
def dwncnt1 = (dwncnt % 4) == 0; 
def dwncnt2 = (dwncnt % 4) == 1; 
def dwncnt3 = (dwncnt % 4) == 2; 
def dwncnt4 = (dwncnt % 4) == 3; 

def d1startbn = if dwncnt[1] != dwncnt and dwncnt1 then bn else d1startbn[1];
def d1stopbn = if dwncnt[1] != dwncnt and dwncnt1 then bn+gap_bar_offset else d1stopbn[1];

def d2startbn = if dwncnt[1] != dwncnt and dwncnt2 then bn else d2startbn[1];
def d2stopbn = if dwncnt[1] != dwncnt and dwncnt2 then bn+gap_bar_offset else d2stopbn[1];

def d3startbn = if dwncnt[1] != dwncnt and dwncnt3 then bn else d3startbn[1];
def d3stopbn = if dwncnt[1] != dwncnt and dwncnt3 then bn+gap_bar_offset else d3stopbn[1];

def d4startbn = if dwncnt[1] != dwncnt and dwncnt4 then bn else d4startbn[1];
def d4stopbn = if dwncnt[1] != dwncnt and dwncnt4 then bn+gap_bar_offset else d4stopbn[1];


def d1top = if d1startbn[1] != d1startbn then dwntop
 else if bn >= d1startbn and bn <= d1stopbn then d1top[1]
 else na;
def d1bot = if d1stopbn[1] != d1stopbn then dwnbot
 else if bn >= d1startbn and bn <= d1stopbn then d1bot[1]
 else na;

def d2top = if d2startbn[1] != d2startbn then dwntop
 else if bn >= d2startbn and bn <= d2stopbn then d2top[1]
 else na;
def d2bot = if d2stopbn[1] != d2stopbn then dwnbot
 else if bn >= d2startbn and bn <= d2stopbn then d2bot[1]
 else na;

def d3top = if d3startbn[1] != d3startbn then dwntop
 else if bn >= d3startbn and bn <= d3stopbn then d3top[1]
 else na;
def d3bot = if d3stopbn[1] != d3stopbn then dwnbot
 else if bn >= d3startbn and bn <= d3stopbn then d3bot[1]
 else na;

def d4top = if d4startbn[1] != d4startbn then dwntop
 else if bn >= d4startbn and bn <= d4stopbn then d4top[1]
 else na;
def d4bot = if d4stopbn[1] != d4stopbn then dwnbot
 else if bn >= d4startbn and bn <= d4stopbn then d4bot[1]
 else na;


plot z1d = d1top;
z1d.SetPaintingStrategy(PaintingStrategy.LINE);
z1d.SetDefaultColor(Color.red);
#z1d.setlineweight(1);
z1d.hidebubble();
plot z2d = d1bot;
z2d.SetPaintingStrategy(PaintingStrategy.LINE);
z2d.SetDefaultColor(Color.red);
#z2d.setlineweight(1);
z2d.hidebubble();

plot z3d = d2top;
z3d.SetPaintingStrategy(PaintingStrategy.LINE);
z3d.SetDefaultColor(Color.red);
#z4d.setlineweight(1);
z3d.hidebubble();
plot z4d = d2bot;
z4d.SetPaintingStrategy(PaintingStrategy.LINE);
z4d.SetDefaultColor(Color.red);
#z4d.setlineweight(1);
z4d.hidebubble();

plot z5d = d3top;
z5d.SetPaintingStrategy(PaintingStrategy.LINE);
z5d.SetDefaultColor(Color.red);
#z5d.setlineweight(1);
z5d.hidebubble();
plot z6d = d3bot;
z6d.SetPaintingStrategy(PaintingStrategy.LINE);
z6d.SetDefaultColor(Color.red);
#z6d.setlineweight(1);
z6d.hidebubble();

plot z7d = d4top;
z7d.SetPaintingStrategy(PaintingStrategy.LINE);
z7d.SetDefaultColor(Color.red);
#z7d.setlineweight(1);
z7d.hidebubble();
plot z8d = d4bot;
z8d.SetPaintingStrategy(PaintingStrategy.LINE);
z8d.SetDefaultColor(Color.red);
#z8d.setlineweight(1);
z8d.hidebubble();

addcloud(z1d,z2d,color.red);
addcloud(z3d,z4d,color.red);
addcloud(z5d,z6d,color.red);
addcloud(z7d,z8d,color.red);


#-------------------------
# misc

#x.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

addchartbubble(0, low,
upcnt + " C\n" +
upcnt1 + "  1\n" +
upcnt2 + "  2\n" +
upcnt3 + "  3\n" + 
upcnt4 + "  4\n"
#bn  + "\n" +
#u1startbn + "\n" +
#u1stopbn + "\n" 
, color.yellow, no);
#
 

Attachments

  • 1716478188955.png
    1716478188955.png
    49.9 KB · Views: 155
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


Code:
# gap_future_xbars_02

#https://usethinkscript.com/threads/identify-gap-up-pattern.18790/
#Identify Gap-Up Pattern
#identify a candle where the low of the candle two positions ahead has a gap up from the high of the current candle.

def na = double.nan;
def bn = barnumber();

def gap_bar_offset = 2;

def uptop = getvalue(low, -gap_bar_offset);
def upbot = high;
def dwntop = low;
def dwnbot = getvalue(high, -gap_bar_offset);

def isgapup = if isnan(uptop) then 0
 else if uptop > high then 1
 else 0;

def isgapdwn = if isnan(dwnbot) then 0
 else if dwnbot < low then 1
 else 0;

def y = 0.0004;
input arrows = yes;
plot zup = if arrows and isgapdwn then (high * (1+y)) else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zup.SetDefaultColor(Color.red);
zup.setlineweight(3);
zup.hidebubble();

plot zdwn = if arrows and isgapup then (low * (1-y)) else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zdwn.SetDefaultColor(Color.green);
zdwn.setlineweight(3);
zdwn.hidebubble();


#-----------------------
#  up gaps

# count all up gaps
def upcnt = if bn == 1 then 0 else if isgapup then upcnt[1] + 1 else upcnt[1];

# look at gap ups between first and last bars, in a 3 bar group
# since 3 bars, need 3+1 lines , so the 1st and 3rd lines don't diagonally connect
# create true signals for 4 counters.  compare remainders
def upcnt1 = (upcnt % 4) == 0;
def upcnt2 = (upcnt % 4) == 1;
def upcnt3 = (upcnt % 4) == 2;
def upcnt4 = (upcnt % 4) == 3;

def u1startbn = if upcnt[1] != upcnt and upcnt1 then bn else u1startbn[1];
def u1stopbn = if upcnt[1] != upcnt and upcnt1 then bn+gap_bar_offset else u1stopbn[1];

def u2startbn = if upcnt[1] != upcnt and upcnt2 then bn else u2startbn[1];
def u2stopbn = if upcnt[1] != upcnt and upcnt2 then bn+gap_bar_offset else u2stopbn[1];

def u3startbn = if upcnt[1] != upcnt and upcnt3 then bn else u3startbn[1];
def u3stopbn = if upcnt[1] != upcnt and upcnt3 then bn+gap_bar_offset else u3stopbn[1];

def u4startbn = if upcnt[1] != upcnt and upcnt4 then bn else u4startbn[1];
def u4stopbn = if upcnt[1] != upcnt and upcnt4 then bn+gap_bar_offset else u4stopbn[1];


def u1top = if u1startbn[1] != u1startbn then uptop
 else if bn >= u1startbn and bn <= u1stopbn then u1top[1]
 else na;
def u1bot = if u1stopbn[1] != u1stopbn then upbot
 else if bn >= u1startbn and bn <= u1stopbn then u1bot[1]
 else na;

def u2top = if u2startbn[1] != u2startbn then uptop
 else if bn >= u2startbn and bn <= u2stopbn then u2top[1]
 else na;
def u2bot = if u2stopbn[1] != u2stopbn then upbot
 else if bn >= u2startbn and bn <= u2stopbn then u2bot[1]
 else na;

def u3top = if u3startbn[1] != u3startbn then uptop
 else if bn >= u3startbn and bn <= u3stopbn then u3top[1]
 else na;
def u3bot = if u3stopbn[1] != u3stopbn then upbot
 else if bn >= u3startbn and bn <= u3stopbn then u3bot[1]
 else na;

def u4top = if u4startbn[1] != u4startbn then uptop
 else if bn >= u4startbn and bn <= u4stopbn then u4top[1]
 else na;
def u4bot = if u4stopbn[1] != u4stopbn then upbot
 else if bn >= u4startbn and bn <= u4stopbn then u4bot[1]
 else na;


plot z1u = u1top;
z1u.SetPaintingStrategy(PaintingStrategy.LINE);
z1u.SetDefaultColor(Color.green);
#z1u.setlineweight(1);
z1u.hidebubble();
plot z2u = u1bot;
z2u.SetPaintingStrategy(PaintingStrategy.LINE);
z2u.SetDefaultColor(Color.green);
#z2u.setlineweight(1);
z2u.hidebubble();

plot z3u = u2top;
z3u.SetPaintingStrategy(PaintingStrategy.LINE);
z3u.SetDefaultColor(Color.green);
#z4u.setlineweight(1);
z3u.hidebubble();
plot z4u = u2bot;
z4u.SetPaintingStrategy(PaintingStrategy.LINE);
z4u.SetDefaultColor(Color.green);
#z4u.setlineweight(1);
z4u.hidebubble();

plot z5u = u3top;
z5u.SetPaintingStrategy(PaintingStrategy.LINE);
z5u.SetDefaultColor(Color.green);
#z5u.setlineweight(1);
z5u.hidebubble();
plot z6u = u3bot;
z6u.SetPaintingStrategy(PaintingStrategy.LINE);
z6u.SetDefaultColor(Color.green);
#z6u.setlineweight(1);
z6u.hidebubble();

plot z7u = u4top;
z7u.SetPaintingStrategy(PaintingStrategy.LINE);
z7u.SetDefaultColor(Color.green);
#z7u.setlineweight(1);
z7u.hidebubble();
plot z8u = u4bot;
z8u.SetPaintingStrategy(PaintingStrategy.LINE);
z8u.SetDefaultColor(Color.green);
#z8u.setlineweight(1);
z8u.hidebubble();

addcloud(z1u,z2u,color.green);
addcloud(z3u,z4u,color.green);
addcloud(z5u,z6u,color.green);
addcloud(z7u,z8u,color.green);


#-----------------------
#  down gaps

# count all up gaps
def dwncnt = if bn == 1 then 0 else if isgapdwn then dwncnt[1] + 1 else dwncnt[1];

# look at gap downs between first and last bars, in a 3 bar group
# since 3 bars, need 3+1 lines , so the 1st and 3rd lines don't diagonally connect
# create true signals for 4 counters.  compare remainders
def dwncnt1 = (dwncnt % 4) == 0;
def dwncnt2 = (dwncnt % 4) == 1;
def dwncnt3 = (dwncnt % 4) == 2;
def dwncnt4 = (dwncnt % 4) == 3;

def d1startbn = if dwncnt[1] != dwncnt and dwncnt1 then bn else d1startbn[1];
def d1stopbn = if dwncnt[1] != dwncnt and dwncnt1 then bn+gap_bar_offset else d1stopbn[1];

def d2startbn = if dwncnt[1] != dwncnt and dwncnt2 then bn else d2startbn[1];
def d2stopbn = if dwncnt[1] != dwncnt and dwncnt2 then bn+gap_bar_offset else d2stopbn[1];

def d3startbn = if dwncnt[1] != dwncnt and dwncnt3 then bn else d3startbn[1];
def d3stopbn = if dwncnt[1] != dwncnt and dwncnt3 then bn+gap_bar_offset else d3stopbn[1];

def d4startbn = if dwncnt[1] != dwncnt and dwncnt4 then bn else d4startbn[1];
def d4stopbn = if dwncnt[1] != dwncnt and dwncnt4 then bn+gap_bar_offset else d4stopbn[1];


def d1top = if d1startbn[1] != d1startbn then dwntop
 else if bn >= d1startbn and bn <= d1stopbn then d1top[1]
 else na;
def d1bot = if d1stopbn[1] != d1stopbn then dwnbot
 else if bn >= d1startbn and bn <= d1stopbn then d1bot[1]
 else na;

def d2top = if d2startbn[1] != d2startbn then dwntop
 else if bn >= d2startbn and bn <= d2stopbn then d2top[1]
 else na;
def d2bot = if d2stopbn[1] != d2stopbn then dwnbot
 else if bn >= d2startbn and bn <= d2stopbn then d2bot[1]
 else na;

def d3top = if d3startbn[1] != d3startbn then dwntop
 else if bn >= d3startbn and bn <= d3stopbn then d3top[1]
 else na;
def d3bot = if d3stopbn[1] != d3stopbn then dwnbot
 else if bn >= d3startbn and bn <= d3stopbn then d3bot[1]
 else na;

def d4top = if d4startbn[1] != d4startbn then dwntop
 else if bn >= d4startbn and bn <= d4stopbn then d4top[1]
 else na;
def d4bot = if d4stopbn[1] != d4stopbn then dwnbot
 else if bn >= d4startbn and bn <= d4stopbn then d4bot[1]
 else na;


plot z1d = d1top;
z1d.SetPaintingStrategy(PaintingStrategy.LINE);
z1d.SetDefaultColor(Color.red);
#z1d.setlineweight(1);
z1d.hidebubble();
plot z2d = d1bot;
z2d.SetPaintingStrategy(PaintingStrategy.LINE);
z2d.SetDefaultColor(Color.red);
#z2d.setlineweight(1);
z2d.hidebubble();

plot z3d = d2top;
z3d.SetPaintingStrategy(PaintingStrategy.LINE);
z3d.SetDefaultColor(Color.red);
#z4d.setlineweight(1);
z3d.hidebubble();
plot z4d = d2bot;
z4d.SetPaintingStrategy(PaintingStrategy.LINE);
z4d.SetDefaultColor(Color.red);
#z4d.setlineweight(1);
z4d.hidebubble();

plot z5d = d3top;
z5d.SetPaintingStrategy(PaintingStrategy.LINE);
z5d.SetDefaultColor(Color.red);
#z5d.setlineweight(1);
z5d.hidebubble();
plot z6d = d3bot;
z6d.SetPaintingStrategy(PaintingStrategy.LINE);
z6d.SetDefaultColor(Color.red);
#z6d.setlineweight(1);
z6d.hidebubble();

plot z7d = d4top;
z7d.SetPaintingStrategy(PaintingStrategy.LINE);
z7d.SetDefaultColor(Color.red);
#z7d.setlineweight(1);
z7d.hidebubble();
plot z8d = d4bot;
z8d.SetPaintingStrategy(PaintingStrategy.LINE);
z8d.SetDefaultColor(Color.red);
#z8d.setlineweight(1);
z8d.hidebubble();

addcloud(z1d,z2d,color.red);
addcloud(z3d,z4d,color.red);
addcloud(z5d,z6d,color.red);
addcloud(z7d,z8d,color.red);


#-------------------------
# misc

#x.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

addchartbubble(0, low,
upcnt + " C\n" +
upcnt1 + "  1\n" +
upcnt2 + "  2\n" +
upcnt3 + "  3\n" +
upcnt4 + "  4\n"
#bn  + "\n" +
#u1startbn + "\n" +
#u1stopbn + "\n"
, color.yellow, no);
#
Thank you, @halcyonguy . 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!
 
One change, please @halcyonguy. I noticed there are some price candles which have equal open, high, low and close prices (attached is an image with lime colored box), Can you please omit such candles from your code so they are not included in the strategy. Apologies for poking you again

bump
 

Attachments

  • 1716564165884.png
    1716564165884.png
    46.6 KB · Views: 112
  • image.png
    image.png
    31.4 KB · Views: 104
Last edited by a moderator:
Nice script guys. This is the exact concept I need however, @halcyonguy any chance this can be changed to reference Close to Open gaps on two candles (last and current candles)? I have tried to change the code myself but can't get it to work on either or both the two candle time frame plus prior candle close to current candle open prices. And would it be possible to also have an option to turn the cloud on and off? Any help with this would be greatly appreciated.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
379 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