tonbParticipant
Junior
I am looking for a 2 candle pattern bassed on the formula below, this formula is for 1 candle
c1 = (range <= 6.1 * pipsize)
c2 = 0
IF close > open THEN
c2 = (high – close) <= 0.8 * PipSize
ELSIF close < open THEN
c2 = (close – low) <= 0.8 * PipSize
ENDIF
Cond = c1 AND c2
return Cond
2-candle pattern based on your 1-candle condition
Below is your original 1-candle logic, extended to detect a pattern where both the current candle and the previous candle satisfy the same condition.
Logic explanation:
- c1: the candle’s total range is smaller than or equal to 6.1 * pipsize.
- c2: the wick on the closing side is very small (≤ 0.8 * pipsize).
- If the candle is bullish (close > open): upper wick = high – close.
- If the candle is bearish (close < open): lower wick = close – low.
- Cond: candle satisfies both conditions c1 AND c2.
- 2-candle pattern: current candle Cond AND previous candle Cond[1] are both true.
ProBuilder code for the 2-candle pattern:
// --- 1-candle condition ---
Irange = high - low
c1 = Irange <= 6.1 * pipsize
IF close > open THEN
c2 = (high - close) <= 0.8 * pipsize
ELSIF close < open THEN
c2 = (close - low) <= 0.8 * pipsize
ELSE
// Doji case: you can decide what to do; here we set it to FALSE
c2 = 0
ENDIF
Cond = c1 AND c2
// --- 2-candle pattern: current candle AND previous candle match the same condition ---
TwoCandlePattern = Cond AND Cond[1]
RETURN TwoCandlePattern