I have the following function which returns a single value.
function getVolumeHigh_excludeUpBars(period)
{
volume_exclude_up = IIf( ROC(CLOSE,1) < 0, Volume, 0);
SELECTED_BAR = SelectedValue( BarIndex() );
volume_exclude_up[SELECTED_BAR] = Volume[SELECTED_BAR];
volume_High = hhv(volume_exclude_up, period);
return volume_High;
}
I want to convert the above function to return an array instead of a single value. I rewrote the function. Here it is;
function getArray_VolumeHigh_excludeUpBars(period)
{
volume_exclude_up = IIf( ROC(CLOSE,1) < 0, Volume, 0);
for (i=(BAR_COUNT-1);i>=0;i--)
{
volume_exclude_up[i] = Volume[i];
volume_High[i] = hhv(volume_exclude_up, period);
}
return volume_High;
}
The rewritten function is inefficient as it uses for-do loop to assign value individually into the array. Is there a more efficient and elegant way to rewrite the function?