First and most important item. It is impossible to use your solution on an intraday time frame. Custom scans on Thinkorswim do not permit you to reference a higher time frame within a Study Filter. Since you are computing a daily average of the daily range, you must use a daily time frame.
And even if we reconfigured your code to synthesize the daily data within the intraday time frame, the scan is not able to look back any further than 10-11 days on an intraday time frame. So the length of 14 exceeds that value and even makes it impossible to use synthesized daily data to compute the values in your example.
There is actually an exception to that rule, but you would have to use at least a 1 hour intraday time frame to have access to more than 14 days of historical data.
So for the current version of Thinkorswim, you must use a daily time frame in your Study Filter in order to get this to work. And the following code will accomplish that:
input length = 14;
def dayRange = high – low;
def AvgRange = Average(dayRange, length);
def adrHigh = open + (AvgRange / 2);
def adrLow = open – (AvgRange / 2);
def isAboveAdrHigh = close >= adrHigh;
def isBelowAdrLow = close <= adrLow;
plot scanCondition = isAboveAdrHigh or isBelowAdrLow;
And yes, such a scan would give you immediate results as soon as the daily close passed through the levels from the average daily range you have computed. Meaning that even when using a daily time frame in your scan, you will get real time results from that scan throughout the trading session.
The screenshot below shows the elements of your scan on the price graph, including the signals. The lower subgraph shows when your scan would return a true result for this stock.