The array has to be sorted first
fxchess:
Dear Metaquotes
why ArrayBsearch(array,30,WHOLE_ARRAY,0,MODE_ASCEND) is 0- Only us users here. MetaQuotes is at the Service Desk
Play videoPlease edit your post.
For large amounts of code, attach it.
- ArrayBsearch - MQL4 Documentation clearly says:
Note
Binary search processes only sorted arrays. To sort numeric arrays use the ArraySort() function.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Dear Metaquotes
i use this code to test arraybsearch i feel the result is incorrect
int OnInit()
{
//---
ArrayResize(array,10);
array[0]=64;
array[1]=128;
array[2]=52;
array[3]=78;
array[4]=30;
array[5]=21;
array[6]=88;
array[7]=977;
array[8]=2110;
array[9]=887;
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
Print(array[4]);
Print(ArrayBsearch(array,30,WHOLE_ARRAY,0,MODE_ASCEND));
}
//+------------------------------------------------------------------+
Array[4] is 30
why ArrayBsearch(array,30,WHOLE_ARRAY,0,MODE_ASCEND) is 0
thank you!