you are not wrong, but the next line simply moves quickly on if price is below Close - 5*Grid



Code:
// find the lowest grid line
if(Price < Close-5*Grid) continue;