How to Create an Engulfing Candlestick Indicator

We’ll show here how easy it is to create a custom candlestick detector. For this example, we’ll create a simple indicator to detect engulfing patterns. An engulfing pattern is when a long rising or falling candlestick appears after a shorter one, and the top and bottom of the engulfing candle body is respectively above and below the shorter one.

To start, open the indicator builder by picking the Indicators tab from the top menu.

Now select MinN from the drop down menu.

Card image cap

Create a MinN operator with inputs open price and close price

The MinN operator gives the smallest of the two inputs. In this case, when the inputs are set to the open and close price, MinN will return the smaller of the two. This will be the bottom of the candlestick.

Next click the top row to select it. A red border should appear at either end. Now click the plus symbol (+) on the top tool bar. This will add a new row above.

Card image cap

Add a Less than above the top row.

Select the Less than operator from the drop down select box. Now click the row that says constant, and choose Array shift from the drop down box.

Card image cap

Set the input to Less than to Array shift.

The array shift will give us the earlier bar. The default shift is already set to 1 bar so this doesn’t need to be changed.

Now set the operand in the array shift to be the same as the MinN in the row above. To speed things up you can select the MinN row then click Copy from the top tool bar. Then click the row beneath the Array shift, the operand and click paste from the toolbar. The result should be similar to the screen above.

Card image cap

Save the work so far

Next click the disk icon to save what we’ve done so far. Enter a name of your choosing.

Once saved, we can test the result on a full-sized chart. Open a new chart, and select the name of the indicator from the drop down box and click to add it to the chart. The result should be something like the chart below.

Card image cap

Check the result on a candle chart

Taking a look at the chart above we can see that the indicator correctly picks out candles where the bottom of the candle body is below the body of the earlier candlestick. This is only half of the logic. We need to make sure that the top of the candle body is above the body of the earlier candlestick as well.

To do this, click the top row again and add a new row above. Set this operator to And.

Card image cap

Repeat the logic to check the candle top

Now add the same logic as above, but now we need to use a Greater than operator, and MaxN. This will check the top of each candle and make sure that it is above the top of the earlier one. The And operator is true only when both conditions are true.

Card image cap

Previewing the result by clicking preview in the top row

If we preview the competed logic, it should now mark out the engulfing candlesticks. Click the top row and add a new row above it. For the purpose of this example, we’ll set that to Sell. This will create a sell signal on each engulfing pattern.

Card image cap

Testing the engulfing detector

Now if we save the indicator again, by clicking the disk icon from the tool bar, this will complete the example. We can now test the final result on a full chart. This should look something like the chart above, depending on the symbol and timeframe you choose.

Use this Indicator

Risk Disclosure: Information given on this website is for general purposes only and should not be construed as investment advice. Certain instruments shown here are complex and may come with a high risk of losing money rapidly due to leverage. You should consider whether you understand how these instruments work and whether you can afford to take the high risk of losing your money. Market data displayed is indicative and is not a solicitation to buy or sell.