Questions from Beginners MQL5 MT5 MetaTrader 5 - page 86

 
fyords:
Print the ObjectCreate results, maybe there is an error there.

Thank you. I will definitely check, but after fixing the new problem. The EA worked for a while and has now been automatically removed from the chart. I can't put it back, it says the array is full.

void CreateLevels()
   {
      double High[];
      ArrayResize(High,0);
      ArraySetAsSeries(High,true);
      CopyHigh(_Symbol,_Period,0,Candle,High);

      for(int j=Nachalo;j<=Candle;j++)
         {
          //--- поиск макс -----------------------------------
          if(iHighest(Symbol(),0,10,MN*2,j-MN)==j)
            {
             double H=High[j];
            }
int iHighest(string symbol,int tf,int type,int count,int start)
  {
   if(start<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(count<=0) count=Bars(symbol,timeframe);
   if(type==10)                                 // MODE_HIGH
     {
      double High[];
      ArraySetAsSeries(High,true);
      CopyHigh(symbol,timeframe,start,count,High);
      return(ArrayMaximum(High,0,count)+start);
     }
   return(0);
  }

Candle=1000. The compiler doesn't swear anywhere, nothing appears in the debugger. Please suggest a solution to the problem

 
The next build will very rarely ask for signals if you don't use them.

This has already been corrected.
 
Renat:
The next build will very rarely ask for signals if you don't use them.

This has already been corrected.
I take it that answer is not for me.
 
There is now a technical error when trying to set the EA on the chart. Where should the details of the error be sent?
 
WindSW:

Why ArrayResize=0?

And it looks like ArrayInitialize should be added before it.

И

double H

Is it initialized each time in loop?

Declare it before the function.

Upd and double-check parentheses, I'm missing one } in

CreateLevels
 
Silent:

Why ArrayResize=0?

Zeroing array High[]
 
WindSW:
Zeroing array High[]
No, you set its size to 0.
 
Silent:
No, you set its size to 0.
Does the information remain at size 0? What is the correct way to reset it?
 
WindSW:
Does the information remain at size 0? How is zeroing performed correctly?

You set the size to zero and then copy the array there.

Try that.

void CreateLevels()
  {
   double High[];
   ArrayResize(High,Candle); // размер = Candle
   ArrayInitialize(High,NULL); // инициализация нулем
   ArraySetAsSeries(High,true);
   CopyHigh(_Symbol,_Period,0,Candle,High);

   double H; // вынес
   int j;    // вынес
   for(j=Nachalo;j<=Candle;j++)
     {
      //--- поиск макс -----------------------------------
      if(iHighest(Symbol(),0,10,MN*2,j-MN)==j)
        {
         H=High[j];
        }
     }
  } // скобки сразу парами ставьте, искать не прийдётся
Upd corrected the code, also int j
 
WindSW:
And with size 0 the information stays?

And, if you kill it, you could probably call ArrayResize twice, with 0, then with the right array size.

It might even be faster... Although I don't know how it would look like in terms of memory allocation.

Reason: