The best way I have found to do this is:
//fill in the results for the all bars with the Y indicator into a non
// display buffer
for( int i = 0; i < (Bars - ExtCountedBars); i++)
{
dYBuffer[i] = iCustom(SymbolName(),0,"Y", Param1, Param2...);
}
//Put the AVERAGE of the...