search for the value of an indicator in the first candle back by indefinite candles

 
Good morning,

I use an icustom function to look up the value of a buy or sell indicator in the previous candle:

ex:
double xyz (int index, int shift)
{
 return (iCustom (Symbol (), PERIOD_H1, "indicator", index, shift));
 }

then in the ontick function I specify the following:

if (
xyz (1,1) <= - 5&& stdscore (1, 1)! = EMPTY_VALUE)
{
ordersend ..... etc}

My indicator does not give a signal for each candle but only when there are certain conditions.

Suppose I want to find the first value in the last 100 candles before the current one. I don't know if it's the candle -2 or -5 or -20 etc ...

how can I do?

Thanks
 
Claudio Lasso: Suppose I want to find the first value in the last 100 candles before the current one.
When in doubt, think!
int iLast=1; while( xyz(1, iLast) == EMPTY_VALUE) ++iLast;