Custom field for intervals

I have added a custom field, that shows total time between specific heartrate.

Below you can see the custom field (Orange)

I need the time to be for each intervals, and not for the full activity

My current code is:

hr = streams.fixed_heartrate
max= 144
min = 134
tiz = 0
for (let i = 0; i < hr .length; i++) {
if ( hr[i] >= min && hr[i] <= max) {
   tiz++
}
}
tiz
1 Like

You need to limit your loop to only look within each interval.

for (let i = interval.start_index; i < interval.end_index; i++)

Works like a charm! Thank you very much!