Download MetaTrader 5
To add comments, please log in or register
Having questions to the author of an article? Discuss them on the Forum!
balintba
18
balintba 2014.03.17 21:02 

Hello,

I would like to report a possible mistake in the Standard Library, Array Class. In my editor, the following function is written in the

ArrayDouble class as follows:


int CArrayDouble::Maximum(const int start,const int count) const

{

return(ArrayMaximum(m_data,start,count));

}

In the documentation, the ArrayMaximum and ArrayMinimum functions are however defined in the following manner:

int ArrayMaximum(

const void& array[], // array for search
int count=WHOLE_ARRAY, // number of checked elements
int start=0 // index to start checking with
);

So according to the documentation the first variable should be the array itself, it is correct. The second variable should be

the count value and the third the starting position. In the Standard Library, however, the start variable is written in the second

place and the count variable in the third place. Either the documentation or the Standard Library is mixed up.

Please advise, which is the correct use of the function. Can I trust the Standard Library? How well is it tested for mistakes?

Many thanks in advance!

Jose Ignacio Martin Somokurzio
44
Jose Ignacio Martin Somokurzio 2014.09.18 22:04  
 double aArrayValMax[] =  { 156.006, 156.002, 156.005, 156.007, 156.005 }                ;
 double aArrayValMin[] =  { 156.001, 156.002, 156.003, 156.005, 156.006 }                 ; 
 
 CArrayDouble * aArrayCopyMax = new CArrayDouble                                                 ;
 CArrayDouble * aArrayCopyMin = new CArrayDouble                                                  ; 
 
 aArrayCopyMax.AssignArray( aArrayValMax )                                                              ;
 aArrayCopyMin.AssignArray( aArrayValMin )                                                               ;

 .........................................................................................................................................
 //----------       With  WHOLE_ARRAY

 

 Print("  CopyMax.Maximum...  ", aArrayCopyMax.Maximum( WHOLE_ARRAY, 0 ))          ;
 Print("  CopyMin.Minimum...  ", aArrayCopyMin.Minimum( WHOLE_ARRAY, 0 ))             ;

 

//----------                                             results:

 

2014.09.18 23:50:18.761 MatrizCont GBPJPY,M1:   aArrayCopyMin.Minimum...  5

2014.09.18 23:50:18.761 MatrizCont GBPJPY,M1:   aArrayCopyMax.Maximum...  3

 .........................................................................................................................................

 //----------                                   with 5 elements

 

 Print("  CopyMax.Maximum...  ", aArrayCopyMax.Maximum( 5, 0 ))          ;
 Print("  CopyMin.Minimum...  ", aArrayCopyMin.Minimum( 5, 0 ))             ;

 

//----------                                              results

 

 2014.09.18 23:52:18.561 MatrizCont GBPJPY,M1:   ValMax  Minimum...  0

2014.09.18 23:52:18.561 MatrizCont GBPJPY,M1:   ValMax  Maximum...  3

 

I have first changed the "start"  in CArrayDouble by "star"

 //---------------------             in class declaration:

 

int  Minimum(const int count, const int star ) const;

int  Maximum(const int count, const int star ) const;

 

//-------------------               and in the function

 

//+------------------------------------------------------------------+

//| Find minimum of array                                            |

//+------------------------------------------------------------------+

int CArrayDouble::Minimum(const int count,const int star ) const

  {

   return(ArrayMinimum(m_data, count, star));

  }

//+------------------------------------------------------------------+

//| Find maximum of array                                            |

//+------------------------------------------------------------------+

int CArrayDouble::Maximum(const int count,const int star ) const

  { 

   return(ArrayMaximum(m_data, count, star));

  } 

Best regards .Be Lucky&Happy 

whroeder1
13619
whroeder1 2014.09.19 13:10  
Don't paste code
Play video
Please edit your post.
For large amounts of code, attach it.
/
To add comments, please log in or register