When you construct a scan you set the time frame using the built-in settings. So the code itself will not address the request for 30 min bar. You will simply set the Study Filter to 30 min time frame and insert the code.
plot scan = (high >= low[1] and high <= low[1] * 1.005) or (high <= low[1] and high >= low[1] * 0.995);
Important note. I have interpreted your request literally. “within 0.5 percent”. Which means the high may be below the previous bar’s low as well as being above it, so long as the percentage difference is less than or equal to 0.5%. If you intended to state: “greater than previous low but within 0.5% of the previous low”. This code will need to be modified.