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.
---
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.