Pine Script News Blackout Timer
Blocks entries for a configurable window around a scheduled news time — CPI, FOMC, NFP — on the NY clock.
//@version=6
strategy("News Blackout", overlay=true, calc_on_every_tick=false)
// ── Inputs ──────────────────────────────────────────────
newsHr = input.int(14, "News Hour (ET)", minval=0, maxval=23,
tooltip="14:00 ET = FOMC statement. 08:30 ET = CPI / NFP.")
newsMin = input.int(0, "News Minute", minval=0, maxval=59)
minsBefore = input.int(10, "Block Minutes Before", minval=0)
minsAfter = input.int(15, "Block Minutes After", minval=0)
// ── Blackout window (NY clock) ───────────────────────────
nyMins = hour(time, "America/New_York") * 60 + minute(time, "America/New_York")
newsMins = newsHr * 60 + newsMin
blackout = nyMins >= newsMins - minsBefore and nyMins <= newsMins + minsAfter
// ── Entry logic (replace with your own conditions) ───────
longCondition = ta.crossover(ta.ema(close, 9), ta.ema(close, 21)) and not blackout
shortCondition = ta.crossunder(ta.ema(close, 9), ta.ema(close, 21)) and not blackout
if longCondition
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", "Long", profit=20, loss=10)
if shortCondition
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", "Short", profit=20, loss=10)
// Visual
bgcolor(blackout ? color.new(color.orange, 88) : na, title="News Blackout")
Settings
newsHr/newsMin— scheduled release time on the NY clock. Default 14:00 (FOMC).minsBefore— minutes blocked before the release. Default 10.minsAfter— minutes blocked after the release. Default 15.
How to use
- Paste into the Pine Editor and replace the EMA-crossover placeholder with your own entry conditions.
- The time is manual — TradingView has no built-in news feed. Set 08:30 ET for CPI/NFP mornings, 14:00 ET for FOMC days.
- Orange shading marks the blackout window so you can verify it against historical releases.
- Some firms restrict news trading on funded accounts — check the rules database for your firm’s policy.
Frequently Asked Questions
How do I stop trading around news in Pine Script?
Enter the scheduled release time as hour/minute inputs, compute a blackout window of N minutes before and after it on the NY clock, and block entries while the current bar falls inside it. The chart shades orange during the blackout so you can verify the window against historical releases.
Can Pine Script detect economic news automatically?
No. Pine Script has no access to an economic calendar or news feed, so the release time must be entered manually. CPI and NFP print at 8:30 AM ET and FOMC statements at 2:00 PM ET, which covers most events that matter for index futures. Update the input on days with a different schedule.
Related
Want a complete eval-ready strategy that survives news days?
This snippet is a building block. Our paid scripts are complete strategies — entries, news-day handling, kill switch, and EOD flatten verified on 3 years of MES/NQ data. Instant delivery from $50.
View Plans — From $50