You only need to remove the original plot statements and one new line of code in order to convert that solution to work as a scan. Everything is already there. You need to create a statement that checks if the current high is greater than or equal to the target price.
Here is the scan:
# adjust to set the target value for pre session high
input percentMultiplier = 0.90;
input premarketStart = 400;
input sessionStartTime = 930;
input sessionEndTime = 1615;
def regularSessionHours = SecondsFromTime(sessionStartTime) >= 0 and SecondsTillTime(sessionEndTime) >= 0;
def extendedSessionHours = !regularSessionHours;
def trackPremarket = SecondsFromTime(premarketStart) >= 0 and SecondsTillTime(sessionEndTime) > 0 and extendedSessionHours;
rec premarketLow = if !regularSessionHours[1] and regularSessionHours then Double.NaN else if !trackPremarket[1] and trackPremarket then low else if low > 0 and trackPremarket then Min(low, premarketLow[1]) else premarketLow[1];
rec targetPrice = if regularSessionHours then Double.NaN else if !trackPremarket[1] and trackPremarket then premarketLow * percentMultiplier + premarketLow else targetPrice[1];
plot scan = trackPremarket and high >= targetPrice;
This scan will only work during the premarket hours. Once the regular session begins, the scan will produce zero results.