Level 3 — ProductionCandlestick Patterns

Candlestick Patterns

45 minutes60 marksprintable — key stays hidden on paper

Subject: Stock-Market · Chapter: Candlestick Patterns Level: 3 — Production (from-scratch derivations, code-from-memory, explain-out-loud) Time Limit: 45 minutes Total Marks: 60

Instructions: Show all reasoning. For coding questions, correct logic scores full marks even with minor syntax slips. Use OHLC = Open, High, Low, Close throughout.


Question 1 — Anatomy from scratch (10 marks)

A daily candle has O=100O = 100, H=112H = 112, L=96L = 96, C=108C = 108.

(a) Derive expressions and compute the body length, upper wick, and lower wick. (4)

(b) Compute the body-to-range ratio COHL\dfrac{|C-O|}{H-L} and state, with justification, whether this qualifies as a marubozu, a spinning top, or neither (use body/range thresholds: marubozu 0.95\geq 0.95, spinning top 0.30\leq 0.30). (3)

(c) Explain out loud (2–3 sentences) why the ratio, not the absolute body length, is the correct discriminator across stocks trading at different price levels. (3)


Question 2 — Doji classifier from memory (12 marks)

Write a function (Python-like pseudocode acceptable) classify_doji(o, h, l, c) that returns one of: "standard_doji", "long_legged_doji", "dragonfly_doji", "gravestone_doji", or "not_doji".

(a) State the numeric rules you will use (body ratio threshold, wick asymmetry criteria). (4)

(b) Write the function code from memory. (6)

(c) Explain why a doji's signal strength depends on the preceding trend context, not the candle alone. (2)


Question 3 — Engulfing vs Harami derivation (10 marks)

Given two consecutive candles (day 1 and day 2), define both a bullish engulfing and a bullish harami purely in terms of the four OHLC values of each day.

(a) Write the precise inequality conditions for bullish engulfing. (4)

(b) Write the precise inequality conditions for bullish harami. (3)

(c) In one sentence each, contrast the market psychology each pattern encodes. (3)


Question 4 — Three-candle star reconstruction (10 marks)

You are given a morning star. Reconstruct the pattern from scratch:

(a) Describe the three candles (colour, body size, gaps) that define a valid morning star. (4)

(b) A trader claims these candles form a morning star: Day 1: O=50,C=44O=50, C=44 · Day 2: O=43.5,C=43.2O=43.5, C=43.2 · Day 3: O=44,C=49O=44, C=49. Test each condition and state whether it qualifies. Show your check on the day-3 confirmation rule (close must recover into day-1 body, i.e. above its midpoint). (4)

(c) Explain out loud why the small middle body is the "indecision pivot." (2)


Question 5 — Tweezer & three-method logic (10 marks)

(a) Define tweezer top and tweezer bottom in terms of the highs/lows of two adjacent candles, including a tolerance parameter ϵ\epsilon. (4)

(b) Write pseudocode is_falling_three_methods(candles) for a 5-candle list, stating all conditions. (4)

(c) Why must the three middle candles stay within the first candle's range? (2)


Question 6 — Combining patterns with context (8 marks)

A hammer appears at the bottom of a 6-day downtrend, on volume 2.3× the 20-day average, right at a prior support level.

(a) List three contextual confirmations that upgrade a raw hammer into a high-probability reversal signal. (3)

(b) Explain how you would use the next candle to confirm entry, and where you'd place the stop-loss with a reason. (5)


End of paper.

Answer keyMark scheme & solutions

Question 1 (10)

(a) (4 — 1 each formula/value, 1 for all correct)

  • Body =CO=108100=8= |C - O| = |108 - 100| = 8
  • Upper wick =Hmax(O,C)=112108=4= H - \max(O,C) = 112 - 108 = 4
  • Lower wick =min(O,C)L=10096=4= \min(O,C) - L = 100 - 96 = 4
  • Range =HL=11296=16= H - L = 112 - 96 = 16 ✓ (body + wicks = 8+4+4 = 16, consistency check)

(b) (3)

  • Ratio =8/16=0.50= 8/16 = 0.50.
  • 0.30<0.50<0.950.30 < 0.50 < 0.95Neither marubozu nor spinning top. (1 for ratio, 1 for comparison, 1 for verdict.)

(c) (3) The ratio normalises body size against the candle's own trading range, making it scale-invariant: an 8-point body means very different things on a \50 stock vs a $5000 stock, but body/range compares intent (conviction) to activity within the same session. This lets one threshold classify candles across all price levels and volatilities.


Question 2 (12)

(a) Rules (4)

  • Body ratio r=co/(hl)r = |c-o| / (h-l); doji if r0.10r \leq 0.10 (and h>lh>l).
  • Upper wick u=hmax(o,c)u = h-\max(o,c); lower wick d=min(o,c)ld = \min(o,c)-l.
  • Dragonfly: u0u \approx 0 (small), dd large → long lower, negligible upper.
  • Gravestone: d0d \approx 0, uu large → long upper, negligible lower.
  • Long-legged: both uu and dd large and roughly balanced.
  • Standard: small body, modest balanced wicks (default doji).

(b) Code (6)

def classify_doji(o, h, l, c):
    rng = h - l
    if rng == 0:
        return "not_doji"
    body = abs(c - o) / rng
    if body > 0.10:
        return "not_doji"
    u = (h - max(o, c)) / rng   # upper wick fraction
    d = (min(o, c) - l) / rng   # lower wick fraction
    if u < 0.10 and d > 0.60:
        return "dragonfly_doji"
    if d < 0.10 and u > 0.60:
        return "gravestone_doji"
    if u > 0.30 and d > 0.30:
        return "long_legged_doji"
    return "standard_doji"

(2 marks structure/guards, 2 marks body test, 2 marks variant branches.)

(c) (2) A doji shows equilibrium between buyers and sellers; its meaning is directional only relative to what preceded it — a dragonfly after a downtrend is bullish reversal, the same candle mid-range is just noise. Context supplies the "from what state are we reversing."


Question 3 (10)

(a) Bullish engulfing (4) — Day 1 bearish, Day 2 bullish body engulfs Day 1 body:

  • C1<O1C_1 < O_1 (day 1 red)
  • C2>O2C_2 > O_2 (day 2 green)
  • O2C1O_2 \leq C_1 (opens at/below prior close)
  • C2O1C_2 \geq O_1 (closes at/above prior open)

(b) Bullish harami (3) — Day 1 large bearish, Day 2 small body inside:

  • C1<O1C_1 < O_1 (day 1 red, large body)
  • C2>O2C_2 > O_2 (day 2 green, small)
  • O2>C1O_2 > C_1 and C2<O1C_2 < O_1 (day-2 body contained inside day-1 body)

(c) (3)

  • Engulfing: buyers overwhelm sellers completely, seizing full control — strong momentum reversal. (1.5)
  • Harami: selling momentum suddenly stalls and contracts inside prior range — hesitation/exhaustion, a weaker, "pause" reversal needing confirmation. (1.5)

Question 4 (10)

(a) (4)

  1. Day 1: long bearish (red) candle continuing the downtrend.
  2. Day 2: small body (star), often gapping down; colour secondary; shows indecision.
  3. Day 3: long bullish (green) candle that closes well into (above midpoint of) Day-1 body. (Gaps between bodies strengthen the pattern.)

(b) (4)

  • Day 1: O=50,C=44O=50, C=44 → red, large body ✓. Midpoint =(50+44)/2=47=(50+44)/2 = 47.
  • Day 2: body =43.543.2=0.3=|43.5-43.2| = 0.3, small ✓; below day-1 close, gapped down ✓.
  • Day 3: O=44,C=49O=44, C=49 → green, large ✓.
  • Confirmation rule: Day-3 close 49>4749 > 47 (midpoint of day-1 body) ✓.
  • Verdict: valid morning star. (1 each: day1, day2, day3, midpoint check.)

(c) (2) The small middle body means neither side won that session — the downtrend's selling pressure has evaporated but buyers haven't yet committed; it is the fulcrum where control transfers, so the following strong green candle confirms the tilt to buyers.


Question 5 (10)

(a) (4)

  • Tweezer top: two adjacent candles with near-equal highs: H1H2ϵ|H_1 - H_2| \leq \epsilon, occurring in an uptrend (first bullish, second bearish typical) → resistance rejection.
  • Tweezer bottom: near-equal lows: L1L2ϵ|L_1 - L_2| \leq \epsilon, in a downtrend (first bearish, second bullish) → support hold. (ϵ\epsilon = small tolerance, e.g. a fraction of ATR or of price.)

(b) (4)

def is_falling_three_methods(candles):
    # candles: list of 5 dicts with o,h,l,c
    c1, c2, c3, c4, c5 = candles
    big_red   = c1['c'] < c1['o']                 # day1 long bearish
    up_middle = all(m['c'] > m['o'] for m in (c2, c3, c4))  # small greens (climbing)
    contained = all(c1['l'] <= m['l'] and m['h'] <= c1['h']
                    for m in (c2, c3, c4))          # inside day1 range
    big_red5  = (c5['c'] < c5['o']) and (c5['c'] < c1['c'])  # day5 breaks below day1 close
    return big_red and up_middle and contained and big_red5

(1 day1, 1 middle three, 1 containment, 1 day5 breakdown.)

(c) (2) Containment shows the counter-trend rally (the three small candles) is only a weak, corrective pause that never overcomes the dominant move; if they broke out of the range the trend would be genuinely contested and the continuation thesis would fail.


Question 6 (8)

(a) (3, 1 each)

  1. Occurs after a defined downtrend (reversal needs something to reverse).
  2. At a prior support / demand zone (confluence).
  3. On elevated volume (2.3× avg) confirming genuine buying interest, not thin drift.

(b) (5)

  • Wait for the next candle to close bullish above the hammer's high (or high of hammer body) before entering — confirms buyers followed through rather than a one-day fake. (3)
  • Place stop-loss just below the hammer's low (the session low that buyers defended); a break below invalidates the support/reversal thesis, giving a defined, logical risk point and favourable reward-to-risk against the next resistance. (2)

[
  {"claim":"Q1 body=8, upper wick=4, lower wick=4, range=16, ratio=0.5, neither category","code":"O,H,L,C=100,112,96,108\nbody=abs(C-O)\nup=H-max(O,C)\ndn=min(O,C)-L\nrng=H-L\nratio=Rational(body,rng)\nverd=(ratio<Rational(3,10)) or (ratio>=Rational(95,100))\nresult=(body==8 and up==4 and dn==4 and rng==16 and ratio==Rational(1,2) and verd==False)"},
  {"claim":"Q4 morning star: day1 midpoint 47 and day3 close 49 recovers above it","code":"mid=Rational(50+44,2)\nd3_close=49\nresult=(mid==47 and d3_close>mid)"},
  {"claim":"Q4 day2 body 0.3 is small relative to day1 body 6","code":"d1=abs(50-44)\nd2=Rational(3,10)\nresult=(d1==6 and d2<Rational(1,10)*d1)"},
  {"claim":"Q3 bullish engulfing sample O1=10,C1=8,O2=7,C2=11 satisfies all conditions","code":"O1,C1,O2,C2=10,8,7,11\nc=(C1<O1) and (C2>O2) and (O2<=C1) and (C2>=O1)\nresult=bool(c)"}
]