Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1005

 
Here's how it works.
 
Seric29:
Here's how it works.
Ilyas has already explained it quite clearly. Look for it in his posts.
 
Seric29:
Here's how it works.

Are you sure you've read everything in the documentation? You even read this:

Note

The function can only be applied to dynamic arrays. You should bear in mind that dynamic arrays assigned as indicator buffers by the SetIndexBuffer() function cannot be resized. All operations related to resizing of indicator buffers are performed by the executive subsystem of the terminal.

The total number of elements in an array cannot exceed 2147483647.

If memory is allocated frequently it is recommended to use the third parameter specifying the reserve to reduce the amount of physical memory allocation. All subsequent calls to the ArrayResizefunction will not result in physical memory reallocation, only a resizing of the first dimension of the array within the reserved memory. Keep in mind that the third parameter will only be used when physical memory allocation is in progress, for example:

ArrayResize(arr,1000,1000);
for(int i=1;i<3000;i++)
ArrayResize(arr,i,1000);

In this case there will be 2 memory reallocations, once before entering the loop for 3000 iterations, with the array dimension set to 1000 and the second at i equal to 2000. If the third parameter is omitted, there will be 2,000 physical memory re allocations and this will slow down program execution.


What's not clear about it?

 
Alexey Viktorov:

Are you sure you've read everything in the documentation? Even read this:

What's not clear about this???

Well, that's the point that there are no pictures or examples, and you can guess what these redistributions mean, and how to use it 100% according to the developers' idea if it's not explained. Judging by these 3 lines that are written here, I think that ArrayResize(arr,1000,1000); creates an array of 2 thousand elements. But it's not clear here. If I do ArrayResize(arr,1,1000); for example, 1000 will hang idle until the array gets to 1000.

for(int i=1;i<1001;i++)ArrayResize(массив,i,1000);

Or the program will use this fragment before overclocking, just incrementing the counter. Or this 1000 is just lying around to quickly get memory from CPU, if it's so then backup memory too will have to be transferred, then it's easier to work without backup. In general, no code, no information, no pictures, no idea how it works.

 
Do you ever have this situation where the hard disk is 100% loaded by a System class of some kind (on 10ka)? It also happens with alps terminal... Usually terminals load the disk during tests, but here it's just kabbda... Not long, 3-5 seconds, but concrete
 
Yevhenii Levchenko:
Do you ever have this happen that your hard drive is 100% booting System class of some sort (on 10)? It also happens with alps terminal... Usually terminals load the disk during tests, but here it's just kabbda... Not long, 3-5 seconds, but concrete

happens, but after PC reboot

at 10-15 min after PC reboot Windows Defender "chews up the disk" and PC usage statistics are collected

solution - suspend the PC, my PC can go a month without rebooting, I press the sleep button on the keyboard instead of shutting down the PC - a couple of times the power went out, no problem with Win10 booting if the PC was in sleep

 
Seric29:

That's the thing, there are no pictures or examples, and you can guess what these redistributions mean, and how to use it 100% according to the developers' idea if it's not explained. Judging by these 3 lines that are written here, I think that ArrayResize(arr,1000,1000); creates an array of 2 thousand elements. But it's not clear here. If I do ArrayResize(arr,1,1000); for example, 1000 will hang idle until the array gets to 1000.

Or the program will use this fragment before overclocking, just incrementing the counter. In general, I say it is not clear and that's all. Or this 1000 it is just stupid lying around to quickly scoop memory from the processor, if so then all the same and the backup memory, too, will have to transfer then it is easier to work without the reserve. In general, no code, no information, no pictures, no idea how it works.

You should read not only the three lines of code, but also the text which explains everything quite clearly.

Reserved memory and array size are different notions. If you override the array size with ArrayResize(arr,1000,1000); the last array element will be 999 and no more. But if you need to increase the array's size, there will be no memory reallocation. If you don't need such a reserve of array size, make it smaller or don't reserve it at all.

 

Good afternoon!
I want to put one parameter as an array in a function. I can't figure out how to do it right. Can you correct the example?

void OnTick()
  {
//---
   int TestArr[]= {5,3,9,4};
   TestFArr(TestArr[]);
  }
//+------------------------------------------------------------------+

void TestFArr(int TestArr[])
  {
   int size=ArraySize(TestArr);
   Print(" --------------- size: ",size);
  }
//+------------------------------------------------------------------+
 
Nauris Zukas:

Good afternoon!
I want to put one parameter as an array in a function. I can't figure out how to do it right. Can you correct the example?

void OnTick()
  {
//---
   int TestArr[]= {5,3,9,4};
   TestFArr(TestArr);
  }
//+------------------------------------------------------------------+

void TestFArr(int & TestArr[])
  {
   int size=ArraySize(TestArr);
   Print(" --------------- size: ",size);
  }
//+------------------------------------------------------------------+
 
Artyom Trishkin:

Thank you!

Reason: