Array question

 
I'm trying to develop an expert that looks back within 100 bars and gives me the max point of a custom indicator (BW below). If I was making an Indicator instead of an Expert, I think I would accomplish this using an Array - but how would I do it in an Expert? see the *** below for where I need help.

Upper=iBands(NULL,0,BB_Period,BB_Deviations,0,PRICE_CLOSE,MODE_UPPER,0);
Lower=iBands(NULL,0,BB_Period,BB_Deviations,0,PRICE_CLOSE,MODE_LOWER,0);
Middle=iMA(NULL,0,BandsPeriod,0,MODE_SMA,PRICE_CLOSE,0);
BW=(Upper-Lower)/Middle;
Q= (***Max value of BW over last 100 bars***)/4 //Define the lowest Quartile range - need help here
If(iClose(NULL,0,0)<Q) // all the other code afterwards I can handle
 
Indicator is easier. In expert you can use array also, but elements will be ascending in oposite direction then in indicator, so you must count them by yourself.
And don't forget to check if there is a new bar! Important with fractal interp. testing.

so

Upper=iBands(NULL,0,BB_Period,BB_Deviations,0,PRICE_CLOSE,MODE_UPPER,0);
Lower=iBands(NULL,0,BB_Period,BB_Deviations,0,PRICE_CLOSE,MODE_LOWER,0);
Middle=iMA(NULL,0,BandsPeriod,0,MODE_SMA,PRICE_CLOSE,0);
BW=(Upper-Lower)/Middle;
if (Time[0]>PrevTime)
{
BWArray[count]=BW;
count++;
}
maxBW=0;
for (i=count-100;i<=count;i++)
{
if(BWArray[i]>maxBW) maxBW=BWArray[i];
}
maxBW/=4;
If(iClose(NULL,0,0)<Q)

also set count in initialization as 0 and BWArray big like last Bars in tester - if you will test it,
or you must set BWArray for 100 elements in initialization part, like
if (Bars>=100)
{
for (i=99;i<=0;i--)
{
Upper=iBands(NULL,0,BB_Period,BB_Deviations,0,PRICE_CLOSE,MODE_UPPER,i);
Lower=iBands(NULL,0,BB_Period,BB_Deviations,0,PRICE_CLOSE,MODE_LOWER,i);
BW=(Upper-Lower)/Middle;
BWArray[i]=BW;
count++;
}
} else "problem"
I didn't compile this, it's just a frame, but I think you can use it.

Regards
Rafael
Reason: