identify bar just before a strong move up or down

Wockets

Member

JxjIUlx.jpg



Is it possible for a study to be created to identify a pair of bars where the second bar has a strong move up / down?

then draw 2 lines towards the right from the open of the previous bar and from the low/ high of the previous bar.

the body of the previous candle should be small. (about 20% smaller than the difference of highlow.

code from blastoff trigger :

input trig = 20;

def val = absValue(close - open);
def range = high - low;
def blastOffVal = (val / range) * 100;

the difference between the high low of the second candle should be at least twice the difference between the previous candle's high low.

the second candle should be closing way higher or way lower than the previous candle
 

JxjIUlx.jpg



Is it possible for a study to be created to identify a pair of bars where the second bar has a strong move up / down?

then draw 2 lines towards the right from the open of the previous bar and from the low/ high of the previous bar.

the body of the previous candle should be small. (about 20% smaller than the difference of highlow.

code from blastoff trigger :

input trig = 20;

def val = absValue(close - open);
def range = high - low;
def blastOffVal = (val / range) * 100;

the difference between the high low of the second candle should be at least twice the difference between the previous candle's high low.

the second candle should be closing way higher or way lower than the previous candle

Hopefully this gets you started.

The percent input is to help def 'way higher or way lower'.

Capture.jpg
Ruby:
input showcloud = yes;
input percent   = .1;

#Up =====================================================================
def blastoffup = if ((high - low) > (high[1] - low[1]) * 2) and
                      close >= open and
                      close > high[1] and 
                      close > close[1] * (1 + percent / 100) then 1 else 0;

def hup        = if blastoffup then high[1] else hup[1];

plot hblastup  = hup;
hblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastup.SetDefaultColor(Color.GREEN);

def lup        = if blastoffup then low[1] else lup[1];
plot lblastup  = lup;
lblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastup.SetDefaultColor(Color.GREEN);

AddCloud(if showcloud and hblastup then hblastup else Double.NaN, lblastup, Color.GREEN, Color.GREEN);

#Down ===============================================================
def blastoffdn = if ((high - low) > (high[1] - low[1]) * 2) and
                      close < open  and
                      close < close[1] * (1 + percent / 100) then 1 else 0;

def hdn        = if blastoffdn then high[1] else hdn[1];

plot hblastdn  = hdn;
hblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastdn.SetDefaultColor(Color.RED);

def ldn        = if blastoffdn then low[1] else ldn[1];

plot lblastdn  = ldn;
lblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastdn.SetDefaultColor(Color.RED);

AddCloud(if showcloud and lblastup then hblastdn else Double.NaN, lblastdn, Color.RED, Color.RED);
 

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

#Credits to : SleepyZ from https://usethinkscript.com/threads/identify-bar-just-before-a-strong-move-up-or-down.12605/
input showcloud = yes;
input percent = .1;
input change = 2.5;
#Up =====================================================================
# if the current candle is more than twice the previous's candle , current candle is green , and closes above the previous
def blastoffup = if ((high - low) > (high[1] - low[1]) * change) and
close >= open and
#close > high[1] and
close > close[1] * (1 + percent / 100) then 1 else 0;
#if it is a blastup , for green candles , I would take the close , for red candles , I would take the open
def topline = if (close[1]> open[1]) then close[1] else open[1];
#plotting the top horizontal line
#I got no idea why there is a need for hup[1] , just leave it there
def hup = if blastoffup then topline else hup[1];
#plotting higher Horizontal lines
plot hblastup = hup;
hblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastup.SetDefaultColor(Color.GREEN);
#when it is a blastup , the botttom line will always be the bottom of the wick
def lup = if blastoffup then low[1] else lup[1];
plot lblastup = lup;
lblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastup.SetDefaultColor(Color.GREEN);

AddCloud(if showcloud and hblastup then hblastup else Double.NaN, lblastup, Color.GREEN, Color.GREEN);

#Down ===============================================================
def blastoffdn = if ((high - low) > (high[1] - low[1]) * change) and
close < open and
close < close[1] * (1 + percent / 100) then 1 else 0;

def bottomline = if (close[1] < open[1] ) then close[1] else open[1];
def hdn = if blastoffdn then bottomline else hdn[1];

plot hblastdn = hdn;
hblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastdn.SetDefaultColor(Color.RED);

def ldn = if blastoffdn then high[1] else ldn[1];

plot lblastdn = ldn;
lblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastdn.SetDefaultColor(Color.RED);

AddCloud(if showcloud and lblastup then hblastdn else Double.NaN, lblastdn, Color.RED, Color.RED);

The concept is there , I probably only need to mess around with the definition of blastoffup and blastoffdn from here , ty sir @SleepyZ
 
Last edited:
There are stray lines at the bottom of the graph sometimes though , any idea why

The following should remove the stray lines likely caused by using a prior bar needed at the beginning (eg: high[1]) did not exist.

The hup[1] (lup[1],hdn[1] and ldn[1 as well) ]is a recursive and is needed to plot the extended horizontal lines. Otherwise, the plot would be over just the 2 blastoff bars.

Ruby:
#Credits to : SleepyZ from https://usethinkscript.com/threads/identify-bar-just-before-a-strong-move-up-or-down.12605/
input showcloud = yes;
input percent = .1;
input change = 2.5;
#Up =====================================================================
# if the current candle is more than twice the previous's candle , current candle is green , and closes above the previous
def blastoffup = if ((high - low) > (high[1] - low[1]) * change) and
close >= open and
#close > high[1] and
close > close[1] * (1 + percent / 100) then 1 else 0;
#if it is a blastup , for green candles , I would take the close , for red candles , I would take the open
def topline = if (close[1] > open[1]) then close[1] else open[1];
#plotting the top horizontal line
#I got no idea why there is a need for hup[1] , just leave it there
def hup = if blastoffup then topline else hup[1];
#plotting higher Horizontal lines
plot hblastup = if hup==0 then double.nan else hup;
hblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastup.SetDefaultColor(Color.GREEN);
#when it is a blastup , the botttom line will always be the bottom of the wick
def lup = if blastoffup then low[1] else lup[1];
plot lblastup = if lup==0 then double.nan else lup;
lblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastup.SetDefaultColor(Color.GREEN);

AddCloud(if showcloud and hblastup then hblastup else Double.NaN, lblastup, Color.GREEN, Color.GREEN);

#Down ===============================================================
def blastoffdn = if ((high - low) > (high[1] - low[1]) * change) and
close < open and
close < close[1] * (1 + percent / 100) then 1 else 0;

def bottomline = if (close[1] < open[1] ) then close[1] else open[1];
def hdn = if blastoffdn then bottomline else hdn[1];

plot hblastdn = if hdn==0 then double.nan else hdn;
hblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastdn.SetDefaultColor(Color.RED);

def ldn = if blastoffdn then high[1] else ldn[1];

plot lblastdn = if ldn==0 then double.nan else ldn;
lblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastdn.SetDefaultColor(Color.RED);

AddCloud(if showcloud and lblastup then hblastdn else Double.NaN, lblastdn, Color.RED, Color.RED);
 
#Credits to : SleepyZ from https://usethinkscript.com/threads/identify-bar-just-before-a-strong-move-up-or-down.12605/
input showcloud = yes;
input percent = .1;
input change = 2.5;
#Up =====================================================================
# if the current candle is more than twice the previous's candle , current candle is green , and closes above the previous
def blastoffup = if ((high - low) > (high[1] - low[1]) * change) and
close >= open and
#close > high[1] and
close > close[1] * (1 + percent / 100) then 1 else 0;
#if it is a blastup , for green candles , I would take the close , for red candles , I would take the open
def topline = if (close[1]> open[1]) then close[1] else open[1];
#plotting the top horizontal line
#I got no idea why there is a need for hup[1] , just leave it there
def hup = if blastoffup then topline else hup[1];
#plotting higher Horizontal lines
plot hblastup = hup;
hblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastup.SetDefaultColor(Color.GREEN);
#when it is a blastup , the botttom line will always be the bottom of the wick
def lup = if blastoffup then low[1] else lup[1];
plot lblastup = lup;
lblastup.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastup.SetDefaultColor(Color.GREEN);

AddCloud(if showcloud and hblastup then hblastup else Double.NaN, lblastup, Color.GREEN, Color.GREEN);

#Down ===============================================================
def blastoffdn = if ((high - low) > (high[1] - low[1]) * change) and
close < open and
close < close[1] * (1 + percent / 100) then 1 else 0;

def bottomline = if (close[1] < open[1] ) then close[1] else open[1];
def hdn = if blastoffdn then bottomline else hdn[1];

plot hblastdn = hdn;
hblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hblastdn.SetDefaultColor(Color.RED);

def ldn = if blastoffdn then high[1] else ldn[1];

plot lblastdn = ldn;
lblastdn.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lblastdn.SetDefaultColor(Color.RED);

AddCloud(if showcloud and lblastup then hblastdn else Double.NaN, lblastdn, Color.RED, Color.RED);

The concept is there , I probably only need to mess around with the definition of blastoffup and blastoffdn from here , ty sir @SleepyZ
Pretty cool, I like it, thanks.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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