Price · condition block
Candle streak
The candle streak block counts consecutive green or red candles ending with the latest one and fires once the run reaches the length you set.
How the engine evaluates it
A green candle closes above its open and a red candle closes below it. The engine counts how many candles of the chosen colour appear in a row, ending with the current candle.
The block is true when that count is at least N, so it stays true on the 4th, 5th and later candles of a longer streak.
A candle that closes exactly at its open ends both green and red streaks.
fires when (consecutive candles of the colour, ending now) ≥ N
Botscript syntax
In the Lab you pick this block from the Price group and fill in its fields. In the code view the same condition is written like this:
streak red 3
streak green 5
Settings
| Setting | Values | Default | Notes |
|---|---|---|---|
| Colour | green, red | red | Which streak to count. |
| Count | 1 – 200 | 3 | Minimum streak length. |
| Timeframe | the run's candles, or 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1w | the run's candles | Optional. 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 streak from bigger candles than the run uses, for example streak red 3 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 streak is a state on a higher timeframe: the result from the last completed bigger candle holds on every run candle until the next one closes.
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
- Mean reversion:
streak red 4as a sign that sellers may be exhausted. - Trend confirmation:
streak green 3with a moving-average filter. - Exits:
streak red 3withholdingto cut a trade that keeps falling.
Example bot
bot "Three Red Candles"
when streak red 3 and flat
then buy 25%
when streak green 2
then sell 100%
- Buys a quarter of the cash after three red candles in a row, only if not already holding.
- Sells everything after two green candles in a row.
Pitfalls
- Streaks say nothing about size: three tiny red candles count the same as three large ones. Combine with price move or big candle if size matters.
Candle streak: frequently asked questions
Does a doji break the streak?
A candle whose close equals its open breaks both green and red streaks.
Does it fire only once per streak?
No. It is true on every candle where the streak is at least N long. Use flat, cooldown or the default one-position rule to avoid repeats.
Can I count candles with big bodies only?
Not inside this block. Add a big candle condition in the same rule to require size on the latest candle.
How long can a streak be?
You can ask for up to 200 candles in a row.
Related blocks
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.