# How to check conditions on loops

Looping through the closes of 3-50 candles to see if the close is below a bb-band, how can i go about coding to  check if any one of the closes is above the yellow moving average and all canles are below the mid bb-band

```for(int i=3: i<50; i++)
{
if(close[1] < close[i])
{
// true in this case
if(check if any one of the closes is above moving average)
{
if(check if all closes are below mid bb-band)
{
}
}
}
}```

Looping through the closes of 3-50 candles to see if the close is below a bb-band, how can i go about coding to  check if any one of the closes is above the yellow moving average and all canles are below the mid bb-band

There is a good example on how to get the Band Values (you have different arrays for each band) just compare its values.

The example on the link below, [look] inside the OnTick function, it has everything you need to code yours: (how to get the arrays data, values of each candle, etc.. ) Then you just compare those band values on your code, and do your own algorithm decisions.

339264

rrocchi:

There is a good example on how to get the Band Values (you have different arrays for each band) just compare its values.

The example on the link below, [look] inside the OnTick function, it has everything you need to code yours: (how to get the arrays data, values of each candle, etc.. ) Then you just compare those band values on your code, and do your own algorithm decisions.

339264

You didn't get my question, I know how to access array values, I do not know which index in the array satisfies the condition, that's why I want to know how I can find out which index of that array satisfies the condition