OPEN-SOURCE SCRIPT
Four Trading Sessions

Ive adapted this from someone else's script to include 4 sessions instead of 3
TradingView Indicator Description: Trading Sessions
Overview:
The "Trading Sessions" indicator, written in Pine Script v5, visually highlights major forex trading sessions (Tokyo, London, New York, and Sydney) on intraday charts. It displays session ranges as colored boxes, with optional open/close lines, average price lines, and labels showing session names, tick ranges, and average prices. Users can customize session times, time zones, colors, and display options.
Key Features:
Customizable Sessions: Supports up to four trading sessions (Tokyo, London, New York, Sydney) with user-defined names, time ranges, and time zones (e.g., "Asia/Tokyo", "America/New_York").
Visual Elements:
Draws semi-transparent boxes to mark session price ranges (high/low).
Optional dashed lines for session open and close prices.
Optional dotted line for the session's average price.
Labels displaying session name, tick range, and/or average price (configurable).
Time Zone Support: Specify time zones using IANA database names (e.g., "Australia/Sydney") or GMT notation, with a recommendation for IANA to handle daylight savings.
Display Options: Toggle session names, open/close lines, tick range, and average price visibility.
Intraday Restriction: Works only on intraday timeframes, with an error for daily/weekly/monthly charts.
Performance Optimized: Limits boxes, lines, and labels to 500 each to ensure smooth performance.
Inputs:
General Settings:
Show session names, open/close lines, tick range, and average price (all enabled by default).
Per Session (Tokyo, London, New York, Sydney):
Enable/disable session display.
Custom session name (e.g., "Tokyo").
Session time range (e.g., "0900-1500" for Tokyo).
Time zone (e.g., "Asia/Tokyo").
Session color (semi-transparent blue, orange, green, purple by default).
How It Works:
The script checks if the current bar falls within a session’s time range (adjusted for the specified time zone).
For each active session, it creates a box spanning the session’s high/low and updates it bar-by-bar.
Optional open/close lines and an average price line are drawn and updated dynamically.
Labels display user-selected metrics (name, range, average price) at the bottom of each session box.
Sessions reset daily, ensuring accurate representation across days.
Use Case:
Ideal for forex traders who want to analyze price action during specific trading sessions. The indicator helps identify session-specific volatility, key price levels, and trends, with clear visual cues and customizable settings.
Limitations:
Only works on intraday timeframes.
Limited to 500 boxes, lines, and labels to prevent performance issues.
Requires accurate time zone settings for proper session alignment.
Example:
Enable the Tokyo and New York sessions, set their respective time zones, and toggle on all display options to see colored boxes, open/close lines, average price lines, and labels with tick ranges and averages for each session.
TradingView Indicator Description: Trading Sessions
Overview:
The "Trading Sessions" indicator, written in Pine Script v5, visually highlights major forex trading sessions (Tokyo, London, New York, and Sydney) on intraday charts. It displays session ranges as colored boxes, with optional open/close lines, average price lines, and labels showing session names, tick ranges, and average prices. Users can customize session times, time zones, colors, and display options.
Key Features:
Customizable Sessions: Supports up to four trading sessions (Tokyo, London, New York, Sydney) with user-defined names, time ranges, and time zones (e.g., "Asia/Tokyo", "America/New_York").
Visual Elements:
Draws semi-transparent boxes to mark session price ranges (high/low).
Optional dashed lines for session open and close prices.
Optional dotted line for the session's average price.
Labels displaying session name, tick range, and/or average price (configurable).
Time Zone Support: Specify time zones using IANA database names (e.g., "Australia/Sydney") or GMT notation, with a recommendation for IANA to handle daylight savings.
Display Options: Toggle session names, open/close lines, tick range, and average price visibility.
Intraday Restriction: Works only on intraday timeframes, with an error for daily/weekly/monthly charts.
Performance Optimized: Limits boxes, lines, and labels to 500 each to ensure smooth performance.
Inputs:
General Settings:
Show session names, open/close lines, tick range, and average price (all enabled by default).
Per Session (Tokyo, London, New York, Sydney):
Enable/disable session display.
Custom session name (e.g., "Tokyo").
Session time range (e.g., "0900-1500" for Tokyo).
Time zone (e.g., "Asia/Tokyo").
Session color (semi-transparent blue, orange, green, purple by default).
How It Works:
The script checks if the current bar falls within a session’s time range (adjusted for the specified time zone).
For each active session, it creates a box spanning the session’s high/low and updates it bar-by-bar.
Optional open/close lines and an average price line are drawn and updated dynamically.
Labels display user-selected metrics (name, range, average price) at the bottom of each session box.
Sessions reset daily, ensuring accurate representation across days.
Use Case:
Ideal for forex traders who want to analyze price action during specific trading sessions. The indicator helps identify session-specific volatility, key price levels, and trends, with clear visual cues and customizable settings.
Limitations:
Only works on intraday timeframes.
Limited to 500 boxes, lines, and labels to prevent performance issues.
Requires accurate time zone settings for proper session alignment.
Example:
Enable the Tokyo and New York sessions, set their respective time zones, and toggle on all display options to see colored boxes, open/close lines, average price lines, and labels with tick ranges and averages for each session.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.