I moved your question out of the "Alerts and Notifications" topic and into the "Stock Scanners" topic. The Heikin-Ashi code using recursive variables, which means it cannot be used with the Study Alert tool located in the MarketWatch tab of Thinkorswim. So you can only use this code as a scan, chart study or custom watchlist column:
input consecutiveBars = 5;
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haGreen = haClose > haOpen;
def haRed = haClose < haOpen; def consecutiveRed = Sum(haRed, consecutiveBars) == consecutiveBars; def closeAbovePreviousRedBody = haClose > haOpen[1];
plot signal = consecutiveRed[1] and haGreen and closeAbovePreviousRedBody;
Notice I have included a user input to adjust the number of consecutive red bars before the first green.