OPEN-SOURCE SCRIPT
Cập nhật Daily Structure Map

Plots key daily price levels and detects significant gap movements between sessions, helping traders quickly identify where price opened and closed relative to the previous day.
Features:
Daily Open & Close lines — color-coded red/green based on current price position, so you instantly know if price is trading above or below key daily levels
Day Separators — dashed vertical lines that mark the start of each new trading day, working consistently across all instruments including 24/7 markets like gold (XAUUSD) and crypto
GAP Signal — cross markers that fire when the percentage difference between two consecutive daily closes exceeds a configurable threshold, highlighting meaningful breakout gaps
Alerts — built-in long and short gap breakout alerts you can set and forget
Best used on intraday timeframes (1m–1H) to see daily structure overlaid on your lower timeframe charts. Fully customizable threshold, separator color, and timeframe seeker to adapt to any instrument or trading style.
Features:
Daily Open & Close lines — color-coded red/green based on current price position, so you instantly know if price is trading above or below key daily levels
Day Separators — dashed vertical lines that mark the start of each new trading day, working consistently across all instruments including 24/7 markets like gold (XAUUSD) and crypto
GAP Signal — cross markers that fire when the percentage difference between two consecutive daily closes exceeds a configurable threshold, highlighting meaningful breakout gaps
Alerts — built-in long and short gap breakout alerts you can set and forget
Best used on intraday timeframes (1m–1H) to see daily structure overlaid on your lower timeframe charts. Fully customizable threshold, separator color, and timeframe seeker to adapt to any instrument or trading style.
Phát hành các Ghi chú
Week separator logic, short-vs-long name toggle, 1H-only restriction, custom horizontal offsets, background mode — all overkill for "minimum"Phát hành các Ghi chú
Separator settings group — color, style (Solid/Dashed/Dotted dropdown), and width (1–5)Open/Close span settings group — same three controls for the horizontal day spans, since you'll likely want those styled too
Inputs grouped — group="..." parameter organizes the settings panel into clear sections instead of one long list
Style strings get converted to Pine's line.style_* constants via ternary lookup
Phát hành các Ghi chú
Levels:PDH / PDL / PDC — Previous Day High, Low, Close
PWH / PWL — Previous Week High, Low
PMH / PML / PMC — Previous Month High, Low, Close
Phát hành các Ghi chú
## Changelog — v1.1.0**Released:** May 2026
### Added
- **Levels** section: 8 previous-period reference lines drawn as right-extending rays anchored to their origin bars
- PDH, PDL, PDC — previous day high, low, close
- PWH, PWL — previous week high, low
- PMH, PML, PMC — previous month high, low, close
- Each level has its own toggle and color picker
- Shared line style (Solid / Dashed / Dotted) and width controls for all levels
- Right-side labels (PDH, PDL, etc.) that stay pinned to the latest bar
- Master "Show Levels" and "Show Labels" toggles
### Changed
- Daily open and previous close now render as **horizontal lines spanning the full width of each day** instead of per-bar dot stacks
- Open/Close Spans moved into its own settings group with color, style, and width controls
- Day Separators settings split into a dedicated group with color, style (Solid / Dashed / Dotted), and width controls
- Day-of-week labels (Mon, Tue, Wed…) shown above each new day with a color picker
- Indicator renamed from "Daily Close GAP Detector" to **Daily Structure Map**
- `max_bars_back` raised from 1000 to 5000 as a safety net
### Fixed
- Day separators not appearing on 24/7 instruments (XAUUSD, crypto). Now uses `ta.change(time("D"))` which works on all session types
- PML / PMH / PWL / PWH not drawing on lower timeframes due to `max_bars_back` lookback limits. Origin bars are now captured in real time as new highs/lows form, instead of being looked up via historical bar references
### Migration notes
- Existing alerts (`SHORT GAP BREAKOUT`, `LONG GAP BREAKOUT`) are unchanged
- Default settings reproduce a similar visual to v1.0 — no action needed after upgrade
- If you previously hid the dotted open/close circles by setting a transparent color, you can now toggle them off via "Show Daily Open/Close Spans"
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.