Have change the function, have put in an extra variable so that you can choose the max size of the array, 10 in the example. Also made the return type an bool so that you know when the array have reached it max size.
Code:
int start()
{
static double a[];
if(AddDataToMaxArray(a, Bid, 10))
{
//Array have collected enough ticks, do some thing with the array now
}
return(0);
}
//Adding data to the front of an array while resizing it
bool AddDataToMaxArray(double& array[], double dData, int iMaxSize)
{
//return if there is no data (server lagging)
if(dData == 0 )return;
bool b = false;
//increase array size with 1
if(ArraySize(array)+1 <= iMaxSize )ArrayResize(array,ArraySize(array)+1);
else b = true;
//move all values in array up on space
for(int i = ArraySize(array) ; i>=0 ;i-- )
{
array[i] = array[i-1];
}
//Add new values to front of array
array[0]= dData;
return(b);
}