Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:
Please use this to post code . . . it makes it easier to read.
Here RaptorUK ...
//+------------------------------------------------------------------+ //| Test 2.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- int Array_A[10] = {5, 7, 3, 1, 2, 6, 9, 8, 10, 4} ; int Array_B[15] = {2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15} ; int c1[10] ; int handle = FileOpen("C1.csv", FILE_CSV|FILE_WRITE, ","); if(handle>0) { for(int j=0; j<10; j++) { c1[j]=ArrayBsearch(Array_B,Array_A[j],WHOLE_ARRAY,0,MODE_ASCEND); FileWrite(handle, c1[j]) ; } } FileClose(handle); //--- return(0); } //+------------------------------------------------------------------+
What do you mean by "does not return the proper values.". ArrayBsearch return is the index of searched array. I check and it's correct.
Is this what you looking for
c1[j]= Array_B [ArrayBsearch(Array_B,Array_A[j],WHOLE_ARRAY,0,MODE_ASCEND)];
Here is my script code. It does not return the proper values.
int Array_B[15] = {2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15} ;
c1[j]=ArrayBsearch(Array_B,Array_A[j],WHOLE_ARRAY,0,MODE_ASCEND);
Of course it doesn't. Array_B is NOT sorted. RTFM
Here RaptorUK ...
What do you mean by "does not return the proper values.". ArrayBsearch return is the index of searched array. I check and it's correct.
Is this what you looking for
I tried that and it still does not give me the correct results.
The results should be
9
10
8
7
0...
I am not getting these results ...
Here RaptorUK ...
What do you mean by "does not return the proper values.". ArrayBsearch return is the index of searched array. I check and it's correct.
Is this what you looking for
To make it clear what I am trying to do. I need to find the index value in Array_B of each value in Array_A.
I tried that and it still does not give me the correct results.
The results should be
9
10
8
7
0...
I am not getting these results ...
Re - run on build 409 and 419 Vista HB. The result : 9 - 10 - 8 - 0 - 0 - 9 - 11 - 10 - 11 - 8. Did you expect the result should be : 9 - 10 - 8 - 7 - 0 - 2 - 11 - 3 - 4 - 1 ?, because if it is, I should delete my previous comment then and also now I don't understand it too, which is good because I don't have to answer question :)
Think we found bug :(
Those are exactly the values I expected. Am I doing something wrong ?
Thanks alot for your help. I just wrote a loop program to get the proper results.
I appreciate the help though, means alot !!!!!!!!!!!!!!!!!!!!!!!!!
Thanks alot for your help. I just wrote a loop program to get the proper results.
I appreciate the help though, means alot !!!!!!!!!!!!!!!!!!!!!!!!!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Here is my script code. It does not return the proper values.
//+------------------------------------------------------------------+
//| Test 2.mq4 |
//| Copyright 2012, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
int Array_A[10] = {5, 7, 3, 1, 2, 6, 9, 8, 10, 4} ;
int Array_B[15] = {2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15} ;
int c1[10] ;
int handle = FileOpen("C1.csv", FILE_CSV|FILE_WRITE, ",");
if(handle>0)
{
for(int j=0; j<10; j++)
{
c1[j]=ArrayBsearch(Array_B,Array_A[j],WHOLE_ARRAY,0,MODE_ASCEND);
FileWrite(handle, c1[j]) ;
}
}
FileClose(handle);
//----
return(0);
}
//+------------------------------------------------------------------+