OPEN-SOURCE SCRIPT
2 AM 4H Candle Levels

**2 AM 4H Candle Levels**
This indicator marks the high and low of the 4-hour candle that opens at 2:00 AM and projects those levels forward through the rest of the trading day — for every historical day on the chart as well as the current session.
Many intraday strategies treat the early-morning 4H range (2 AM – 6 AM) as a key reference: it often brackets the pre-session liquidity that price later sweeps or respects once the more active hours begin. This tool makes that range visible at a glance so you can watch how price interacts with it — breakouts, retests, or rejections — without redrawing levels every day.
**What it draws**
- **Window box** — a box spanning the full 4H window, from the 2 AM open to the 6 AM close, framed at the candle's high and low. The left and right borders mark the open and close times; the top and bottom borders trace the range. Optional fill with adjustable transparency.
- **Extended level lines** — from the 6 AM close, a high line and a low line carry the range forward. You choose where they stop: **End of day**, or a **Custom time** you set (e.g. 9:30 AM for the NYSE open).
- On the **current day**, the box builds in real time while the 2 AM candle is still forming, and the lines can optionally extend to the right edge of the chart until their cutoff arrives.
**Settings**
- **4H candle open hour** — defaults to 2 AM; anchor the window to any hour.
- **Timezone** — "Exchange" by default; set it to match your chart's displayed timezone (UTC, America/New_York, GMT+2, …) so the window lands on the candle you see.
- **Lines end at** — End of day, or a custom hour/minute (24-hour clock).
- **Window box** — show/hide, border color, width, style (solid/dashed/dotted), and fill color.
- **Extended lines** — independent colors for the high and low lines, width, and style.
**How it works**
The script does not rely on `request.security`. It identifies all chart bars whose open time falls inside the 4-hour window (in your chosen timezone) and accumulates their high and low directly. This keeps the levels accurate and non-repainting on any intraday timeframe — from 1 minute up to 4 hours — and means the levels appear at the window itself rather than four hours late, a common artifact of higher-timeframe data requests.
**Notes & limitations**
- Works on intraday timeframes up to 4H. On Daily and above a whole day is a single bar, so there is nothing to draw; the indicator shows a small notice instead.
- If the levels don't line up with the candle you expect, the timezone setting is almost always the reason — match it to the clock at the bottom-right of your chart.
- TradingView caps drawing objects per indicator, so history reaches back roughly 250 trading days.
---
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.