What is wrong with this Array search? New comment [Deleted] 2008.09.06 18:27 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) } Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes adding and/or deleting data in Array ArrayBSearch Help Pls :) Ray 2008.09.06 18:29 #1 int ArrayBsearch( ) Note: Binary search processes only sorted arrays. New comment
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)
}