Code Your Own Bullish Engulfing Pattern Recognition Indicator.

Here is an example of an .mq4 code for an indicator that can find a Bullish Engulfing candle pattern within a chart.

This code provides a basic framework for detecting Bullish Engulfing candle patterns and showing them on a trading chart. It is important to thoroughly test and verify this custom indicator before using it in live trading.

You are welcome to modify and customized the below example to fit your specific trading strategy.

//+------------------------------------------------------------------+
//|                                             Bullish-Engulfing.mq4|
//|                                          Copyright 2023, Richpips|
//|                                        https://www.richpips.com/ |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red

extern int period = 14;

double bullishEngulfing[];
double bearishEngulfing[];

void calculateEngulfing() {
    int limit;
    int counted_bars = IndicatorCounted();
    if (counted_bars > 0) {
        limit = Bars - counted_bars;
    } else {
        limit = Bars - period - 1;
    }

    for (int i = limit; i >= 0; i--) {
        if (Close[i] > Open[i] && Close[i+1] < Open[i+1] && Close[i] > Open[i+1] && Close[i] < High[i]) {
            bullishEngulfing[i] = Low[i] - 0.0001;
        } else {
            bullishEngulfing[i] = 0.0;
        }

        if (Close[i] < Open[i] && Close[i+1] > Open[i+1] && Close[i] < Open[i+1] && Close[i] > Low[i]) {
            bearishEngulfing[i] = High[i] + 0.0001;
        } else {
            bearishEngulfing[i] = 0.0;
        }
    }
}

int init() {
    IndicatorBuffers(2);
    SetIndexBuffer(0, bullishEngulfing);
    SetIndexStyle(0, DRAW_ARROW);
    SetIndexArrow(0, 233);
    SetIndexEmptyValue(0, 0.0);
    SetIndexBuffer(1, bearishEngulfing);
    SetIndexStyle(1, DRAW_ARROW);
    SetIndexArrow(1, 234);
    SetIndexEmptyValue(1, 0.0);
    return 0;
}

int start() {
    calculateEngulfing();
    return 0;
}

To use this indicator, save it as a .mq4 file and compile it in MetaEditor. Then, attach it to a chart and the Bullish Engulfing and Bearish Engulfing patterns will be highlighted with green and red arrows respectively. The indicator will only look back a specified number of periods (in this example, 14) so adjust as needed.