htfBullish = htfHigh[2] < htfHigh[1] and htfHigh[1] < htfHigh[0] and htfLow[2] < htfLow[1] and htfLow[1] < htfLow[0]
// 2. Find HTF Support (Recent Swing Low) var float htfSupport = na htfSwingLow = ta.pivotlow(htfLow, 2, 2) if not na(htfSwingLow) htfSupport := htfSwingLow
// 3. Detect Order Blocks on LTF var float[] obHighs = array.new_float() var float[] obLows = array.new_float()
if bearishCandle and bullishBreak and nearSupport and htfBullish array.unshift(obHighs, high[1]) array.unshift(obLows, low[1])
// Keep only recent OBs if array.size(obHighs) > obLookback array.pop(obHighs) array.pop(obLows)
detectOB()
// 4. Entry Conditions var bool entrySignal = false var float entryPrice = na var float stopLoss = na var float takeProfit = na
for i = 0 to array.size(obHighs)-1 obH = array.get(obHighs, i) obL = array.get(obLows, i)
// Check price return to OB zone if low <= obH and high >= obL and not entrySignal entrySignal := true entryPrice := obL stopLoss := obL - (obL * 0.001) takeProfit := htfHigh[0] break