Purpose: To visually identify and differentiate between the Asian, London, and New York trading sessions on the chart, and to provide alerts when a session starts or ends.
Features:
Highlights the background of the chart during each session.
Includes a mini dashboard in the top-right corner to show the active session.
Provides alerts to notify when a session starts or ends.
Allows customization of time zones (exchange timezone or UTC).
Displays copyright and author information.
Key Components
Inputs:
useExchangeTimezone: A boolean input to toggle between using the exchange timezone or UTC for session times.
showDashboard: A boolean input to toggle the visibility of the mini dashboard.
Session Times:
The script defines three trading sessions:
Asian Session: 2000-0000 UTC (or adjusted for exchange timezone).
London Session: 0200-0500 UTC (or adjusted for exchange timezone).
New York Session: 0700-1000 UTC (or adjusted for exchange timezone).
Session Detection:
The is_session function checks if the current time falls within a specified session using the time function.
Background Coloring:
The bgcolor function is used to highlight the chart background during each session:
Asian Session: Red background.
London Session: Green background.
New York Session: Blue background.
Mini Dashboard:
A table is created in the top-right corner of the chart to display the active session and its corresponding color.
The dashboard includes:
A header row with "Session" and "Color".
Rows for each session (Asian, London, New York) with their respective colors.
Copyright and Author Information:
A label is added to the chart to display the copyright and author information ("© ICT Session by Lasins Raj").
Alerts:
Alerts are added to notify when a session starts or ends.
Alert conditions are defined for:
Asian Session Start and End.
London Session Start and End.
New York Session Start and End.
Alerts are triggered when the current bar transitions into or out of a session.
How It Works
Session Highlighting:
The script checks the current time and compares it to the predefined session times.
If the current time falls within a session, the chart background is highlighted with the corresponding color.
Mini Dashboard:
The dashboard updates to reflect the active session and its color.
Alerts:
Alerts are triggered when a session starts or ends.
For example:
If the current bar is within the Asian session and the previous bar was not, the "Asian Session Start" alert is triggered.
If the current bar is outside the Asian session and the previous bar was within it, the "Asian Session End" alert is triggered.