DEV Community

ForexNewsRadar
ForexNewsRadar

Posted on

Open-Source Pine Script v6 Indicator: Highlight US 08:30 ET Pre-News Windows, Rollover & Two-Way Gold Whipsaws

Many intraday losses on Gold (XAU/USD) and EUR/USD have nothing to do with a broken chart setup. They happen because a trader enters a market order or leaves tight resting stops inside the thinnest liquidity windows of the week: the five minutes before 08:30 America/New_York US macro drops (CPI, NFP, Core PCE, GDP), the daily 17:00 ET broker rollover, and the final hour before Friday close.

Below is a clean, zero-repainting Pine Script v6 open-source indicator (FX & Gold Macro Session & Event-Risk Windows) that compiles with zero warnings in TradingView's free Pine Editor. Copy and paste it onto any 1m to 15m chart for XAUUSD, EURUSD, GBPUSD, or USDJPY.

What It Plots on TradingView

  1. Pre-News Thin Liquidity (08:25–08:30 ET, red shade): Automatic America/New_York DST-aware shading for the 5-minute pre-release liquidity pull.
  2. Post-Release Macro Drift Window (08:30–09:30 ET, green shade): Marks the 60-minute window where genuine macro repricing typically plays out after second-one spreads refill.
  3. London Open (07:00–10:00 UTC) & NY Macro Peak (08:00–11:00 ET): Optional low-noise session shading (plus a toggle for Tokyo 00:00–09:00 UTC).
  4. Daily Rollover (17:00–17:15 ET, Sun–Thu) & Friday Pre-Close (16:00–17:00 ET): Flags thin-book windows where spreads widen sharply without a directional catalyst.
  5. Two-Way Whipsaw Expansion Marker: Flags candles whose full range exceeds 1.8x the 100-bar ATR baseline while leaving heavy upper and lower wicks (>28% of bar range on each side), a classic signature of two-way stop sweeps.
  6. Compact Volatility HUD & Built-in Alerts: Displays the active window, live ATR ratio, and volatility regime in the top-right corner with alertcondition() hooks.

Full Pine Script v6 Source Code (MIT / MPL-2.0)

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ForexNewsRadar

//@version=6
indicator(
    title       = "FX & Gold Macro Session & Event-Risk Windows",
    shorttitle  = "Macro Windows",
    overlay     = true
)

// =============================================================================
// Inputs
// =============================================================================
grpSess = "Trading Sessions (UTC)"
showTokyo   = input.bool(false, "Highlight Tokyo Session (00:00–09:00 UTC)", group = grpSess)
showLondon  = input.bool(true,  "Highlight London Open (07:00–10:00 UTC)", group = grpSess)
showNY      = input.bool(true,  "Highlight NY Macro Peak (08:00–11:00 New York)", group = grpSess)

grpMacro = "US Tier-1 Macro Window (08:30 America/New_York, DST-Aware)"
showPreNews   = input.bool(true, "Shade Pre-News Thin Liquidity (08:25–08:30 ET)", group = grpMacro)
showPostDrift = input.bool(true, "Shade Post-Release Drift Window (08:30–09:30 ET)", group = grpMacro)
showRollover  = input.bool(true, "Shade Daily Rollover / Spread Window (17:00–17:15 ET)", group = grpMacro)
showFriClose  = input.bool(true, "Shade Friday Pre-Close Thin Liquidity (16:00–17:00 ET)", group = grpMacro)

grpVol = "Live Volatility Regime HUD"
atrLen      = input.int(14, "ATR Length", minval = 5, maxval = 100, group = grpVol)
atrBaseLen  = input.int(100, "Baseline ATR SMA Length", minval = 20, maxval = 500, group = grpVol)
spikeMult   = input.float(1.8, "Whipsaw / Expansion Alert Multiplier", minval = 1.1, maxval = 5.0, step = 0.1, group = grpVol)
showHud     = input.bool(true, "Show Compact Session & Volatility Table", group = grpVol)

// =============================================================================
// Time-Zone Aware Session Detection (Automatic US DST Handling)
// =============================================================================
isIntraday = timeframe.isintraday

inTokyo    = isIntraday and not na(time(timeframe.period, "0000-0900:1234567", "UTC"))
inLondon   = isIntraday and not na(time(timeframe.period, "0700-1000:1234567", "UTC"))
inNYPeak   = isIntraday and not na(time(timeframe.period, "0800-1100:23456",   "America/New_York"))

inPre830   = isIntraday and not na(time(timeframe.period, "0825-0830:23456",   "America/New_York"))
inDrift830 = isIntraday and not na(time(timeframe.period, "0830-0930:23456",   "America/New_York"))
inRollover = isIntraday and not na(time(timeframe.period, "1700-1715:12345",   "America/New_York"))
inFriClose = isIntraday and not na(time(timeframe.period, "1600-1700:6",       "America/New_York"))

// =============================================================================
// Real-Time Volatility & Two-Way Wick (Whipsaw) Telemetry
// =============================================================================
atrNow     = ta.atr(atrLen)
atrBase    = ta.sma(atrNow, atrBaseLen)
volRatio   = atrBase > 0 ? atrNow / atrBase : 1.0

barRange   = high - low
upperWick  = high - math.max(open, close)
lowerWick  = math.min(open, close) - low
isWhipsawBar = barRange > atrBase * spikeMult and upperWick > barRange * 0.28 and lowerWick > barRange * 0.28

// =============================================================================
// Background Shading
// =============================================================================
colTokyo    = color.new(#3B82F6, 94)
colLondon   = color.new(#06B6D4, 93)
colNY       = color.new(#F59E0B, 94)
colPreNews  = color.new(#EF4444, 82)
colDrift    = color.new(#10B981, 91)
colRollover = color.new(#A855F7, 86)
colFriClose = color.new(#F97316, 86)

bgcolor(showTokyo and inTokyo ? colTokyo : na, title = "Tokyo Session")
bgcolor(showLondon and inLondon ? colLondon : na, title = "London Open")
bgcolor(showNY and inNYPeak ? colNY : na, title = "NY Macro Peak")
bgcolor(showPostDrift and inDrift830 ? colDrift : na, title = "08:30 ET Post-Release Drift")
bgcolor(showPreNews and inPre830 ? colPreNews : na, title = "08:25-08:30 ET Pre-News Window")
bgcolor(showRollover and inRollover ? colRollover : na, title = "Daily Rollover Window")
bgcolor(showFriClose and inFriClose ? colFriClose : na, title = "Friday Pre-Close Window")

plotshape(
    isWhipsawBar,
    title     = "Two-Way Whipsaw Expansion",
    style     = shape.triangledown,
    location  = location.abovebar,
    color     = color.new(#EF4444, 15),
    size      = size.tiny
)

// =============================================================================
// Compact Top-Right Session & Volatility HUD
// =============================================================================
var table hud = table.new(position.top_right, 2, 4, bgcolor = color.new(#0B0F19, 15), border_width = 1, border_color = color.new(#334155, 40))

if barstate.islast and showHud
    sessText = inPre830 ? "PRE-NEWS (08:25-08:30 ET)" :
               inDrift830 ? "POST-8:30 ET DRIFT" :
               inRollover ? "ROLLOVER (THIN BOOK)" :
               inFriClose ? "FRIDAY CLOSE RISK" :
               inNYPeak ? "NEW YORK PEAK" :
               inLondon ? "LONDON OPEN" :
               inTokyo ? "TOKYO SESSION" : "OFF-PEAK"

    sessCol = inPre830 or inRollover or inFriClose ? color.new(#F87171, 0) :
              inDrift830 ? color.new(#34D399, 0) :
              color.new(#FBBF24, 0)

    regimeText = isWhipsawBar ? "TWO-WAY WHIPSAW" :
                 volRatio >= spikeMult ? "HIGH VOLATILITY" :
                 volRatio >= 1.25 ? "ELEVATED" : "NORMAL"

    regimeCol = isWhipsawBar or volRatio >= spikeMult ? color.new(#F87171, 0) :
                volRatio >= 1.25 ? color.new(#FBBF24, 0) :
                color.new(#34D399, 0)

    table.cell(hud, 0, 0, "Window", text_color = color.new(#94A3B8, 0), text_size = size.small, text_halign = text.align_left)
    table.cell(hud, 1, 0, sessText, text_color = sessCol, text_size = size.small, text_halign = text.align_right)

    table.cell(hud, 0, 1, "Vol Ratio", text_color = color.new(#94A3B8, 0), text_size = size.small, text_halign = text.align_left)
    table.cell(hud, 1, 1, str.tostring(volRatio, "0.00") + "x ATR", text_color = color.white, text_size = size.small, text_halign = text.align_right)

    table.cell(hud, 0, 2, "Regime", text_color = color.new(#94A3B8, 0), text_size = size.small, text_halign = text.align_left)
    table.cell(hud, 1, 2, regimeText, text_color = regimeCol, text_size = size.small, text_halign = text.align_right)

    table.cell(hud, 0, 3, "Timeframe", text_color = color.new(#94A3B8, 0), text_size = size.small, text_halign = text.align_left)
    table.cell(hud, 1, 3, isIntraday ? timeframe.period : "Use <= 15m", text_color = color.new(#CBD5E1, 0), text_size = size.small, text_halign = text.align_right)

// =============================================================================
// Alerts
// =============================================================================
alertcondition(inPre830 and not inPre830[1], title = "US 08:25 ET Pre-News Window", message = "Entering 08:25-08:30 ET thin-liquidity pre-news window on {{ticker}}.")
alertcondition(isWhipsawBar, title = "Two-Way Whipsaw Bar", message = "Two-way volatility expansion (whipsaw candle) detected on {{ticker}}.")
Enter fullscreen mode Exit fullscreen mode

Pairing Chart Windows With Live Macro Verdicts & Automated VETO

Pine Script sees OHLC bars and session clocks, not whether an actual 08:30 ET US Core PCE or NFP print aligned cleanly or collided with companion releases.

If you also want live directional BUY / SELL macro drift verdicts alongside automated T-5m pre-news and post-release VETO flags across 18 FX and Gold pairs (plus Zero-DLL MT5, our official zero-dependency Python SDK pip install forexnewsradar on PyPI, and Remote MCP), EUR/USD is permanently free with no login or API key at ForexNewsRadar. You can also check the live 2026 Prop Firm News Rules Table before major releases.

Top comments (2)

Collapse
 
kamalmosadegh profile image
Kamal Mosadegh •

The DST-aware timezone handling is the part most people get wrong, so good call making it explicit — hardcoding EST is how these indicators silently shift an hour in March and November.

One thing worth checking: your whipsaw rule measures the bar's range against a 100-bar ATR on the same 1-minute bars, and that baseline inflates during the release itself — the 08:30 bar's own range is part of the 100-bar average, so the 1.8x threshold gets harder to reach exactly when the move is happening. A cleaner test is to freeze the ATR at 08:25 ET, before the window opens, and measure the 08:30 bar against that frozen value. If the flag rate drops a lot, the rule was mostly measuring its own baseline moving. I ran into the same moving-baseline problem while building DipCatcher: a threshold that looks stable in backtest but moves with the event it's supposed to detect.

Also worth a quick count: of the bars your rule flags inside the 08:30–09:30 window, how many are followed by a directional move vs. a reversal back through the open? That split tells you whether the marker is a "stay out" signal or a "fade the spike" signal — they're opposite trades.

Collapse
 
forexnewsradar profile image
ForexNewsRadar •

Great catch on both points — appreciate the careful read.

  1. ATR baseline self-inflation at 08:30 ET: You're completely right. Because ta.atr(100) includes the current release bar, a large CPI/NFP candle immediately lifts the denominator on the exact bar you're trying to classify (and bleeds into the next few bars via RMA smoothing). Freezing the pre-window baseline (var float preNewsAtr = na captured right at 08:25 ET before the window opens, or referencing ta.atr(100)[1] for a single-bar check) gives a much cleaner apples-to-apples ratio without moving the goalpost mid-shock.

  2. Stay-out vs. fade-the-spike split: In this lightweight chart-only Pine script, the marker is strictly a stay-out / execution-hygiene flag — pure 1-minute OHLC geometry without the actual macro release surprise cannot reliably separate a real continuation impulse from a mean-reverting stop sweep. That's the exact reason our server-side pipeline splits the two problems: waiting through a ~15–30s post-print stabilization window to let the initial liquidity vacuum clear, then classifying directional 15–60m+ post-announcement drift separately from two-way Whipsaw/Collision VETO blocks.

Freezing the baseline at 08:25 ET is a genuinely clean upgrade for v1.1 of the open-source script — thanks for pointing it out.