Cookbook · live
The candle-pattern cookbook
Classic candlestick patterns, written in MuseScript's candle-pattern DSL. The design goal was a vocabulary that reads cleanly by hand and is discoverable by the evolution engine — so every pattern here is scale-free (wick-vs-body ratios, ATR-normalized ranges), which is what lets one rule transfer across instruments and regimes. Each is editable and runs in your browser.
The primitives. Each takes i bars back (0 = current): candle_body(i) / candle_body_abs(i), candle_upper_wick(i) / candle_lower_wick(i), candle_dir(i), candle_range_atr(i, n), candle_gap(i, n). Compose with count_true(…), all_of(…), any_of(…), and bars_since(cond). Full list in the language reference.
A note on honesty: these run on a driftless synthetic tape with no planted edge, so most will earn a NO-GO verdict — a pattern is a hypothesis, not an edge. The point of the DSL is to let you state the hypothesis precisely; the point of the engine is to tell you the truth about it.
Doji
neutralIndecision: the body is tiny relative to the bar's range. Expressed scale-free as body vs ATR, so the same rule reads a doji on a penny stock and on an index.
`candle_range_atr(i, n)` normalizes the bar's range by ATR(n) — the key to a threshold that transfers across instruments.
Hammer / Hanging man
bullishA small body with a long lower wick — sellers pushed price down intrabar and lost it. Bullish after a downtrend (hammer); the same shape after an uptrend is the bearish hanging man.
The wick-to-body ratio is what makes it a hammer; `count_true(...)` requires the prior context (a down move to reverse).
Shooting star
bearishThe hammer's mirror: a small body with a long UPPER wick after an advance — buyers pushed up and got rejected. A short-side or exit signal.
Reversal patterns double as risk controls — here the star is an exit gate on an otherwise trend-following long.
Bullish engulfing
bullishA big up bar whose body dwarfs the prior down bar — momentum flips. Encoded as a body-size proxy: current up body larger than the previous (down) body.
A pragmatic proxy: true engulfing also checks open/close overlap, but the body-size relation captures the momentum idea and stays evolution-friendly.
Marubozu
bullishA conviction bar: a large body with almost no wicks — price opened at one extreme and closed at the other. A continuation signal in the direction of the body.
Body ≈ range and wicks ≈ 0 is the whole definition — expressed directly in the DSL's wick/body primitives.
Pin bar (rejection)
bullishA single long wick rejecting a level — the 'pin'. Either side: a long lower wick rejects lower prices (bullish). More permissive than a hammer; no prior-trend requirement.
Wick length relative to ATR is a clean, robust 'rejection' measure — no fragile absolute thresholds.
Three white soldiers
bullishThree up bars in a row, each with a real body — a persistent, low-noise advance. The DSL's `count_true` turns 'a run of' directly into a number.
`count_true(...) == 3` reads exactly like the pattern's name — and the evolution engine can tune the count and the body threshold as free parameters.
Gap-and-go
bullishAn opening gap in the trend direction, measured against volatility so a 'gap' means the same thing on any instrument. `candle_gap(i, n)` is the open-vs-prior-close jump, ATR-normalized.
ATR-normalizing the gap is what keeps the threshold meaningful across regimes and instruments.
Part two
Multi-bar & continuation patterns
The patterns above read a single bar. These read across two or three — coils, three-bar reversals, and the pole-and-flag — so they reach for raw lookback (high[1], close[2]) alongside the candle primitives. Same idea: state the shape precisely, then let the engine judge it.
Inside bar
neutralA coil: one bar trades entirely inside the prior bar's range (high < high[1], low > low[1]) — volatility contracting, energy building. Trade the break of the mother bar in either direction; here, the up-break.
Raw lookback — `high[1]`, `low[2]` — reads any prior bar's OHLC. Inside/outside bars are pure range containment, so they need it.
Outside bar
bullishThe inside bar's opposite: a bar that engulfs the prior range entirely (high > high[1], low < low[1]) — an expansion. Direction of the close tells you who won.
Morning star
bullishA three-bar reversal: a strong down bar, a small-bodied 'star' of indecision, then an up bar that closes back into the first bar's body. Bearish evening star is the mirror.
Three roles — down / star / recovery — map to three indices (2, 1, 0). The DSL lets each condition name exactly what it means.
Bullish harami
bullishA large down bar followed by a small up bar that sits inside it — momentum stalling, then turning. Like an inside bar, but with a directional flip that makes it a reversal read.
Tweezer bottom
bullishTwo bars printing almost the same low after a decline — a level tested twice and held. Measured against ATR (no absolute-value builtin needed: bound the gap from both sides).
There's no abs(); two one-sided comparisons express |low − low[1]| < ε cleanly — and stay legible to the evolution engine.
Bull flag
bullishThe classic pole-and-flag: a sharp advance (the pole), a tight low-range consolidation (the flag), then a breakout. Continuation, not reversal — you're betting the trend resumes.
Three ideas — a move, a pause, a break — become three composable clauses over `highest`/`lowest`/`atr`. A strict pattern, so it fires rarely; that's honest.
Three inside up
bullishHarami plus confirmation: a large down bar, an inside up bar, then a third bar breaking above the inside bar's high. The confirmation bar is what separates it from a plain harami.
Where patterns go next
Because every pattern above is just a MuseScript expression over the same primitives, the evolution engine treats each threshold and count as a free parameter — it can rediscover a hammer, or find a shape nobody named. Hand-write the hypothesis here, then let the engine search around it — and keep only what survives the honesty layer.