Candle patterns
Classic candlestick shapes such as engulfing, hammer, doji, inside bar and stars.
Candle shapes only (context is the strategy's job), each true on the candle that completes it. body = |close − open|, range = high − low; a doji has body ≤ doji_ratio × range. A zero-range candle has no ratio shape. Engulfing (V1): opposite colours, neither a doji, the body contains the previous body and is larger. Harami: the body inside the previous opposite, non-doji body. Hammer: lower wick ≥ hammer_wick_body × body, upper wick ≤ hammer_max_opposite × range. Pin bar (V1): body ≥ pin_min_body × range, the wick > pin_wick_body × body and > pin_wick_ratio × range. Inside bar (V1): high < previous high and low > previous low. Stars: a big candle (body ≥ star_big × range), a small one (body ≤ star_small × range) at or beyond the first close, then a big opposite candle closing past the first body's middle.
Candle patterns is a structure detector: it marks price structure on the chart and counts against the plan's detector limit.
Settings
| Setting | Default | Range | What it does |
|---|---|---|---|
| doji_ratio | 0.1 | 0 to 0.5 | Doji: largest body ÷ range. |
| pin_min_body | 0.05 | 0 to 0.5 | Pin bar: smallest body ÷ range. |
| pin_wick_ratio | 0.6 | 0.3 to 1 | Pin bar: the wick is more than this share of the range. |
| pin_wick_body | 2 | 0.5 to 20 | Pin bar: the wick is more than this many bodies. |
| hammer_wick_body | 2 | 0.5 to 20 | Hammer: the long wick is at least this many bodies. |
| hammer_max_opposite | 0.1 | 0 to 0.5 | Hammer: the other wick is at most this share of the range. |
| star_big | 0.5 | 0.1 to 1 | Stars: smallest body ÷ range of the first and last candle. |
| star_small | 0.3 | 0 to 0.9 | Stars: largest body ÷ range of the middle candle. |
What it gives
| Output | What it is |
|---|---|
| Bullish engulfing | True on a bullish engulfing candle. |
| Bearish engulfing | True on a bearish engulfing candle. |
| Bullish harami | True on a bullish harami. |
| Bearish harami | True on a bearish harami. |
| Hammer | True on a hammer (long lower wick). |
| Shooting star | True on a shooting star (long upper wick). |
| Doji | True on a doji (tiny body). |
| Inside bar | True when the range is inside the previous candle's. |
| Outside bar | True when the range covers the previous candle's on both sides. |
| Morning star | True on the third candle of a morning star. |
| Evening star | True on the third candle of an evening star. |
| Bullish pin bar | True on a bullish pin bar (long lower wick). |
| Bearish pin bar | True on a bearish pin bar (long upper wick). |
What it reads
It reads the whole candle (open, high, low, close and volume).
Warm-up
With its default settings, Candle patterns needs 3 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.
Test it
Copy this sentence into the Algonney chat to backtest it:
Backtest a strategy on BTC that uses Candle patterns with its default settings