OPEN-SOURCE SCRIPT

Market Opening Time

19
### TradingView Pine Script "Market Opening Time" Explanation

This Pine Script (`version=5`) is an indicator that visually highlights market trading sessions (Sydney, London, New York, etc.) by changing the chart's background color. It adjusts for U.S. and Australian Daylight Saving Time (DST).

---

#### **1. Overview**
- **Purpose**: Changes the chart's background color based on UTC time zones to highlight market sessions.
- **Features**:
- Automatically adjusts for U.S. DST (2nd Sunday of March to 1st Sunday of November) and Australian DST (1st Sunday of October to 1st Sunday of April).
- Assigns colors to four time zones (00:00, 06:30, 14:00, 21:00).
- **Use Case**: Helps forex/stock traders identify active market sessions.

---

#### **2. Key Logic**
- **DST Detection**:
- `f_isUSDst`: Checks U.S. DST status.
- `f_isAustraliaDst`: Checks Australian DST status.
- **Time Adjustment** (`f_getAdjustedTime`):
- U.S. DST off: Shifts `time3` (14:00) forward by 1 hour.
- Australian DST off: Shifts `time4` (21:00) forward by 1 hour.
- **Time Conversion** (`f_timeToMinutes`): Converts time (e.g., "14:00") to minutes (e.g., 840).
- **Current Time** (`f_currentTimeInMinutes`): Gets UTC time in minutes.
- **Background Color** (`f_getBackgroundColor`):
- Applies colors based on time ranges:
- 00:00–06:30: Orange (Asia)
- 06:30–14:00: Purple (London)
- 14:00–21:00: Blue (New York, DST-adjusted)
- 21:00–00:00: Red (Sydney, DST-adjusted)
- Outside ranges: Gray

---

#### **3. Settings**
- **Time Zones**:
- `time1` = 00:00 (Orange)
- `time2` = 06:30 (Purple)
- `time3` = 14:00 (Blue, DST-adjusted)
- `time4` = 21:00 (Red, DST-adjusted)
- **Colors**: Transparency set to 90 for visibility.

---

#### **4. Example**
- **September 5, 2025, 10:25 PM JST (13:25 UTC)**:
- U.S. DST active, Australian DST inactive.
- 13:25 UTC falls between `time2` (06:30) and `time3` (14:00) → Background is **Purple** (London session).
- **Effect**: Background color changes dynamically to reflect active sessions.

---

#### **5. Customization**
- Modify `time1`–`time4` or colors for different sessions.
- Add time zones for other markets (e.g., Tokyo).

---

#### **6. Notes**
- Uses UTC; ensure chart is set to UTC.
- DST rules are U.S./Australia-specific; verify for other regions.

A simple, visual tool for tracking market sessions.


----

### TradingView Pine Script「Market Opening Time」解説

このPine Script(`version=5`)は、市場の取引時間帯(シドニー、ロンドン、ニューヨークなど)を背景色で視覚化するインジケーターです。米国とオーストラリアの夏時間(DST)を考慮し、時間帯を調整します。

---

#### **1. 概要**
- **目的**: UTC基準の時間帯に基づき、チャートの背景色を変更して市場セッションを強調。
- **機能**:
- 米国DST(3月第2日曜~11月第1日曜)とオーストラリアDST(10月第1日曜~4月第1日曜)を自動調整。
- 4つの時間帯(00:00、06:30、14:00、21:00)に色を割り当て。
- **用途**: FXや株式トレーダーが市場のアクティブ時間を把握。

---

#### **2. 主要ロジック**
- **DST判定**:
- `f_isUSDst`: 米国DSTを判定。
- `f_isAustraliaDst`: オーストラリアDSTを判定。
- **時間調整** (`f_getAdjustedTime`):
- 米国DST非適用時: `time3`(14:00)を1時間遅延。
- オーストラリアDST非適用時: `time4`(21:00)を1時間遅延。
- **時間変換** (`f_timeToMinutes`): 時間(例: "14:00")を分単位(840)に変換。
- **現在時刻** (`f_currentTimeInMinutes`): UTCの現在時刻を分単位で取得。
- **背景色** (`f_getBackgroundColor`):
- 時間帯に応じた色を適用:
- 00:00~06:30: オレンジ(アジア)
- 06:30~14:00: 紫(ロンドン)
- 14:00~21:00: 青(ニューヨーク、DST調整)
- 21:00~00:00: 赤(シドニー、DST調整)
- 時間外: グレー

---

#### **3. 設定**
- **時間帯**:
- `time1` = 00:00(オレンジ)
- `time2` = 06:30(紫)
- `time3` = 14:00(青、DST調整)
- `time4` = 21:00(赤、DST調整)
- **色**: 透明度90で視認性確保。

---

#### **4. 使用例**
- **2025年9月5日22:25 JST(13:25 UTC)**:
- 米国DST適用、豪DST非適用。
- 13:25は`time2`(06:30)~`time3`(14:00)の間 → 背景色は**紫**(ロンドン)。
- **効果**: 時間帯に応じて背景色が変化し、市場セッションを直感的に把握。

---

#### **5. カスタマイズ**
- 時間帯(`time1`~`time4`)や色を変更可能。
- 他の市場(例: 東京)に対応する時間帯を追加可能。

---

#### **6. 注意点**
- UTC基準のため、チャート設定をUTCに。
- DSTルールは米国・オーストラリア準拠。他地域では要確認。

シンプルで視覚的な市場時間インジケーターです。

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.