Narrow Range AFL

Hi All,
Can you please assist me in completing this code snippet to detect a narrow range ticker.
scenarios are like, 8.45 am market opens, starting from 9.45 am to the mid of the day around 12.45 noon the exploration run on the m5 time frame and detect the narrow range tickers. almost 30 m5 bars must have been

TimeFrameSet(in5Minute);
hvalue = HHV(High,35);           // Highest Value among 35 Bars 
lvalue = LLV(Low, 35);     // Lowest Value among 35 bars
rbars = 0; 
for (i=1; i<=35 ; i++) 
{
IIf(High[i] <= hvalue AND Low[i] >= lvalue, rbars++, Null); 
}
Ranging = IIf(rbars >= 30, True, False);

TimeFrameRestore(); 
Filter = 1;
AddColumn(hvalue, "highestvalue"); 
AddColumn(lvalue, "lowestvalue"); 
AddColumn(rbars, "rangingbars");