How do I remove an element from an array (one-dimensional two-dimensional)?

 
How do I remove an element from an array? Do I need to know the number of elements stored in it?
 

There is a function, although no one has seen it (either in the help or on the website), but it is there )


 
Ilya Malev:

There is a function, although no one has seen it (either in the help or on the website), but it is there )

oh, a secret function, and how does it work?
 
Ilya Malev:

There is a function, although no one has seen it (either in the help or on the website), but it is there )


Coming soon

 

To delete a single item, the function

void OnStart()
{
 double array[];
 CopyOpen(_Symbol, PERIOD_CURRENT, 0, 6, array);
 ArrayPrint(array);
 dellArrayElement(3, array);
 ArrayPrint(array);
}/*******************************************************************/

void dellArrayElement(int shift, double &arr[])
{
 int arrSize = ArraySize(arr);
 if(shift > arrSize)
  return;
 if(shift < arrSize)
 ArrayCopy(arr, arr, shift, shift+1);
 ArrayResize(arr, arrSize-1);
}

Result

2018.12.22 09:55:06.206 !00 (EURUSD,M15)        1.13588 1.13607 1.13588 1.13612 1.13586 1.13614
2018.12.22 09:55:06.206 !00 (EURUSD,M15)        1.13588 1.13607 1.13588 1.13586 1.13614

Then you can convert this function to bool type, so that you can control its execution. Basically, if you are smart and can control the values you send to it, you can use it anyway...

Remember, you cannot reduce the size of static arrays.

 
Alexey Viktorov:

To delete a single item, the function

Result

Then you can convert this function to bool type, so that you can control its execution. Basically, if you are smart and can control the values you send to it, you can use it anyway...

Don't forget that you cannot reduce the size of static arrays.

Comrade has written: one-dimensional and two-dimensional. Your function doesn't work with two-dimensional. Show me how to make a function with the same name work for both :)

 
Alexey Viktorov:

Don't forget that static arrays cannot be reduced in size.

I'm not reducing the size of the array, I'm removing an element from it, these are different things. I understand that your function deleted value1.13612, it is specified in the linedellArrayElement(3, array); i.e. the 3rd element is removed from the array, i.e. understood correctly? How fast are such experiments loading the program a lot?

 
Aleksey Semenov:
oh, a secret function, and how does it work?

In C++ there are such functions, you plug in the library and the action is performed. But we take into account the fact that mql doesn't have such functions and want to use handwritten functions.

 

I found thishttp://kvodo.ru/urok-7-2-massivyi-osnovnyie-operatsii.html (and also this https://purecodecpp.com/archives/1935)

Suppose we need to removethe m-th element in numberfrom arrayX consisting ofn elements. For that, just write (m+1)-th element in place of elementm, (m+2)-th element in place of (m+1)-th, and so on,n-1 in place of(n-2)and usen-1elementwhen working with this array further:

cout<<"\n m="; cin>>m; //ввод номера элемента, подлежащего удалению
for (i=m; i<n-1; X[i+1],i++); //удаление m-го элемента
for (i=0; i<n-1; i++) cout<<X[i]<<"\t"; //вывод измененного массива
n--; //уменьшение количества элементов в массиве

But that's with C++. But here we need to know the number of items stored in the array. You need to write a function that will read the elements as they are written.

 
Alexey Viktorov:

To delete one element, this function will be fine

And if you want to delete e.g. not a price value but a date from an array, willCopyOpen work with dates, as I understood from the help that this function works with prices?

 
Ilya Malev:

There is a function, although no one has seen it (either in the help or on the website), but it is there )


How does it work?

int ArrayRemove()

There is no description of it in the help, where can I read about it?

Reason: