error with mq1rate

 

Hello everybody,  i'm french and i am a beginner, i wrote a program and i need help with an error that i don't understand:


int main ()
{

datetime start_time="20:00:00";
datetime stop_time="05:00:00";

  MqlRates rates[];
   int copied=CopyRates(NULL,0, start_time,stop_time,rates);
   if(copied<=0)
      Print("Error copying price data ",GetLastError());
   else Print("Copied ",ArraySize(rates)," bars");
 
  
   int    maxValueIdx=ArrayMaximum(rates,WHOLE_ARRAY,0);
   Print("Max value = ",rates [maxValueIdx]," at index=",maxValueIdx);
 
 

   int    minValueIdx=ArrayMinimum(rates,WHOLE_ARRAY,0);
   Print("Min value = ",rates [minValueIdx]," at index=",minValueIdx);
 

   return (0) ;}


error is line 21 and 26 : 'rate'-objects are passed by reference only


thanks for your help

 

In the ArrayMaximum the first parameter must be a numeric array:

array[] [in]  A numeric array, in which search is made.

By numeric is meant double[], char[], int[], long[] etc, but not the structure[].

 
pragma64: i am a beginner
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. int main () {
    Unlike C/C++, there is no main in Mql4. Event Handling Functions - Functions - Language Basics - MQL4 Reference
  3. datetime start_time="20:00:00";
    datetime stop_time="05:00:00";
    This will not compile. You can use the literal format (D'20:00:00') if you mean the date of compile. Otherwise you must conversion function StringToTime - Conversion Functions - MQL4 Reference
  4. OVO answered your question. For what you are trying to do, read up on iBarShift and iHighest - Timeseries and Indicators Access - MQL4 Reference






 
if i want to use iHighest how can i write it in order to the fonction calculate the hightest price of a period ? i mean from 20h to 5h ?

 
pragma64: if i want to use iHighest how can i write it in order to the fonction calculate the hightest price of a period ? i mean from 20h to 5h ?

WHRoeder has already answered that (and I quote):

WHRoeder: For what you are trying to do, read up on iBarShift and iHighest - Timeseries and Indicators Access - MQL4 Reference

Use iBarshift() to convert a "date & time" into a "bar-shift" which you can use with the iHighest() which in turn will return another "bar-shift" which you can then use with High[], high[] or iHigh() depending on the case.

Also, please read a related thread of a user with a similar request: https://www.mql5.com/en/forum/159990

Reason: