OPEN-SOURCE SCRIPT
Candle count, with simple number

What it does
Counts the length of same-color candle streaks (consecutive bullish or bearish bars) and prints the running number above each bar:
e.g., “1, 2, 3…”; when color flips, it restarts at “1”.
Prime numbers (2, 3, 5, 7, 11, 13) are emphasized by rendering one size step larger and with a user-selected color.
Labels are pinned to each bar (anchored by bar index and price), so they do not drift when you pan or zoom the chart.
How it works
Determines candle direction: bullish if close > open, bearish if close < open.
If the current bar has the same direction as the previous bar, the counter increments; otherwise it resets to 1.
For values 2, 3, 5, 7, 11, 13 the number is highlighted (bigger + custom color).
Each number is drawn just above the bar’s High with a configurable offset.
The script does not repaint on history. During the live bar, the number updates in real time (as expected).
Settings
Digits size — Base text size (Tiny / Small / Normal / Large / Huge).
Prime numbers are automatically shown one step larger than the base size.
Offset above bar (ticks) — Vertical offset from the bar’s High, in instrument ticks.
Prime numbers color — Text color used specifically for prime numbers (non-prime digits are white).
How to read & use it
Rising momentum. Long streaks (e.g., 5–7+) suggest strong directional moves with few pullbacks.
Early pause/mean-reversion hints. After a long streak, the appearance of the opposite color (counter resets to “1”) often coincides with a pause or minor retrace.
Research & statistics. Quickly see which streak lengths are common on your market/timeframe (e.g., “How often do 3–5 bar runs occur?”).
Trade management. You can tie partial exits to specific streak lengths (2, 3, 5…) or reduce risk when the counter flips back to “1”.
Why it’s useful
Provides a clean, numeric view of momentum with zero smoothing or lag.
Works on any symbol and timeframe.
Prime-number emphasis makes important counts pop at a glance.
Pinned labels stay exactly above their bars, ensuring stable, readable visuals at any zoom level.
Notes
Doji bars (close == open) are treated as no direction and reset the streak.
This is a context tool, not a standalone buy/sell signal. Combine it with your entry/exit framework.
Very dense charts may hit platform label limits; the script raises the limit, but extremely long histories on very low timeframes can still be heavy.
Counts the length of same-color candle streaks (consecutive bullish or bearish bars) and prints the running number above each bar:
e.g., “1, 2, 3…”; when color flips, it restarts at “1”.
Prime numbers (2, 3, 5, 7, 11, 13) are emphasized by rendering one size step larger and with a user-selected color.
Labels are pinned to each bar (anchored by bar index and price), so they do not drift when you pan or zoom the chart.
How it works
Determines candle direction: bullish if close > open, bearish if close < open.
If the current bar has the same direction as the previous bar, the counter increments; otherwise it resets to 1.
For values 2, 3, 5, 7, 11, 13 the number is highlighted (bigger + custom color).
Each number is drawn just above the bar’s High with a configurable offset.
The script does not repaint on history. During the live bar, the number updates in real time (as expected).
Settings
Digits size — Base text size (Tiny / Small / Normal / Large / Huge).
Prime numbers are automatically shown one step larger than the base size.
Offset above bar (ticks) — Vertical offset from the bar’s High, in instrument ticks.
Prime numbers color — Text color used specifically for prime numbers (non-prime digits are white).
How to read & use it
Rising momentum. Long streaks (e.g., 5–7+) suggest strong directional moves with few pullbacks.
Early pause/mean-reversion hints. After a long streak, the appearance of the opposite color (counter resets to “1”) often coincides with a pause or minor retrace.
Research & statistics. Quickly see which streak lengths are common on your market/timeframe (e.g., “How often do 3–5 bar runs occur?”).
Trade management. You can tie partial exits to specific streak lengths (2, 3, 5…) or reduce risk when the counter flips back to “1”.
Why it’s useful
Provides a clean, numeric view of momentum with zero smoothing or lag.
Works on any symbol and timeframe.
Prime-number emphasis makes important counts pop at a glance.
Pinned labels stay exactly above their bars, ensuring stable, readable visuals at any zoom level.
Notes
Doji bars (close == open) are treated as no direction and reset the streak.
This is a context tool, not a standalone buy/sell signal. Combine it with your entry/exit framework.
Very dense charts may hit platform label limits; the script raises the limit, but extremely long histories on very low timeframes can still be heavy.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。