OPEN-SOURCE SCRIPT
Aggiornato Visible Range

Overview This is a precision tool designed for quantitative traders and engineers who need exact control over their chart's visual scope. Unlike standard time calculations that fail in markets with trading breaks (like A-Shares, Futures, or Stocks), this indicator uses a loop-back mechanism to count the actual number of visible bars, ensuring your indicators (e.g., MA60, MA200) have sufficient sample data.
Why use this? If you use multi-timeframe layouts (e.g., Daily/Hourly/15s), it is critical to know exactly how much data is visible.
The Problem: In markets like the Chinese A-Share market (T+1, 4-hour trading day), calculating Time Range / Timeframe results in massive errors because it includes closed market hours (lunch breaks, nights, weekends).
The Solution: This script iterates through the visible range to count the true bar_index, providing 100% accurate data density metrics.
Key Features
True Bar Counting: Uses a for loop to count actual candles, ignoring market breaks. perfect for non-24/7 markets.
Integer Precision: Displays time ranges (Days, Hours, Mins, Secs) in clean integers. No messy decimals.
Compact UI: Displays information in a single line (e.g., View: 30 Days (120 Bars)), default to the Top Right corner to save screen space.
Fully Customizable: Adjustable position, text size, and colors to fit any dark/light theme.
Performance Optimized: Includes max_bars_back limits to prevent browser lag on deep history lookups.
Settings
Position: Default Top Right (can be moved to any corner).
Max Bar Count: Default 5000 (Safety limit for loop calculation).
Why use this? If you use multi-timeframe layouts (e.g., Daily/Hourly/15s), it is critical to know exactly how much data is visible.
The Problem: In markets like the Chinese A-Share market (T+1, 4-hour trading day), calculating Time Range / Timeframe results in massive errors because it includes closed market hours (lunch breaks, nights, weekends).
The Solution: This script iterates through the visible range to count the true bar_index, providing 100% accurate data density metrics.
Key Features
True Bar Counting: Uses a for loop to count actual candles, ignoring market breaks. perfect for non-24/7 markets.
Integer Precision: Displays time ranges (Days, Hours, Mins, Secs) in clean integers. No messy decimals.
Compact UI: Displays information in a single line (e.g., View: 30 Days (120 Bars)), default to the Top Right corner to save screen space.
Fully Customizable: Adjustable position, text size, and colors to fit any dark/light theme.
Performance Optimized: Includes max_bars_back limits to prevent browser lag on deep history lookups.
Settings
Position: Default Top Right (can be moved to any corner).
Max Bar Count: Default 5000 (Safety limit for loop calculation).
Note di rilascio
Minor bug fixes and enhancementScript open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.