OPEN-SOURCE SCRIPT
MP SESSIONS, DST, OTT

Here’s a clear description you can use for this script (for yourself or as a TradingView “Indicator Description”):
---
### MP SESSIONS, DST, OTT – What this indicator does
This script is a **multi-session market timing tool** that:
1. **Draws full trading sessions on the chart** (Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE)
2. **Automatically adjusts for Daylight Saving Time (DST)** for Sydney, London, and New York
3. **Shows a live info table** with session times, DST status, and whether each session is currently open or closed
4. **Adds optional custom “OTT” vertical lines** at user-defined intraday times (for your own models, killzones, or time blocks)
---
### Main Features (high level)
#### 1. Market mode & time zone handling
* **Market Mode**:
* `Forex`
* `Stock`
* `User Custom` (you type your own session ranges)
* `TFlab suggestion` (predefined “optimized” session times)
* **Time Zone Mode**:
* `UTC`
* `Session Local Time` (local exchange time: Sydney, Tokyo, London, New York etc.)
* `Your Time Zone` (converts to the user-selected TZ, e.g. `UTC-4:00`)
* Handles separate time zones for:
* Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE
* Has logic to **recalculate session start/end depending on DST** and the chosen mode.
---
#### 2. Daylight Saving Time (DST) engine
The function `DST_Detector`:
* Calculates when DST **starts and ends** for:
* `Australia/Sydney`
* `Europe/London`
* `America/New_York`
* Detects the correct Sunday (2nd, 4th, etc.) for start/end using day-of-week and week counts.
* Returns `'Active'` or `'Inactive'` for each region.
* These values are then used to **shift the sessions** (e.g. New York 13:00–21:00 vs 12:00–20:00 in UTC).
The script can also **draw vertical lines** on the chart when DST starts/ends and label them:
* “Sydney DST Started / Ended”
* “London DST Started / Ended”
* “New York DST Started / Ended”
---
#### 3. Session timing & sessions on the chart
The function `Market_TimeZone_Calculator`:
* Based on **Market Mode** + **Time Zone Mode** + **DST state**, it returns:
* Time ranges for: Sydney, Tokyo, Shanghai, Asia (combined), Europe, London, New York, NYSE
* These ranges are in `"HHMM-HHMM"` format.
Then the script:
* Converts these to `time()` conditions using the proper time zone
* Creates boolean series like `On_sesAsia`, `On_sesEurope`, `On_sesNewYork`, etc., which are **1 when the session is open and 0 when closed**.
---
#### 4. Session high/low boxes & labels
The function `LowHighSessionDetector`:
* Tracks **high and low of each session** while it’s active.
* When a new session starts:
* Resets and starts recording the session high/low.
* While session is active:
* Updates `High` with the max of current bar high and previous session high.
* Updates `Low` with the min of current bar low and previous session low.
* When the session is "on":
* Draws a **box** from session low to high (`box.new`) and extends it to the right as long as the session continues.
* Places a **label with session name** (Asia, London, New York, etc.) near the high:
* Style depends on the session (down/right/left).
You have visibility toggles per session:
* `Asia Session`, `Sydney Session`, `Tokyo Session`, `Shanghai Session`, `Europe Session`, `London Session`, `New York Session`, `NYSE` (for TFlab mode).
So you visually see:
* A shaded box for each session
* The full H/L range for that session
* A text label with the session name.
---
#### 5. Info table
The indicator builds a **table in a corner of the chart** showing:
* Header:
* “FOREX Session”, “Stock Market Trading Hours”, “User Custom Session”, or “TFlab suggestion” depending on mode.
* Columns:
1. Session name (Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE)
2. DST status for that region (“Active 🌞 / Inactive 🍂 / Not Observed”)
3. Session **start time**
4. Session **end time**
5. Current **status** (“Open / Closed”, with green/red background)
The function `SplitFunction`:
* Parses the `"HHMM-HHMM"` strings for each session.
* Converts them into:
* Either raw times (if viewing in UTC/session local)
* Or converted times in **Your Time Zone** using `timestamp` and `hour/ minute` with `YourTZ`.
* Returns formatted `Start` and `End` strings like `9:30`, `13:00`, etc.
So the table is effectively a **live session schedule** that:
* Auto-adjusts to DST
* Can show times in your own time zone
* Shows which session is open right now.
---
#### 6. OTT vertical lines (custom intraday markers)
At the bottom, there is an **OTT section** which lets you draw up to **three sets of vertical lines** at specific times:
* Each OTT block has:
* Enable toggle (`Enable OTT 1/2/3`)
* Start hour & minute
* End hour & minute
* Color
* Global OTT settings:
* Line style: `Solid / Dashed / Dotted`
* Line width
* Toggle: “Show OTT Labels?”
Logic:
* `is_ott_time()` checks if current bar’s `hour` and `minute` match the OTT input time.
* `draw_ott()`:
* When the bar time matches, draws a **vertical line** through the candle from low to high (`extend.both`).
* Optionally adds a label above the bar, like `"OTT1 Start"`, `"OTT1 End"`, etc.
Use cases:
* Marking **open/close of your trading session**
* Defining **killzones**, news times, or custom model windows
* Visual anchors for your intraday routine (NY open, 10 AM candle, etc.)
---
### TL;DR
This indicator is a **session toolkit + DST engine + time markers**:
* **Visually paints the main global sessions** with boxes and labels.
* **Handles DST automatically** for Sydney, London, New York.
* **Shows a live table** with session times, DST status, and open/closed status in your time zone.
* **Adds up to three configurable vertical time markers (OTT)** for custom session windows or key times.
If you want, I can also write a **short version** (2–3 sentences) for the TradingView “Description” field.
---
### MP SESSIONS, DST, OTT – What this indicator does
This script is a **multi-session market timing tool** that:
1. **Draws full trading sessions on the chart** (Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE)
2. **Automatically adjusts for Daylight Saving Time (DST)** for Sydney, London, and New York
3. **Shows a live info table** with session times, DST status, and whether each session is currently open or closed
4. **Adds optional custom “OTT” vertical lines** at user-defined intraday times (for your own models, killzones, or time blocks)
---
### Main Features (high level)
#### 1. Market mode & time zone handling
* **Market Mode**:
* `Forex`
* `Stock`
* `User Custom` (you type your own session ranges)
* `TFlab suggestion` (predefined “optimized” session times)
* **Time Zone Mode**:
* `UTC`
* `Session Local Time` (local exchange time: Sydney, Tokyo, London, New York etc.)
* `Your Time Zone` (converts to the user-selected TZ, e.g. `UTC-4:00`)
* Handles separate time zones for:
* Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE
* Has logic to **recalculate session start/end depending on DST** and the chosen mode.
---
#### 2. Daylight Saving Time (DST) engine
The function `DST_Detector`:
* Calculates when DST **starts and ends** for:
* `Australia/Sydney`
* `Europe/London`
* `America/New_York`
* Detects the correct Sunday (2nd, 4th, etc.) for start/end using day-of-week and week counts.
* Returns `'Active'` or `'Inactive'` for each region.
* These values are then used to **shift the sessions** (e.g. New York 13:00–21:00 vs 12:00–20:00 in UTC).
The script can also **draw vertical lines** on the chart when DST starts/ends and label them:
* “Sydney DST Started / Ended”
* “London DST Started / Ended”
* “New York DST Started / Ended”
---
#### 3. Session timing & sessions on the chart
The function `Market_TimeZone_Calculator`:
* Based on **Market Mode** + **Time Zone Mode** + **DST state**, it returns:
* Time ranges for: Sydney, Tokyo, Shanghai, Asia (combined), Europe, London, New York, NYSE
* These ranges are in `"HHMM-HHMM"` format.
Then the script:
* Converts these to `time()` conditions using the proper time zone
* Creates boolean series like `On_sesAsia`, `On_sesEurope`, `On_sesNewYork`, etc., which are **1 when the session is open and 0 when closed**.
---
#### 4. Session high/low boxes & labels
The function `LowHighSessionDetector`:
* Tracks **high and low of each session** while it’s active.
* When a new session starts:
* Resets and starts recording the session high/low.
* While session is active:
* Updates `High` with the max of current bar high and previous session high.
* Updates `Low` with the min of current bar low and previous session low.
* When the session is "on":
* Draws a **box** from session low to high (`box.new`) and extends it to the right as long as the session continues.
* Places a **label with session name** (Asia, London, New York, etc.) near the high:
* Style depends on the session (down/right/left).
You have visibility toggles per session:
* `Asia Session`, `Sydney Session`, `Tokyo Session`, `Shanghai Session`, `Europe Session`, `London Session`, `New York Session`, `NYSE` (for TFlab mode).
So you visually see:
* A shaded box for each session
* The full H/L range for that session
* A text label with the session name.
---
#### 5. Info table
The indicator builds a **table in a corner of the chart** showing:
* Header:
* “FOREX Session”, “Stock Market Trading Hours”, “User Custom Session”, or “TFlab suggestion” depending on mode.
* Columns:
1. Session name (Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE)
2. DST status for that region (“Active 🌞 / Inactive 🍂 / Not Observed”)
3. Session **start time**
4. Session **end time**
5. Current **status** (“Open / Closed”, with green/red background)
The function `SplitFunction`:
* Parses the `"HHMM-HHMM"` strings for each session.
* Converts them into:
* Either raw times (if viewing in UTC/session local)
* Or converted times in **Your Time Zone** using `timestamp` and `hour/ minute` with `YourTZ`.
* Returns formatted `Start` and `End` strings like `9:30`, `13:00`, etc.
So the table is effectively a **live session schedule** that:
* Auto-adjusts to DST
* Can show times in your own time zone
* Shows which session is open right now.
---
#### 6. OTT vertical lines (custom intraday markers)
At the bottom, there is an **OTT section** which lets you draw up to **three sets of vertical lines** at specific times:
* Each OTT block has:
* Enable toggle (`Enable OTT 1/2/3`)
* Start hour & minute
* End hour & minute
* Color
* Global OTT settings:
* Line style: `Solid / Dashed / Dotted`
* Line width
* Toggle: “Show OTT Labels?”
Logic:
* `is_ott_time()` checks if current bar’s `hour` and `minute` match the OTT input time.
* `draw_ott()`:
* When the bar time matches, draws a **vertical line** through the candle from low to high (`extend.both`).
* Optionally adds a label above the bar, like `"OTT1 Start"`, `"OTT1 End"`, etc.
Use cases:
* Marking **open/close of your trading session**
* Defining **killzones**, news times, or custom model windows
* Visual anchors for your intraday routine (NY open, 10 AM candle, etc.)
---
### TL;DR
This indicator is a **session toolkit + DST engine + time markers**:
* **Visually paints the main global sessions** with boxes and labels.
* **Handles DST automatically** for Sydney, London, New York.
* **Shows a live table** with session times, DST status, and open/closed status in your time zone.
* **Adds up to three configurable vertical time markers (OTT)** for custom session windows or key times.
If you want, I can also write a **short version** (2–3 sentences) for the TradingView “Description” field.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。