Hi

i have 1 variable called "ms" which is a data that i get from sensor reading. So ms will always read the data that got sensor

If i want to set the condition to check first that if the second data that I received is less than the first data , if it less than the first data keep it, else throw it away. Then start to compare the latest data that coming with the older data that pass the condition.

For example

ms = 23,20,10,22,9,7,6,5,8,2

first: compare 23 with 20 >> " keep 20

So ms collect: 23, 20

Then: compare 20 with 1o >> ' keep 10

So ms now have: 23,20,10

Then: compare next coming data 10 with 22 >> fail condition throw away this data

So ms have:23,20,10

Then : compare 10 with 9 >> pass condition keep 9

So finally ms have : 23,20,10,9

if ms have 4 data sum it and calculate average and then continue doing this and the first

How do I loop to check the data? it's kinda basic skill but i still confused

Really Appreciate for any help and suggestion, Thank you