Double array size?

 
double HighBroadreachArray[];
int HighBroadreachArr=sizeof(HighBroadreachArray)/sizeof(double);

void OnStart()
  {

  CopyClose(Symbol(),PERIOD_M5,0,HighBroadreachArr,HighBroadreachArray);
  Print(HighBroadreachArr);
  Print("HighBroadreachArray:",sizeof(HighBroadreachArray));
  ArrayPrint(HighBroadreachArray);

It shows that

6
HighBroadreachArray:52
1.10902 1.10907 1.10892 1.10894 1.10896 1.10880

Double is 8 places, why not 48, but 52?

 
I guess its some internal information like size, true(reserved) size or a handle for such properties.
 
helloea:

It shows that

Double is 8 places, why not 48, but 52?

The variable HighBroadreachArr is always 6. Is the maximum 6? I think there must be something I don't know

 
helloea:

The variable HighBroadreachArr is always 6. Is the maximum 6? I think there must be something I don't know

Looks like the sizeof() will always return 52, regardless of the array size. If you want to know the number of elements in an array use ArraySize().

I think the 52 bytes cover information about size, type of element, series flags and pointer to a memory area.

Documentation on MQL5: Array Functions / ArraySize
Documentation on MQL5: Array Functions / ArraySize
  • www.mql5.com
"Zero dimension = Array size / (First dimension * Second dimension * Third dimension)"
 
helloea: Double is 8 places, why not 48, but 52?

Wrong, Floating-point has infinite number of decimals.-

Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.

 
lippmaje:

Looks like the sizeof() will always return 52, regardless of the array size. If you want to know the number of elements in an array use ArraySize().

I think the 52 bytes cover information about size, type of element, series flags and pointer to a memory area.

Because the fourth parameter of CopyClose determines how many closing prices to write into the array, I want to represent the closing prices with a variable instead of fixed values.

 
helloea:

Because the fourth parameter of CopyClose determines how many closing prices to write into the array, I want to represent the closing prices with a variable instead of fixed values.

You can specify how many values you want to have copied, and if the values are present the array will be automatically resized (in case it is dynamic.)

But you must check if the history is present, especially when copying 'foreign' chart data during OnStart.

double HighBroadreachArray[];

void OnStart()
  {
   int values_wanted=6;
   int values_received=CopyClose(Symbol(),PERIOD_M5,0,values_wanted,HighBroadreachArray);

   if(values_wanted!=values_received)
     {
      Print("error copying ",values_wanted," prices from ",PERIOD_M5,": ",_LastError);
      return;
     }
  Print("HighBroadreachArray size: ",ArraySize(HighBroadreachArray));
  Print("HighBroadreachArray values: ");
  ArrayPrint(HighBroadreachArray);