Is This An Engulfing Indicator?

Lone Wolf

New member
Plus
Screenshot 2023-06-21 at 10.56.33 PM.png

If possible I would like to modify this so that the candle on the right shows an en engulfing candle as well.
 

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

View attachment 18959
I cant get any other code except this.

For some reason it doesn't show up in the study section for you to view the code.

if you don't know where to look for the study code, there is no point in altering a code for you. you need to do some studying.

why are you looking at a web page? are you using a built in study? what is the name?

regarding post1, we don't know what candle you are talking about,
candle on the right... right of what?

if the purple arrow is pointing at an engulfing candle, then it must be based on body size and have to be bigger than the previous one.
maybe the other candle has a top level equal to other candle , instead of greather than?
 
if you don't know where to look for the study code, there is no point in altering a code for you. you need to do some studying.

why are you looking at a web page? are you using a built in study? what is the name?

regarding post1, we don't know what candle you are talking about,
candle on the right... right of what?

if the purple arrow is pointing at an engulfing candle, then it must be based on body size and have to be bigger than the previous one.
maybe the other candle has a top level equal to other candle , instead of greather than?
for some reason it doesnt show up so that I can view the source code. I cant search for the indicator but I can only select it.
 
View attachment 18958
If possible I would like to modify this so that the candle on the right shows an en engulfing candle as well.
From what I can tell from this screenshot and your screenshot of the parameters, it looks like you're trying to use the "Engulfing" candlestick pattern that's built into TOS. If you right-click and select "view" on that study, you'll see this:


Code:
def BodyMax = Max(open, close);
def BodyMin = Min(open, close);
def IsEngulfing = BodyMax > BodyMax[1] and
    BodyMin < BodyMin[1];
def IsWhite = open < close;
def IsBlack = open > close;
def IsPrevDoji = IsDoji(length)[1];

plot Bearish = IsAscending(close, trendSetup)[1] and
    (IsWhite[1] or IsPrevDoji) and
    IsBlack and
    IsEngulfing;

plot Bullish = IsDescending(close, trendSetup)[1] and
    (IsBlack[1] or IsPrevDoji) and
    IsWhite and
    IsEngulfing;

If you look at the definition of the IsEngulfing parameter, it requires a bearish engulfing candle to have an open greater than the open of the previous candle, and a close lower than the previous close.

Your screenshot is very zoomed in so I can't tell for sure but it looks like the open of the engulfing candle that you want is lower than the open of the candle before it, which is why it's not getting flagged here. If you wanted to fix this, you'd have to copy the code in the study and adjust it yourself or look at some of the existing studies on this website that detect engulfing candles.
 
From what I can tell from this screenshot and your screenshot of the parameters, it looks like you're trying to use the "Engulfing" candlestick pattern that's built into TOS. If you right-click and select "view" on that study, you'll see this:


Code:
def BodyMax = Max(open, close);
def BodyMin = Min(open, close);
def IsEngulfing = BodyMax > BodyMax[1] and
    BodyMin < BodyMin[1];
def IsWhite = open < close;
def IsBlack = open > close;
def IsPrevDoji = IsDoji(length)[1];

plot Bearish = IsAscending(close, trendSetup)[1] and
    (IsWhite[1] or IsPrevDoji) and
    IsBlack and
    IsEngulfing;

plot Bullish = IsDescending(close, trendSetup)[1] and
    (IsBlack[1] or IsPrevDoji) and
    IsWhite and
    IsEngulfing;

If you look at the definition of the IsEngulfing parameter, it requires a bearish engulfing candle to have an open greater than the open of the previous candle, and a close lower than the previous close.

Your screenshot is very zoomed in so I can't tell for sure but it looks like the open of the engulfing candle that you want is lower than the open of the candle before it, which is why it's not getting flagged here. If you wanted to fix this, you'd have to copy the code in the study and adjust it yourself or look at some of the existing studies on this website that detect engulfing candles.
Screenshot 2023-06-22 at 11.37.11 AM.png

This is the only way i can find the engulfing study on my TOS.

It does not allow me to right click on it.

Additionally, when I drill down and try and search for the study, it does not show up.
Screenshot 2023-06-22 at 11.38.24 AM.png
 
under Patterns, select candlestick, find engulfing and you can then add it. It will show you an arrow like a study. also, you can copy the code and then in the scanner you paste it as a custom study
 
If possible I would like to modify this so that the candle on the right shows an en engulfing candle as well.

sorry if i came across a little aggressive in first post.

thanks to FSUTommy, i found the pattern code and studied it.
to answer your question, some bars are not marked as engulfing, because the study is looking at 3 additional conditions to the engulfing condition. if price levels are not smaller, then it did not mark it as engulfing.

i copied the pattern code and added some inputs to choose conditions to apply (in the plot formula).
with all 4 set to no, i think you will see what you expect, just the engulfing rule.

input engulfed_bars_have_to_be_smaller = no;
input use_rising_falling = no;
input use_white_black = no;
input use_PrevDoji = no;


Code:
# pattern_engulfing_code_01

#  add a pattern to a chart
# Patterns button
# .select patterns
# ..candlestick tab
# ...pick a pattern to apply to a chart (engulfing)

# pattern - engulfing code
# TD Ameritrade IP Company, Inc. (c) 2011-2023
#
#wizard plots
#wizard text: Inputs: length:
#wizard input: length
#wizard text: trend setup:
#wizard input: trendSetup

input length = 20;
input trendSetup = 3;

def BodyMax = Max(open, close);
def BodyMin = Min(open, close);
def IsEngulfing = BodyMax > BodyMax[1] and BodyMin < BodyMin[1];
def IsEngulfing2 = BodyMax >= BodyMax[1] and BodyMin <= BodyMin[1];
def IsWhite = open < close;
def IsBlack = open > close;
def IsPrevDoji = IsDoji(length)[1];

input engulfed_bars_have_to_be_smaller = no;
def engulf2 = if engulfed_bars_have_to_be_smaller then IsEngulfing else IsEngulfing2;

input use_rising_falling = no;
def rising = if use_rising_falling then IsAscending(close, trendSetup)[0] else 1;
def falling = if use_rising_falling then IsDescending(close, trendSetup)[0] else 1;

input use_white_black = no;
def white1 = if use_white_black then iswhite else 1;
def black1 = if use_white_black then isblack else 1;

input use_PrevDoji = no;
def PrevDoji = if use_PrevDoji then IsPrevDoji else 1;

#plot Bearish = IsAscending(close, trendSetup)[1] and
#    (IsWhite[1] or IsPrevDoji) and
#    IsBlack and
#    IsEngulfing;

#plot Bullish = IsDescending(close, trendSetup)[1] and
#    (IsBlack[1] or IsPrevDoji) and
#    IsWhite and
#    IsEngulfing;


plot Bearish = rising[1] and
    (White1[1] or PrevDoji) and
    Black1 and
    Engulf2;

plot Bullish = falling[1] and
    (Black1[1] or PrevDoji) and
    White1 and
    Engulf2;

Bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Bearish.SetDefaultColor(GetColor(1));
Bearish.SetLineWeight(2);
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Bullish.SetDefaultColor(GetColor(2));
Bullish.SetLineWeight(2);

addchartbubble(0, high*1.002,
 BodyMax  + "\n" +
 BodyMin + "\n" +
 IsEngulfing 
, color.yellow, yes);
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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