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.

01

Doji

neutral

Indecision: 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.

MuseScript · live · js

`candle_range_atr(i, n)` normalizes the bar's range by ATR(n) — the key to a threshold that transfers across instruments.

02

Hammer / Hanging man

bullish

A 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.

MuseScript · live · js

The wick-to-body ratio is what makes it a hammer; `count_true(...)` requires the prior context (a down move to reverse).

03

Shooting star

bearish

The 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.

MuseScript · live · js

Reversal patterns double as risk controls — here the star is an exit gate on an otherwise trend-following long.

04

Bullish engulfing

bullish

A 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.

MuseScript · live · js

A pragmatic proxy: true engulfing also checks open/close overlap, but the body-size relation captures the momentum idea and stays evolution-friendly.

05

Marubozu

bullish

A 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.

MuseScript · live · js

Body ≈ range and wicks ≈ 0 is the whole definition — expressed directly in the DSL's wick/body primitives.

06

Pin bar (rejection)

bullish

A 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.

MuseScript · live · js

Wick length relative to ATR is a clean, robust 'rejection' measure — no fragile absolute thresholds.

07

Three white soldiers

bullish

Three 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.

MuseScript · live · js

`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.

08

Gap-and-go

bullish

An 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.

MuseScript · live · js

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.

01

Inside bar

neutral

A 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.

MuseScript · live · js

Raw lookback — `high[1]`, `low[2]` — reads any prior bar's OHLC. Inside/outside bars are pure range containment, so they need it.

02

Outside bar

bullish

The 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.

MuseScript · live · js
03

Morning star

bullish

A 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.

MuseScript · live · js

Three roles — down / star / recovery — map to three indices (2, 1, 0). The DSL lets each condition name exactly what it means.

04

Bullish harami

bullish

A 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.

MuseScript · live · js
05

Tweezer bottom

bullish

Two 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).

MuseScript · live · js

There's no abs(); two one-sided comparisons express |low − low[1]| < ε cleanly — and stay legible to the evolution engine.

06

Bull flag

bullish

The 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.

MuseScript · live · js

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.

07

Three inside up

bullish

Harami 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.

MuseScript · live · js

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.