Test a condition for n times and take action

i have to test a condition for n times and if its value is greater than one each time for continuous 5 iterations it will take action

My Approach

run the same command 5 times in for loop and divert the output to a file and then read the values from file and use if else if and take action

Is the above approach looks good
or can you suggest better ?

Very superficial question, no detailed answer possible. Still: No need for a file. Increment a variable for a "good" result, or reset to zero if bad, then test variable for 5.

If not satisfactory: more details, please.