OPEN-SOURCE SCRIPT

Bar Count (Timezone Fixed | Colorful Multiples)

590
Bar Count (Timezone Fixed | Colorful Multiples)
This indicator sequentially numbers each bar within a trading day, featuring two key improvements over traditional bar counters:

1. Timezone Fixed – No More Noon Reset
Uses the exchange’s timezone to detect a new trading day (time("D", syminfo.timezone)), rather than local time or calendar date. The counter resets only at the exchange’s actual session start, eliminating the common issue where numbers reset at noon due to timezone differences or lunch breaks.

2. Colorful Multiples – Highlight Key Intervals
Supports custom colors for bars at specific multiples (e.g., every 12th, 24th bar). Visual markers help you easily identify repeating cycles, important time windows, or rhythm points without manual calculation.

Input Parameters
  • Label Size: Text size (Auto/Huge/Large/Normal/Small/Tiny)
  • Display at every X bars: Show label every X bars (set to 1 for every bar)
  • Default Color: Default label color
  • every N bars: The multiple interval (e.g., 12 for every 12th bar)
  • N bars Color: Color for bars at the specified multiple


Use Case
Ideal for intraday traders, especially those trading futures, forex, or indices with overnight sessions or lunch breaks. The timezone fix ensures accurate continuous numbering, while the color-coded multiples provide visual cues for recurring intervals.

本指标为图表上的每根 K 线按交易日顺序连续编号,并针对传统同类指标的痛点进行了两项关键改进:

1. 时区修正,告别中午重置
使用交易所时区判断新交易日(time("D", syminfo.timezone)),而非本地时间或自然日。无论图表时区如何设置,编号仅在交易所实际开盘时重置,彻底解决因午休、时区偏移导致的中午 12:00 后序号从 1 开始的错误。

2. 彩色倍数,关键节点一目了然
支持为指定倍数的 K 线(如每 12 根、每 24 根)设置独立颜色。通过直观的色彩标记,轻松识别固定周期循环(如每 12 根 K 线)、时间窗口或重要节奏点,无需额外计算。

输入参数
  • Label Size:标签文字大小(自动/特大/大/正常/小/微小)
  • Display at every X bars:每 X 根 K 线显示一次编号(设为 1 则每根显示)
  • Default Color:默认标签颜色
  • every N bars:倍数间隔(例如 12 表示每 12 根 K 线使用特殊颜色)
  • N bars Color:倍数序号的标签颜色


适用场景
日内交易者、期货、外汇、指数等有夜盘或午休的品种,确保编号连续准确;同时通过颜色区分固定周期,辅助识别关键时间节点。

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。