OPEN-SOURCE SCRIPT

MP SESSIONS, DST, OTT

201
MP SESSIONS, DST, OTT – What this indicator does

This script is a multi-session market timing tool that:

Draws full trading sessions on the chart (Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE)

Automatically adjusts for Daylight Saving Time (DST) for Sydney, London, and New York

Shows a live info table with session times, DST status, and whether each session is currently open or closed

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:

Session name (Asia, Sydney, Tokyo, Shanghai, Europe, London, New York, NYSE)

DST status for that region (“Active 🌞 / Inactive 🍂 / Not Observed”)

Session start time

Session end time

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.)

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.