OPEN-SOURCE SCRIPT
Candle Numbers (last N, no bubble)

Candle Numbers (last N, no bubble) is a lightweight utility indicator that labels candles with sequential numbers to make chart analysis and discussion easier (e.g., “candle 213”, “the breakout candle”, “the pivot”). It is designed for clarity and performance: labels are text-only (no background bubble) and are drawn only for the last N bars.
What it does
Numbers the last N candles on the chart (a sliding window near the most recent bar).
Counting starts at the left edge of that window:
the leftmost bar in the window is 1
the most recent bar in the window is N (or fewer if you use stepping / limits).
Allows numbering every Nth bar to keep the chart clean.
Places numbers below each candle, with a configurable vertical offset measured in ticks.
Inputs
Bars to number (last N) (barsWindow)
Size of the numbered window (default 200).
Number every N bars (step)
1 = every bar, 2 = every second bar, 5 = every fifth bar, etc.
Text color (txtColor)
Text size (txtSizeIn)
tiny / small / normal / large
Vertical offset (ticks) (offsetTick)
Moves the label down by offsetTick * syminfo.mintick. You can use large values if needed.
Max numbers to plot (maxMarks)
Extra safeguard to control label count and performance.
How it works (implementation notes)
Labels are drawn only when barstate.islast is true (updates on the latest bar).
Previously created labels are deleted and re-created each update to avoid clutter.
Uses max_labels_count=500 plus maxMarks to stay within TradingView label limits.
Notes
This is not a trading signal indicator. It’s a chart annotation tool for analysis and manual backtesting.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.