Errors, bugs, questions - page 2276

 

When I need to fill a part of a large array with a single Z-value, I use the construct:

ArrayInitialize(ar,Z);     // промежуточный массив размер массива ar = 1000 
ArrayCopy(arr,ar,5000);    // основной массив заполняется значением Z c 5000 по 5999 элемент


Many traders will say why it is so complicated, it can be simpler:

ArrayFill(arr,5000,1000,Z);

But for some unknown reason, the first variant using an intermediate array runs noticeably faster than the second

2018.09.04 11:01:17.222 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayFill = 338
2018.09.04 11:01:17.222 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayInitialize + ArrayCopy = 111
2018.09.04 11:01:18.563 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayFill = 301
2018.09.04 11:01:18.563 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayInitialize + ArrayCopy = 122
2018.09.04 11:01:19.717 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayFill = 334
2018.09.04 11:01:19.717 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayInitialize + ArrayCopy = 142
2018.09.04 11:01:21.095 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayFill = 364
2018.09.04 11:01:21.095 TestArrayFill (EURUSD,M4)       Время заполнения через ArrayInitialize + ArrayCopy = 156

I already wrote on this issue to CA a couple of years ago. I got a reply saying that I had found and fixed the problem and it would be ok in the next build.

But the problem persists.

I've got the same test in MT4:

2018.09.04 11:08:21.258 TestArrayFill EURUSD,H1: Время заполнения через ArrayInitialize + ArrayCopy = 113
2018.09.04 11:08:21.258 TestArrayFill EURUSD,H1: Время заполнения через ArrayFill = 78
Files:
 
Nikolai Semko:

When I need to fill a part of a large array with a single Z-value, I use the construct:


Many traders will say why it is so complicated, it can be simpler:

But for some unknown reason, the first variant using an intermediate array runs noticeably faster than the second

I already wrote on this issue to CA a couple of years ago. I got a reply saying that I had found and fixed the problem and it would be ok in the next build.

But the problem persists.

I've got the same test in MT4:

Maybe this is a good place to check in.

 
Artyom Trishkin:

Maybe this is a good place to check in.

What a peculiarity and subtlety!
The important standard function of working with arrays in the world's fastest algorithmic trading language is 4 times slower than in the obsolete MQL4 language.
Only here.

It's a clear bogey.
Can you imagine how many programs are going to fail when it is fixed?
 
Nikolai Semko:

What a peculiarity and subtlety!
The important standard function of working with arrays in the world's fastest algorithmic trading language is 4 times slower than in the outdated MQL4 language.
Only here.

It's a clear bogey.
Can you imagine how many programs will be affected when it is fixed?

Good.

But as a feature at the moment - is that a bad thing?
 
Artyom Trishkin:

Good.

But as a feature at the moment - is that a bad thing?
Yes, I probably stated the problem incorrectly. It appeared as if I was talking about its solution.
Of course not. I was trying to formulate the problem. The intermediate array option is not a solution to the problem at all, because it takes longer to execute than it should based on memory logic, and also leads to additional memory consumption.
 
Artyom Trishkin:

Good.

But as a feature at the moment - is that a bad thing?

Anecdote.

An old man goes to the doctor. He says:

- Doctor, my back hurts.

- Bend over. Does it hurt?

- It hurts.

- Bend down more!

- There, that feels better...

- There! That's how you walk!

)))))

 
Nikolai Semko:

When I need to fill a part of a large array with a single Z-value, I use the construct:


Many people will say why it's so complicated - it can be simpler:

But for some unknown reason, the first variant using an intermediate array works much faster than the second one

I don't understand! Why did you need to fill part of a large array with a single Z value? Or, what data do you assign to the array, for what purpose? Close, AVG, RSI values? But aren't they present in MetaTrader's memory after the indicator is loaded? I was playing with the array 0 and 1 and finally got the word SOS, i.e. I assigned 0 value to S and 1 to O. Of course, I could enter Help for a better result in the second array size. Then check the filling time for each array's size. Then add everything up and divide by 4.
 
Bob1Thec:
I can't understand! Why did you need to fill part of a large array with a single Z-value? Or, what data do you assign to the array, for what purpose?
The monochrome background (including transparency) of a picture is done this way.
 
fxsaber:
The monochrome background (including transparency) of a picture is done this way.

more precisely a gradient background

 
Nikolai Semko:

more precisely a gradient background

I have no idea what filling an array with a single value plays here.

Reason: