I'm trying to detect bullish/bearish engulfing candles with a bit of wiggle room on either side, as there are sometimes small discrepancies in the price(s). I'd like to detect an engulfing even if the candle open/close is say +/-.01% from the previous open/close.
//identify bullish/bearish engulfing candles
bullishEC = close > open[1] and open <= close[1] and close[1] < open[1]
bearishEC = close < open[1] and open >= close[1] and close[1] > open[1]
You can multiply the open[1] and close[1] with required price percentage and then compare. Example
bullishEC = close > open[1]*(1-0.01/100) and open <= close[1]*(1+0.01/100) and close[1] < open[1]
bearishEC = close < open[1]*(1+0.01/100) and open >= close[1]*(1-0.01/100) and close[1] > open[1]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.