[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 57

 
There are two functions.
// заполняет массив фракталами, найденными в пределах заданного количества баров
double FractalsUP[], FractalsDN[];
void FractalsMassive(string symb, int timeframe, int bars)
 {
  int fr, frtUP=0, frtDN=0;
  for(fr=3; fr<=bars; fr++)
   {
    if(iFractals(symb,timeframe,MODE_UPPER,fr)>0)
     {
      ArrayResize(FractalsUP,frtUP+1);
      FractalsUP[frtUP]=iFractals(symb,timeframe,MODE_UPPER,fr);
      frtUP++;
     }
    if(iFractals(symb,timeframe,MODE_LOWER,fr)>0)
     {
      ArrayResize(FractalsDN,frtDN+1);
      FractalsDN[frtDN]=iFractals(symb,timeframe,MODE_LOWER,fr);
      frtDN++;      
     }
   }
 }
double ExtremeFractalUP(double& fractalup[])
 {
  int masrange, efup;
  masrange=ArrayRange(fractalup,1);
  
  for(efup=0; efup<masrange; efup++)
   {
    if(fractalup[efup]>fractalup[efup+1])
     {
      return(fractalup[efup]);
     }
    else continue;
   }  
 }

"FractalsUP - incompatible types" error when trying to compile in EA.

   FractalsMassive(Symbol(),0,100);
   double extr=ExtremeFractalUP(FractalsUP[]);

Functions and declared arrays are stored in include files, if anything.

 
silhouette:
I read textbook before writing, I saw underline, but in practice I could not implement it - it says about incompatible type.


I saw a working example of passing parameters of array element values by reference (with & prefix).

 
silhouette:
There are two functions.

When trying to compile in EA, it gives error "FractalsUP - incompatible types".

Functions and declared arrays are stored in include files, if anything.


God willing, this should work. At least it compiles without errors:

int start()
{
 double FractalsUP[], FractalsDN[];
 ExtremeFractalUP(FractalsUP);// Передаем ссылку на один массив
 ExtremeFractalUP(FractalsDN);// Передаем ссылку на другой массив
}
//
double ExtremeFractalUP(double& fractalup[]) // В параметрах указываем что будет передаваться ссылка на массив
 {
  int masrange, efup;
  masrange=ArrayRange(fractalup,1);
  
  for(efup=0; efup<masrange; efup++)
   {
    if(fractalup[efup]>fractalup[efup+1])
     {
      return(fractalup[efup]);
     }
    else continue;
   }  
 }
 
Sepulca:


God willing, this should work. At least it compiles without errors:

Thanks for the help, the principle seems to be sorted out.
 

Hello Dear programmers!

Could you please tell me what I am doing wrong?

I have an external variable of int type, in the program it should set how many elements will be in the array of double type,

I am doing it the way i am shown below, but the compiler still generates errors, i have already tried to write an external variable of the double type, but i still get errors.

Please advise.

extern int       max_count=4;

int start()
{
   static double A[max_count];

Errors

 
SvSerg:

Hello Dear programmers!

Could you please tell me what I am doing wrong?

I have an external variable of int type, in the program it should set how many elements will be in the array of double type,

I am doing it the way i am shown below, but the compiler still generates errors, i have already tried to write an external variable of the double type, but i still get errors.

Please advise.

Initialize the array with an explicit value of double A[4];

Then resize it using ArrayResize();

 
artmedia70:

Initialize the array with an explicit value of double A[4];

Then resize it using ArrayResize();



Thank you!

I'm thinking, if we initialize an empty arraydouble A[];, then it's possible to put as much as you want by looping into it?

I apologize for nouveau-vous questions, but arrays are a mess for me as a beginner.

 
SvSerg:


Thank you!

I was thinking, if we initialize an empty arraydouble A[]; then it can be used as much as you want?

I apologize for nouveau-vous questions, but arrays are a mess for me as a beginner.

You can stuff any array with as much memory as you need, the main thing is to remember to resize it. Especially if the array is empty.
 
artmedia70:
Any array can be filled with as much memory as it needs, as long as you remember to resize it. Especially if the array is empty.


Thanks again! It's a pity you can't give me a +.
 

Good afternoon!

Dear programmers! You need to write an Expert Advisor.

Description available.

What are the conditions? What are the guarantees?

Regards, Maxim.