OPEN-SOURCE SCRIPT
Cập nhật CVR Earnings Window Filter

What It Does
The indicator answers a single practical question on every chart: how close is the next earnings event, and does that proximity matter for my trading decision?
It calculates the number of calendar days between right now and the next scheduled earnings release using TradingView's built-in earnings.future_time variable, which holds the Unix timestamp of the next announced earnings date for the current symbol.
Inputs
ParameterDefaultRangeDescriptionN — days until earnings51–60Width of the earnings window in calendar daysFilter modeAvoid window—Controls which condition is a pass
Core Calculation
days_until = floor( (earnings.future_time − timenow) / 86,400,000 )
Floored to full calendar days. Earnings day itself is always day 0 and is always excluded from the window. The active window is the interval [1, N].
days_untilMeaningnaNo earnings date on file for this symbol0Earnings today — excluded from window1Earnings tomorrow — first day inside window> NOutside window — far enough from earnings
Filter Modes
Avoid Window — passes = true when the symbol is outside the window. Enforces a pre-earnings blackout zone (e.g. no new entries within 5 days of a report). Symbols with no date on file (na) pass as safe.
Target Window — passes = true when the symbol is inside the window. Surfaces stocks approaching an earnings catalyst for pre-earnings setup hunting.
Visual Output
Blue step-line — raw days_until value per bar
Dashed line at N — outer boundary; when the line crosses below, the window is active
Dotted lines at 1 and 0 — inner boundaries marking the earnings day itself
Orange background — active whenever the window is open (1 ≤ days_until ≤ N)
Label on last bar — green if the symbol passes the active mode, red if blocked
Edge Cases
No date (na): Avoid mode passes, Target mode blocks
Earnings today (0): outside the window in both modes — the earnings day is never included
Calendar vs. trading days: the calculation uses raw calendar days; a Monday report shows 2 on Friday, not 1
Data accuracy: depends on whether TradingView has a confirmed date; unconfirmed estimates may differ from the actual report
The indicator answers a single practical question on every chart: how close is the next earnings event, and does that proximity matter for my trading decision?
It calculates the number of calendar days between right now and the next scheduled earnings release using TradingView's built-in earnings.future_time variable, which holds the Unix timestamp of the next announced earnings date for the current symbol.
Inputs
ParameterDefaultRangeDescriptionN — days until earnings51–60Width of the earnings window in calendar daysFilter modeAvoid window—Controls which condition is a pass
Core Calculation
days_until = floor( (earnings.future_time − timenow) / 86,400,000 )
Floored to full calendar days. Earnings day itself is always day 0 and is always excluded from the window. The active window is the interval [1, N].
days_untilMeaningnaNo earnings date on file for this symbol0Earnings today — excluded from window1Earnings tomorrow — first day inside window> NOutside window — far enough from earnings
Filter Modes
Avoid Window — passes = true when the symbol is outside the window. Enforces a pre-earnings blackout zone (e.g. no new entries within 5 days of a report). Symbols with no date on file (na) pass as safe.
Target Window — passes = true when the symbol is inside the window. Surfaces stocks approaching an earnings catalyst for pre-earnings setup hunting.
Visual Output
Blue step-line — raw days_until value per bar
Dashed line at N — outer boundary; when the line crosses below, the window is active
Dotted lines at 1 and 0 — inner boundaries marking the earnings day itself
Orange background — active whenever the window is open (1 ≤ days_until ≤ N)
Label on last bar — green if the symbol passes the active mode, red if blocked
Edge Cases
No date (na): Avoid mode passes, Target mode blocks
Earnings today (0): outside the window in both modes — the earnings day is never included
Calendar vs. trading days: the calculation uses raw calendar days; a Monday report shows 2 on Friday, not 1
Data accuracy: depends on whether TradingView has a confirmed date; unconfirmed estimates may differ from the actual report
Phát hành các Ghi chú
noneMã 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.