DefParam CumulateOrders=False
DefParam PreLoadBars=1000
ONCE LongSignal = 0
ONCE ShortSignal = 0
BollingerMiddle = Average[20](Close)
BollingerUpper = BollingerUp[20](close)
BollingerLower = BollingerDown[20](close)
haClose = (Open + High + Low + Close) / 4
If barindex=0 then
haOpen=Open
else
haOpen = (haOpen[1] + haClose[1]) / 2
EndIf
haHigh = max(High, max(haOpen, haClose))
haLow = min(Low, min(haOpen, haClose))
// Detect Heikin-Ashi close below lower Bollinger Band
if haClose[1] < BollingerLower[1] then
LongSignal = 1 // Mark as potential buy signal
endif
// Detect Heikin-Ashi close above upper Bollinger Band
if haClose[1] > bollingerUpper[1] then
ShortSignal = 1 // Mark as potential sell signal
endif
// Confirm Buy: First Green HA Candle After Long Signal
if LongSignal = 1 and haClose > haOpen then
Buy 1 Contract at Market
longSignal = 0 // Reset signal after entry
endif
// Confirm Sell: First Red HA Candle After Short Signal
if ShortSignal = 1 and haClose < haOpen then
SellShort 1 Contract at Market
ShortSignal = 0 // Reset signal after entry
endif
GraphOnPrice BollingerUpper as "Upper"
GraphOnPrice BollingerLower as "Lower"