New Pattern Analysis Tools: streak() and count()

November 29, 2025 Luis Gomez
New Pattern Analysis Tools: streak() and count()

Find stocks with winning streaks and consistent performance patterns using two powerful new indicators.

streak() - Consecutive Condition Counter

The streak() function counts how many consecutive bars satisfy your condition, starting from today and looking backwards.

Examples:

Find stocks with 5+ consecutive up days:

streak(close > open, 10) >= 5;

7 or more consecutive days above the 50-day moving average:

streak(close > sma(close, 50), 10) >= 7;

Volume compression (decreasing volume streak):

streak(volume < volume[1], 5) >= 4;

Consecutive days with RSI above 50:

streak(rsi(close, 14) > 50, 10) >= 5;

The streak breaks immediately when the condition becomes false. A stock with 3 up days, then 1 down day, then 2 up days has a current streak of 2.

count() - Occurrence Counter

The count() function counts how many times a condition is true in the last N bars. Unlike streak(), the occurrences don't need to be consecutive.

Examples:

Stocks with at least 3 up days in the last 5:

count(close > open, 5) >= 3;

Stocks mostly above their 50-day MA (7+ of last 10 days):

count(close > sma(close, 50), 10) >= 7;

Frequent high RSI readings:

count(rsi(close, 14) > 60, 10) >= 5;

High volume days in the last week:

count(volume > sma(volume, 20), 5) >= 3;

Using streak() and count() Together

Find consistent performers that aren't necessarily on a hot streak:

count(close > open, 5) >= 3 and streak(close > open, 5) < 3;

Find stocks in a strong consecutive uptrend:

count(close > open, 10) >= 7 and streak(close > open, 10) >= 3;

Key Differences

streak() - Counts consecutive true conditions from today backwards. Resets to 0 when condition is false.

count() - Counts total true conditions in the window. Doesn't require consecutive bars.

Both accept boolean expressions as the first parameter, making them flexible for any condition you can write in StonQL.

Related Posts

Introducing StocksFast: A Stock Scanner for Technical Traders
Introducing StocksFast: A Stock Scanner for Technical Traders

A high-level introduction to StocksFast - motivation, what it is, what it does, and who it's for.

New Features: IPO Date Tracking & Synthetic Price Fields
New Features: IPO Date Tracking & Synthetic Price Fields

Find recent IPOs, filter stocks by listing age, and use new synthetic price fields like typical price (HLC3), OHLC4, and …

Undo/Redo Now Availbale in the Expression Editor
Undo/Redo Now Availbale in the Expression Editor

Edit your scan expressions with confidence. Made a mistake? Just undo it. Our expression editor now features undo and redo …