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.
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.
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.
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.
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.
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.
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.
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.
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.