Now, we modify the entry logic from the previous script to enforce the regime alignment before firing the continuation trade. We also add a directional lock so we don't accidentally take a short continuation setup in a bullish 4-hour regime.
// =========================================================================
// UPDATED EXECUTION ENGINE (With MTF Filter)
// =========================================================================
// Entry Engine
if state == MarketState.PostNewsWindow and struct.isLocked and strategy.position_size == 0
// Evaluate Long Setup
bool inDiscountZoneLong = close > struct.fib618 and low <= struct.fib50
bool isTrendAlignedLong = htfTrend == Regime.Bullish
if inDiscountZoneLong and isSpreadTight and isTrendAlignedLong and lotSize > 0
strategy.entry("Macro_Cont_Long", strategy.long, qty=lotSize)
strategy.exit("Macro_Risk", "Macro_Cont_Long", stop=close - stopDist, limit=struct.impHigh)
tradeStartTime := currMins
// (Optional) Evaluate Short Setup using the same logic inverted
// bool inPremiumZoneShort = close < struct.fib618 and high >= struct.fib50
// bool isTrendAlignedShort = htfTrend == Regime.Bearish
// if inPremiumZoneShort and isSpreadTight and isTrendAlignedShort...
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
By isolating getHtfRegime()[1] with lookahead=barmerge.lookahead_on, you force the script to ask: "What was the 4-hour trend state at the exact millisecond before the 08:30 CPI candle opened?"
If you are scalping the 1-minute or 5-minute chart during the digest, the algorithm will hold that pre-news 4H bias constant, allowing you to confidently trade the structural 50% retrace in the direction of the dominant institutional flow.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.