stratester.com

Patterns · condition block

Candlestick patterns

The candlestick pattern block fires when the candle that just closed completes one of seven classic patterns. Each pattern has a precise, mechanical definition, so the same chart always gives the same answer.

How the engine evaluates it

Body is |close − open|, range is high − low, the upper wick is the high minus the higher of open and close, and the lower wick is the lower of open and close minus the low.

Doji: a body no bigger than 10% of the range. Hammer: a lower wick at least twice the body, an upper wick at most 25% of the range, and a real body. Shooting star: the mirror image of the hammer.

Bullish engulfing: the previous candle was red, this one is green, closes at or above the previous open and opens at or below the previous close. Bearish engulfing is the reverse.

Inside bar: this candle's high and low are both within the previous candle's range. Outside bar: this candle's high is above and its low below the previous candle's.

Patterns are judged on shape only. There is no trend context, so a hammer is a hammer whether price was falling or not.

Formula
doji:     body ≤ 0.1 × range
hammer:   lower wick ≥ 2 × body  and  upper wick ≤ 0.25 × range
engulfing (bullish): prev red, current green, close ≥ prev open, open ≤ prev close

Botscript syntax

In the Lab you pick this block from the Patterns group and fill in its fields. In the code view the same condition is written like this:

pattern bullish_engulfing
pattern bearish_engulfing
pattern hammer
pattern shooting_star
pattern doji
pattern inside_bar
pattern outside_bar

Settings

SettingValuesDefaultNotes
Patternbullish engulfing, bearish engulfing, hammer, shooting star, doji, inside bar, outside barbullish engulfingOne pattern per block; add more blocks with or to accept several.
Timeframethe run's candles, or 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1wthe run's candlesOptional. At least the run's candle size and a whole multiple of it.

On a higher timeframe

Add a timeframe at the end to read Candle patterns from bigger candles than the run uses, for example pattern bullish_engulfing on 1d. The engine builds those candles from the run's own candles (UTC, weeks start on Monday) and evaluates the block only on candles that have closed, so there is no look-ahead. Lengths and lookbacks count the bigger candles.

Candle patterns is an event on a higher timeframe: it fires once, on the run candle that closes the bigger candle where it happened, and is false on the other run candles.

The timeframe must be at least the run's candle size and a whole multiple of it; otherwise the run stops with an error and is not charged. Multi-timeframe conditions covers the details, including warm-up.

How traders use it

  • Reversal entries with context: pattern hammer and rsi(14) < 35 in a dip.
  • Exhaustion exits: pattern shooting_star with holding.
  • Breakout setups: an inside bar followed by a breakout high of the last 2 candles.

Example bot

botscript
bot "Hammer In A Dip"

when pattern hammer and price down 5% in 48
then buy 50%

when pattern bearish_engulfing
then sell 100%
  • Buys half the cash on a hammer after a 5% fall over 48 candles.
  • Sells on a bearish engulfing candle.

Pitfalls

  • Single-candle patterns are common; on their own they are weak signals. Add trend or momentum context.
  • The definitions are strict ratios. A candle that looks like a hammer to the eye may miss the 2 × body test.

Candle patterns: frequently asked questions

Does the hammer need a downtrend?

No. The block checks the candle's shape only. Add a condition such as price down 5% in 48 or rsi(14) < 35 to require a prior fall.

How big is a doji's body allowed to be?

At most 10% of the candle's high-to-low range.

Can I accept several patterns in one rule?

Yes. Use or: pattern hammer or pattern bullish_engulfing.

Are engulfing patterns based on bodies or wicks?

Bodies: the current open and close must cover the previous candle's open and close.

Simulated results are hypothetical. They include only the fee and slippage you set on the bot, not every real-world cost or market condition, and past performance does not guarantee future results. Nothing here is financial advice.