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
tonbParticipant
Junior
The code is incorrect in this case, a signal is triggered at candele 3 witch is incorrect because the opening of candele 2 does not meet the condition. The signal should be triggered at candle 2, the opening of candle 1 meets the condition, and the closing of candle 2 also both meet the condition <0.8 pip Wick at the top and bottom
Below is another version, first pattern detected draw a ball, second pattern found in a row, draw a signal arrow.
c1 = (range <= 6.1 * pipsize)
green = c1 and close>open and (high - close) <= 0.8 * PipSize
red = c1 and close<open and (close - low) <= 0.8 * PipSize
if green then
if green[1] then
drawarrowup(barindex,low) coloured("green")
else
drawpoint(barindex,low,5) coloured("green")
endif
endif
if red then
if red[1] then
drawarrowdown(barindex,high) coloured("red")
else
drawpoint(barindex,high,5) coloured("red")
endif
endif
return
tonbParticipant
Junior
Perhaps what I mean isn’t possible, but the opening of the first candle shouldn’t have a wick, and the closing of the second candle shouldn’t either. Now I’m seeing signals with a larger wick.
I have highlighted where a signal should occur.
I would also like to link a sound alert to the signal, is it also possible for the signal to be displayed as an indicator?
I think the issue is that your original code only checks the wick on the closing side of each candle, but not the opening side. That’s why you’re still seeing signals with larger wicks.
What you actually want is to check both wicks (upper and lower) on each candle, so you only detect full-body candles (marubozu-like) with minimal wicks on both sides.
// --- Marubozu-like condition: small range + both wicks minimal ---
c1 = (range <= 6.1 * pipsize)
upperWick = (high - max(open, close)) <= 0.8 * pipsize
lowerWick = (min(open, close) - low) <= 0.8 * pipsize
Cond = c1 AND upperWick AND lowerWick
// --- 2-candle pattern ---
TwoCandle = Cond AND Cond[1]
RETURN TwoCandle