Pine Script News Blackout Timer

Blocks entries for a configurable window around a scheduled news release — CPI, FOMC, NFP — measured on the NY clock.

Pine Script v6 Free · TradingView free plan
Pine Script
//@version=6
strategy("Target Filled - News Blackout Filter Example", overlay=true, calc_on_every_tick=false)

// --- Inputs ---------------------------------------------------
releaseHour = input.int(14, "Release Hour (ET)", minval=0, maxval=23,
     tooltip="14:00 ET = FOMC statement. 08:30 ET = CPI / NFP.")
releaseMin  = input.int(0, "Release Minute", minval=0, maxval=59)
padBefore   = input.int(10, "Minutes Blocked Before", minval=0)
padAfter    = input.int(15, "Minutes Blocked After", minval=0)

// --- Blackout window on the NY clock ------------------------------
nyClockMins = hour(time, "America/New_York") * 60 + minute(time, "America/New_York")
releaseMins = releaseHour * 60 + releaseMin
inBlackout  = nyClockMins >= releaseMins - padBefore and nyClockMins <= releaseMins + padAfter

// --- Sample signal — replace with your own entry logic ---------
fastMA = ta.ema(close, 9)
slowMA = ta.ema(close, 21)
canLong  = ta.crossover(fastMA, slowMA)  and not inBlackout
canShort = ta.crossunder(fastMA, slowMA) and not inBlackout

if canLong
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", "Long", profit=20, loss=10)

if canShort
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", "Short", profit=20, loss=10)

// Visual
bgcolor(inBlackout ? color.new(color.orange, 88) : na, title="News Blackout")

Settings

InputDefaultPurpose
releaseHour14Scheduled release hour on the NY clock. 14 = FOMC; 8 = CPI/NFP.
releaseMin0Scheduled release minute.
padBefore10Minutes blocked before the release.
padAfter15Minutes blocked after the release.

How to use

  • Paste into the Pine Editor and swap the EMA-crossover placeholder for your own entry conditions.
  • The release time is entered manually — there's no news feed inside Pine. Set 8:30 ET for CPI/NFP mornings, 14:00 ET for FOMC days.
  • Orange shading marks the blackout window on the chart so you can verify it against historical releases before going live.
  • Some firms restrict news trading outright on funded accounts — check the rules database for your firm's current policy.
FTMO's rule is stricter than a pad window. No new position within 2 minutes before or after a high-impact news release — a violation can void the Challenge.

Frequently Asked Questions

How do I stop trading around news in Pine Script?
Enter the release time as hour/minute inputs, convert the current bar to minutes-of-day on the NY clock, and compare it against a window of N minutes before and after the release. Gate every entry condition with the resulting boolean. Orange shading on the chart lets you eyeball the window against past releases before trusting it live.
Can Pine Script detect economic news automatically?
No — TradingView has no built-in economic calendar, so the release time has to be entered by hand. CPI and NFP print at 8:30 AM ET; FOMC statements land at 2:00 PM ET. That covers most of what moves index futures, but update the input on any day with a different schedule.

Get a Pine Script tuned to your prop firm.

Invite-only on TradingView within 24 hours. From $19/mo, cancel anytime.