OPEN-SOURCE SCRIPT
ASIA AND LONDON BOXES

---
### Purpose:
This indicator highlights the **Tokyo (Asia) and London trading sessions** on a price chart by drawing boxes around the price action during these time frames. It helps traders visually identify the price range (high and low) for each session across multiple days.
---
### Key Features:
1. **Timezone Selection:**
* You can select the timezone offset (default `'GMT-7'`) for the session times.
* This adjusts when the sessions start and end according to your preferred timezone.
2. **Sessions Defined:**
* **Tokyo session** defaults to 17:00 to 23:00 (5 PM to 11 PM) in the selected timezone.
* **London session** defaults to 23:00 to 05:00 (11 PM to 5 AM) in the selected timezone.
* These are customizable through `input.session()`.
3. **Session Boxes:**
* For each day and session, the script:
* Tracks the highest high and lowest low price during the session.
* Draws a box on the chart covering that price range over the session time.
* Boxes can be styled either as a solid box or just a background color (configurable).
* Box opacity and colors are customizable.
4. **Multiple Days Back:**
* The indicator keeps boxes visible for a user-defined number of days back (default 3 days).
* Old boxes beyond this limit are deleted to keep the chart clean.
5. **Session Start/End Detection:**
* It detects the start and end of the Tokyo and London sessions based on the selected session times and timezone.
* At session start: initializes tracking variables for high, low, and bars.
* During the session: updates the high and low.
* At session end: finalizes the session box.
6. **Box Drawing Details:**
* Boxes are drawn using price coordinates (`yloc=yloc.price`), meaning the vertical edges correspond exactly to the high and low prices of the session.
* Horizontally, the boxes stretch from the session start bar to the session end bar.
7. **Performance:**
* Uses arrays to manage multiple boxes.
* Periodically cleans up old boxes to avoid performance degradation.
---
### Summary:
* **Visualizes Tokyo and London trading sessions on your chart with colored boxes.**
* **Boxes highlight the price range during each session (high and low).**
* **Allows customization of session times, colors, opacity, style, and timezone.**
* **Maintains boxes for a set number of past days, then cleans up old ones.**
---
### Why is this useful?
For many traders, especially those trading forex or global indices, knowing the price range during the Asian and London sessions is critical. These boxes let you quickly see support/resistance zones and volatility windows linked to these major market hours.
---
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, người tạo ra tập lệnh này đã biến tập lệnh thành mã nguồn mở để các nhà giao dịch có thể xem xét và xác minh công năng. Xin dành lời khen tặng cho tác giả! Mặc dù bạn có thể sử dụng miễn phí, nhưng lưu ý nếu đăng lại mã, bạn phải tuân theo Quy tắc nội bộ của chúng tôi.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.