OPEN-SOURCE SCRIPT
RTH Session Bar Counter EU/US/Asia v.2.2

Added a "Label every N bars" setting (1–20) to extend how far back into history the bar numbers are visible. TradingView caps any script at 500 labels total, so on busy timeframes numbers eventually ran out while background shading didn't — raising N now lets you trade granularity for historical reach (e.g. every 2nd bar roughly doubles the visible range, every 3rd roughly triples it).
Regardless of the setting, the first bar of every session, every hour-end bar, and your special marked bar (if enabled) are always numbered and never thinned out.
Regardless of the setting, the first bar of every session, every hour-end bar, and your special marked bar (if enabled) are always numbered and never thinned out.
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.