Originally Posted By: manual
The CDL functions return a value of -100% for bearish patterns, +100% for bullish patterns, and 0 for no pattern match.

I'm not familiar with candle patterns and have never used them, but there are books where you probably find a description what an engulfing pattern is. A candle pattern can be bearish or bullish, but I think it can not be both, so your algorithm will probably not work.