Questions from Beginners MQL5 MT5 MetaTrader 5 - page 88

 
WindSW:
Please, can you tell me how to see how much memory Expert Advisor occupies and how it is reallocated?

The Windows Task Manager should be enough for you.

Check outthis article.

In general, take apart your Expert Advisor into scripts, make all functions work, and then assemble them in a pile.

 
WindSW:

And yet I can't figure out why levels are not created using ObjectCreate. All functions work, but no OBJ_TREND objects are created

There are variables defined on the global level:

string oRes, oSup, oPP, oRes1, oRes2, oRes3, oSup1, oSup2, oSup3, textPP, textR1, textR2, textR3, textS1, textS2, textS3;

The code that should create the levels:

Folks, help sort this out. Please

Levels are created, only they are not visible)

Set the coordinates - time / price. You have zeros all over the place.

 
Dima_S:

Levels are created, only you can't see them)

Set the coordinates - time / price. You have solid zeros set there.

It makes an object without bindings, then modifies it. Here.

The object is not created because of incorrect (not assigned) name. (Above already replied). Consequently, it can't be modified to see it.

 
fyords:

Well, let's say you've declared variables at global level, have you assigned values to these variables?

If not, then you say to the program "create an object with such-and-such characteristics with the name..." and there is a problem - the name is not given. So it doesn't create it.

Wouldn't it be easier to specify it directly in the ObjectCreate code?

Thank you! For some reason I didn't think to do that right away, because in version 4 the name of the object is also defined.
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Свойства объектов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Свойства объектов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Свойства объектов - Документация по MQL5
 

I can't get a fix for the array overflow error. I wrote about it on page 88. The Expert Advisor works for some time and crashes. To be more exact it works one pass from the beginning to the end of Expert Advisor and on the second pass in the loop below the array overflows indicating a string:

H=High[j];

void CreateLevels()
   {
      double High[];
      ArrayResize(High,0);
      ArraySetAsSeries(High,true);
      CopyHigh(_Symbol,_Period,0,Candle,High);
      ArrayResize(HBar,0);
      ArrayResize(HBar,1000);
      int countH=0;
      int f1;
      double H;
      for(int j=Nachalo;j<=Candle;j++)
         {
          //--- поиск макс -----------------------------------
          if(iHighest(Symbol(),0,10,MN*2,j-MN)==j)
            {
             f1=0;
             H=High[j];                                 // отметка текущего хая
             ...                                        // здесь обработка флага f1
             if(f1==0)                                  // если занесение хая в массив разрешено
               {
                HBar[countH][0]=High[j];
                countH++;
               }
            }
         }
   }

Most importantly, I don't understand how the High[] array overflows, since a specific number of haves is specified? And why terminal indicates overflow in string H=High[j]; ?

Please, can you tell me how to implement it correctly? Is it possible to null High[] array or to write the high of a particular candle in variable H in some other way?

 
WindSW:

Try it this way:

for(int j=Nachalo;j< Candle;j++)

Basis: array indexing starts at zero, so when Candle==100 the last element of the array is indexed by the number 99, not the number 100.

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Основы языка / Переменные - Документация по MQL5
 
Yedelkin:

Try it this way:

Basis: array indexing starts at zero, so when Candle==100 the last element of the array is indexed by the number 99, not the number 100.

Thank you! It helped!
 

Good afternoon! I encountered the following problem... Generated an Expert Advisor... Run it on RTS index futures. And there, the lots are not fractional = no money management works, and the quotations are multiples of 10 = trailing stop does not work. Please advise, is it possible to solve this problem?

I know how to round iMa values to 10 or 5, as a last resort I think to run trailing stop separately.

 
oldiol: If my EA has not fractional lots = not working money management, and quotes multiple of 10 = not working trailing stop. Please advise, is it possible to solve this problem?

The tool has a Volume_Step property. See if you can use it for non-fractional volumes.

For quotes divisible by 10, you just need to make the trailing stop step the same.

 
Yedelkin:

The tool has a Volume_Step property. See if you can use it for non-fractional volumes.

And for quotes divisible by 10, you just need to make the trailing stop step the same.

Thank you very much) I'll give it a try.
Reason: