Questions from Beginners MQL5 MT5 MetaTrader 5 - page 113

 

Hello, I can't write an array.

Every day a Ros level appears, if the price (Tick) touches it then it becomes invalid, i.e. we don't remember it.

The task.

If a tick has not touched the Ros level, we keep the value of the Ros price in the array.

If a tick has touched Ros, we delete the Ros price value from the array.

I tried to write something, but it's just nonsense. I cannot even add the index value to the array. Not to mention adding the index itself))

double masCenPoc[]; 
   int Size = ArraySize(masCenPoc);
      
   for(int i=0; i<Size; i++){
 
   if(cena_poc < high && cena_poc < low)
    masCenPoc[i] = cena_poc;
   if(cena_poc > high && cena_poc > low)
    masCenPoc[i] = cena_poc;
    
 
Top2n: int Size = ArraySize(masCenPoc);
What is the value of the Size variable?
 
Yedelkin:
What is the value of the Size variable?

 int Size = ArraySize(masCenPoc);
 
Top2n:

Hello, I can't write an array.

Every day a Ros level appears, if the price (Tick) touches it then it becomes invalid, i.e. we don't remember it.

The task.

If a tick has not touched the Ros level, we keep the value of the Ros price in the array.

If a tick has touched Ros, we delete the Ros price value from the array.

I tried to write something, but it's just nonsense. I cannot even add the index value to the array. Not to mention adding the index itself))

It all seems a bit vague, so I think you should first define what you need this array for. Then you compare the same variables and put the same values in the array.
 
zfs:

So I can't write the index of the array to increase as the values of Ros accumulate. Size is not equal to anything yet))

The array is needed to accumulate non-crossed values of Ros, and to remove them from the array as they are crossed.

Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Основы языка / Переменные - Документация по MQL5
 
Top2n: Size doesn't equal anything yet))
What do you mean "doesn't equal anything"? What value does the Size variable contain? How many iterations are there in the for loop ?
 
Yedelkin:
What does "not equal to anything" mean? What value does the Size variable contain? How many iterations in the for loop ?

The question is open, we need indexes to increase as Ros values are filled, it's kind of dynamic. if there are 5 Ros values, then Size = 5. I don't know how to do it.

 
Top2n: The question is open, we need indexes to increase as Ros values are filled, it's kind of dynamic. if there are 5 Ros values, then Size = 5. I don't know how to do it.
https://www.mql5.com/ru/docs/array/arrayresize
Документация по MQL5: Операции с массивами / ArrayResize
Документация по MQL5: Операции с массивами / ArrayResize
  • www.mql5.com
Операции с массивами / ArrayResize - Документация по MQL5
 

is it something like this?

 for(int i=0; i<Size; i++){
  int Size =   ArrayResize(masCenPoc,i,1)
   if(cena_poc < high && cena_poc < low)
    masCenPoc[i] = cena_poc;
   
   if(cena_poc > high && cena_poc > low)
    masCenPoc[i] = cena_poc;
 
Top2n: is it something like this?
It's hard to answer. I've reread your posts, but I don't understand the idea of changing the array's size. And the answer to the code depends on understanding the concept. Maybe somebody else will answer.
Reason: