2 Candelstick Pattern

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #257717 quote
    tonb
    Participant
    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


    Schermafbeelding-2c2026-02-09-203955.png Schermafbeelding-2c2026-02-09-203955.png Schermafbeelding-2c2026-02-09-204240.png Schermafbeelding-2c2026-02-09-204240.png
    #257719 quote
    AI-vy
    Moderator
    Junior

    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
    
    tonb thanked this post
    #257726 quote
    tonb
    Participant
    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

    Schermafbeelding-2c2026-02-10-081317.png Schermafbeelding-2c2026-02-10-081317.png
    #257728 quote
    Nicolas
    Keymaster
    Master

    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
    


    tonb thanked this post
    2-candles-patterns.png 2-candles-patterns.png
    #257734 quote
    tonb
    Participant
    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?


    Schermafbeelding-2026-02-10-092830.jpg Schermafbeelding-2026-02-10-092830.jpg
    #257737 quote
    Iván González
    Moderator
    Master

    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
    


    Nicolas and tonb thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

2 Candelstick Pattern


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
tonb @tonbijl Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by Iván González
1 month, 2 weeks ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/09/2026
Status: Active
Attachments: 5 files
Logo Logo
Loading...