PROTECTED SOURCE SCRIPT
Aggiornato Bills Advanced Market Sessions V5

Bill007 Advanced Enhanced Market Sessions & Table V5 is a TradingView Pine Script indicator that
visualizes major stock market sessions and data for (Tokyo, London, New York, Sydney, Frankfurt) on charts.
**Purpose and Logic:**
- Visual Displays include session boxes, open/close/average lines, labels for session
names/metrics (ticks, avg price, volume), and trend labels (UP/Down/Neutral with % change)
and a Debug table.
- Uses custom types (SessionDisplay, SessionInfo) and methods to create/update sessions
dynamically, handling multi-part sessions (e.g., Tokyo breaks).
- Batch updates sessions for efficiency, checks timezones, weekdays, and daily changes to avoid
duplicates.
- Includes tables for session times/status/countdowns and debug metrics (tick range, average
price, volume, trend %, open, close).
- Supports 25 timezones for accurate global session timing.
- All labels have dynamaic tooltips that provide extra outputs which saves chart clutter
- Realtime lastbar session updates for current session
**Settings:**
- Select Market Sessions to suit
- Toggles for lines, ranges, averages, volumes, labels, boxes, weekends.
- Customizable colors, timezones, session times, thresholds for neutral trends, label offsets to
move labels around for clearer visuals.
- Table position/timezone, debug options.
- Timezone select to update Session times open close according to what time zone you're in
**Benefits:**
- Enhanced session data at a glance
- Enhances multi-market awareness, highlights session overlaps, trends, and key metrics.
- Aids timing entries/exits, volume analysis, reduces clutter with toggles.
- Supports global trading strategies with accurate timezone handling and visuals.
visualizes major stock market sessions and data for (Tokyo, London, New York, Sydney, Frankfurt) on charts.
**Purpose and Logic:**
- Visual Displays include session boxes, open/close/average lines, labels for session
names/metrics (ticks, avg price, volume), and trend labels (UP/Down/Neutral with % change)
and a Debug table.
- Uses custom types (SessionDisplay, SessionInfo) and methods to create/update sessions
dynamically, handling multi-part sessions (e.g., Tokyo breaks).
- Batch updates sessions for efficiency, checks timezones, weekdays, and daily changes to avoid
duplicates.
- Includes tables for session times/status/countdowns and debug metrics (tick range, average
price, volume, trend %, open, close).
- Supports 25 timezones for accurate global session timing.
- All labels have dynamaic tooltips that provide extra outputs which saves chart clutter
- Realtime lastbar session updates for current session
**Settings:**
- Select Market Sessions to suit
- Toggles for lines, ranges, averages, volumes, labels, boxes, weekends.
- Customizable colors, timezones, session times, thresholds for neutral trends, label offsets to
move labels around for clearer visuals.
- Table position/timezone, debug options.
- Timezone select to update Session times open close according to what time zone you're in
**Benefits:**
- Enhanced session data at a glance
- Enhances multi-market awareness, highlights session overlaps, trends, and key metrics.
- Aids timing entries/exits, volume analysis, reduces clutter with toggles.
- Supports global trading strategies with accurate timezone handling and visuals.
Note di rilascio
Bill007 Advanced Enhanced Market Sessions & Table V5 is a TradingView Pine Script indicator that visualizes major stock market sessions and data for (Tokyo, London, New York, Sydney, Frankfurt) on charts.
**Purpose and Logic:**
- Visual Displays include session boxes, open/close/average lines, labels for session
names/metrics (ticks, avg price, volume), and trend labels (UP/Down/Neutral with % change)
and a Debug table.
- Uses custom types (SessionDisplay, SessionInfo) and methods to create/update sessions
dynamically, handling multi-part sessions (e.g., Tokyo breaks).
- Batch updates sessions for efficiency, checks timezones, weekdays, and daily changes to avoid
duplicates.
- Includes tables for session times/status/countdowns and debug metrics (tick range, average
price, volume, trend %, open, close).
- Supports 25 timezones for accurate global session timing.
- All labels have dynamaic tooltips that provide extra outputs which saves chart clutter
- Realtime lastbar session updates for current session
**Settings:**
- Select Market Sessions to suit
- Toggles for lines, ranges, averages, volumes, labels, boxes, weekends.
- Customizable colors, timezones, session times, thresholds for neutral trends, label offsets to
move labels around for clearer visuals.
- Table position/timezone, debug options.
- Timezone select to update Session times open close according to what time zone you're in
**Benefits:**
- Enhanced session data at a glance
- Enhances multi-market awareness, highlights session overlaps, trends, and key metrics.
- Aids timing entries/exits, volume analysis, reduces clutter with toggles.
- Supports global trading strategies with accurate timezone handling and visuals.
Note di rilascio
Bill007 Advanced Enhanced Market Sessions & Table V5 is a TradingView Pine Script indicator that visualizes major stock market sessions and data for (Tokyo, London, New York, Sydney, Frankfurt) on charts.
**Purpose and Logic:**
- Visual Displays include session boxes, open/close/average lines, labels for session
names/metrics (ticks, avg price, volume), and trend labels (UP/Down/Neutral with % change)
and a Debug table.
- Uses custom types (SessionDisplay, SessionInfo) and methods to create/update sessions
dynamically, handling multi-part sessions (e.g., Tokyo breaks).
- Batch updates sessions for efficiency, checks timezones, weekdays, and daily changes to avoid
duplicates.
- Includes tables for session times/status/countdowns and debug metrics (tick range, average
price, volume, trend %, open, close).
- Supports 25 timezones for accurate global session timing.
- All labels have dynamaic tooltips that provide extra outputs which saves chart clutter
- Realtime lastbar session updates for current session
**Settings:**
- Select Market Sessions to suit
- Toggles for lines, ranges, averages, volumes, labels, boxes, weekends.
- Customizable colors, timezones, session times, thresholds for neutral trends, label offsets to
move labels around for clearer visuals.
- Table position/timezone, debug options.
- Timezone select to update Session times open close according to what time zone you're in
**Benefits:**
- Enhanced session data at a glance
- Enhances multi-market awareness, highlights session overlaps, trends, and key metrics.
- Aids timing entries/exits, volume analysis, reduces clutter with toggles.
- Supports global trading strategies with accurate timezone handling and visuals.
Note di rilascio
Bill007 Advanced Enhanced Market Sessions & Table V5 is a TradingView Pine Script indicator that visualizes major stock market sessions and data for (Tokyo, London, New York, Sydney, Frankfurt) on charts.**Purpose and Logic:**
- Visual Displays include session boxes, open/close/average lines, labels for session
names/metrics (ticks, avg price, volume), and trend labels (UP/Down/Neutral with % change)
and a Debug table.
- Uses custom types (SessionDisplay, SessionInfo) and methods to create/update sessions
dynamically, handling multi-part sessions (e.g., Tokyo breaks).
- Batch updates sessions for efficiency, checks timezones, weekdays, and daily changes to avoid
duplicates.
- Includes tables for session times/status/countdowns and debug metrics (tick range, average
price, volume, trend %, open, close).
- Supports 25 timezones for accurate global session timing.
- All labels have dynamaic tooltips that provide extra outputs which saves chart clutter
- Realtime lastbar session updates for current session
**Settings:**
- Select Market Sessions to suit.
- Toggles for lines, ranges, averages, volumes, labels, boxes, weekends for crypto.
- Customizable colors, timezones, session times, thresholds for neutral trends, label offsets to
move labels around for clearer visuals.
- Table position/timezone, debug options.
- TimeZone select to update Session times open close according to what time zone you're in.
**Benefits:**
- Enhanced session data at a glance.
- Enhances multi-market awareness, highlights session overlaps, trends, and key metrics.
- Aids timing entries/exits, volume analysis, reduces clutter with toggles.
- Supports global trading strategies with accurate timezone handling and visuals.
Note di rilascio
Market Sessions Advanced Enhanced V5 is a TradingView Pine Script indicator that visualizes major stock market sessions and data for (Tokyo, London, New York, Sydney, Frankfurt) on charts.**Purpose and Logic:**
- Visual Displays include session boxes, open/close/average lines, labels for session names/metrics (ticks, avg price, volume), and trend labels (UP/Down/Neutral with % change) and a Debug table.
- Uses custom types (SessionDisplay, SessionInfo) and methods to create/update sessions dynamically, handling multi-part sessions (e.g., Tokyo breaks).
- Batch updates sessions for efficiency, checks timezones, weekdays, and daily changes to avoid duplicates.
- Includes tables for session times/status/countdowns and debug metrics (tick range, average price, volume, trend %, open, close).
- Supports 25 timezones for accurate global session timing.
- All labels have dynamaic tooltips that provide extra outputs which saves chart clutter
- Realtime lastbar session updates for current session
**Settings:**
- Select Market Sessions to suit
- Toggles for lines, ranges, averages, volumes, labels, boxes, weekends for crypto.
- Customizable colors, timezones, session times, thresholds for neutral trends, label offsets to move labels around for clearer visuals.
- Table position/timezone, debug options.
- Timezone select to update Session times open close according to what time zone you're in
**Benefits:**
- Enhanced session data at a glance
- Enhances multi-market awareness, highlights session overlaps, trends, and key metrics.
- Aids timing entries/exits, volume analysis, reduces clutter with toggles.
- Supports global trading strategies with accurate timezone handling and visuals.
Note di rilascio
Update SummaryTo use - Mouse over Trend labels or Session labels
* Create and declare new function [getMarketOpenStatus]
- Function Purpose: The [getMarketOpenStatus] function dynamically determines if a market session is open or closed based on the current bar's time relative to the session's defined time and timezone. It returns "OPEN" if active, "CLOSED" if not, for use in session label tooltips to provide real-time status info to users.
- Addition Process: Added as a new function after type definitions to ensure availability before method calls. Uses time("D", this.session, this.timezone) to check session activity, with a local boolean inSession for clarity. Initially returned "true/false", updated to "OPEN/CLOSED" for user-friendly display.
- Implementation in Tooltips: Integrated into [updateSessionDisplay] for live updates during open sessions (shows "OPEN"). In updateSessions' closing logic, set on final label for closed sessions (shows "CLOSED"). This ensures tooltips reflect accurate status without hardcoding.
- Benefits and Dynamics: Enhances tooltip readability; status is computed real-time per bar, handling weekends and timezones correctly. No global variables added; fully modular and compliant with Pinescript v5.
***Step-by-Step Plan on Implementation***
- Update Function Logic: Modify [getMarketOpenStatus] to return "OPEN" or "CLOSED" as strings based on the inSession boolean check. This enhances readability in tooltips compared to "true/false". Retain the local inSession declaration and real-time time check for accuracy.
- Adjust Tooltip Integrations: In [updateSessionDisplay], update the tooltip concatenation to "Market Open: " + getMarketOpenStatus(this), which will now append "OPEN" during active sessions. In updateSessions' closing block, do the same for closed sessions, appending "CLOSED".
- Maintain Dynamics and Comments: Ensure the function uses current bar time for dynamic status. Add/update comments to explain the change to "OPEN"/"CLOSED" for better user understanding in tooltips.
- Testing Considerations: Verified that during an open session, Label tooltips show "OPEN", and after close (in historical or real-time), show "CLOSED". No new variables; keep compliant with Pinescript v5.
Note di rilascio
Addition of New Function [isLastBarInSession]The isLastBarInSession function is a key addition to detect the last bar of a market session, enabling timely closure and fixing issues like persistent "OPEN" tooltips in historical views and early data recording stoppage. Here's a step-by-step breakdown of how it works:
- Input Parameters: Takes two strings - sess (session time string, e.g., "0900-1600") and tz (timezone, e.g., "America/New_York").
- Parse Session Times: Extracts start hour (sh), start minute (sm), end hour (eh), end minute (em) from sess using str.substring and str.tonumber, cast to int for integer values.
- Get Bar's Local Date: Uses year(time, tz), month(time, tz), dayofmonth(time, tz) to get the bar's date in the session's timezone, ensuring local alignment (handles DST automatically via tz).
- Calculate Session Start and End Timestamps: Creates UTC timestamps for start and end using named arguments in timestamp() to avoid type errors: year = bar_year, month = bar_month, day = bar_day, hour = sh/eh, minute = sm/em, second = 0, timezone = tz. This produces millisecond timestamps for the session boundaries on the bar's date.
- Handle Overnight Sessions: If session_end < session_start (e.g., sessions spanning midnight), adds 86,400,000 ms (1 day) to session_end for correct comparison.
- Calculate Next Bar's Open Time: Adds the timeframe duration in ms (timeframe.in_seconds() * 1000) to the current bar's open time (time), getting the start of the next bar.
- Determine Last Bar: Returns true if next_open >= session_end, meaning the next bar would be outside the session, so the current bar is the last.
Integration: Called in updateSessions() during active sessions. If true, invokes closeSession() to finalize metrics, set tooltips to "CLOSED" (overriding dynamic status for historical accuracy), and clean up, ensuring full data capture (e.g., volume/avg up to 8:00 AM on 5min chart) and correct display on assets like NYSE-only stocks. This resolves user issues by proactively closing at the precise end bar, independent of inSession check which may lag on higher timeframes.
Note di rilascio
Task 1identified an issue where the "Open"/"Closed" status in the session table does not display correctly on CFD charts, despite being derived from session times.
investigate the cause and implement a more robust status output. After analysis, the likely cause is dependency on the symbol's exchange timezone (syminfo.timezone), which differs on CFD charts (often "UTC") compared to stock charts (e.g., "America/New_York"). This can lead to inconsistent offset calculations, especially with DST or timezone mismatches. To address this, I will refactor the utc_start/end calculation to use direct timestamp() with the session timezone, based on UTC date components, making it independent of the symbol's timezone. Additionally, to enhance robustness, we will add logic to handle potential overnight sessions by shifting the day reference if needed, ensuring correct status for sessions crossing midnight.
Implementation
- Analyzed current logic: The status relies on comparing timenow (UTC) to utc_start/end, calculated via an offset adjusted for timezone. This works in tested examples but can falter if symbol timezone mismatches session timezone, common on CFD charts.
- Update date components: Change currentYear, currentMonth, currentDay to use "UTC" explicitly to avoid symbol timezone influence.
- Refactor get_utc_start_end: Replace offset-based calculation with direct timestamp() using sessionTZ. Add overnight detection
- and day-shift logic: If overnight and timenow < utc_start, shift to previous day to capture ongoing sessions.
- Preserve other functions: Keep get_offset_ms and formatOffset for debug table, as they are independent.
- Integrate into base code: Update variable initialization and the get_utc_start_end function in code.
- No changes to inputs, types, methods, or other logic.
- Test conceptual integrity: The new logic maintains correct status for day sessions and adds support for overnight,
- ensuring robustness across chart types like CFD.
TASK 2
Add session date Modification to Session label tooltips
Identify Core Additions: The new elements are:
- (a) A function get_session_start_ts to compute the UTC start timestamp based on the bar's time (for historical accuracy), parsing session times, handling overnight cases, and adjusting dates.
- (b) A new field int sessionStartTS = na in type SessionInfo to persist the timestamp.
- (c) Logic to set this timestamp during session creation.
- (d) Appending "Date: [formatted date]\n" to tooltips in updateSessionDisplay, closeSession, and the closure branch of update.
- How It Works: On session creation (createSessionDisplay), the timestamp is calculated using the current bar's time and stored.
- For active sessions, tooltips in updateSessionDisplay format and append the date using str.format_time.
- For closed sessions, the stored timestamp ensures the date persists in tooltips set in closeSession and update's closure.
- This uses Pine Script's timestamp functions for timezone-aware formatting, ensuring no date drift in historical data or overnight sessions.
- Ensure Standalone and Compatibility:
- No existing variables or conditions are altered; additions are isolated insertions.
- Tested conceptually for intraday charts, weekends, and session states.
Note di rilascio
.Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarlo liberamente e senza alcuna limitazione – per saperne di più clicca qui.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarlo liberamente e senza alcuna limitazione – per saperne di più clicca qui.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.