What is wrong with this Array search?

 

Can anyone tell me why this code does not find a record with a 0 value in the first dimension? Thank you


int AddTradeRecord()
{
int tsize=ArraySize(trades);
int r;

r=ArrayBsearch(trades,0,WHOLE_ARRAY,0,MODE_ASCEND); // find an empty row/record

if (trades[r][0]==0)
{
trades[r][0]=ticket;
trades[r][1]=sl;
trades[r][2]=tp;
trades[r][3]=_magic;
trades[r][4]=0;
}

return(0)

}

 
int ArrayBsearch( )
Note: Binary search processes only sorted arrays.