Single array calculation during optimisation - page 2

 
fxsaber:
Resource attachment. Don't ask how. Didn't write the source code.
Do you need a third-party software to create an array?
 
forexman77:

So I have a dilemma: how to make it possible to read from a file once, fill an array with it and use this array on all passes.

I need this to reduce the optimization time, because the array will always be unchanged and it is expensive to read it every time.

Well, for example, write a script that prepares and collects all data into an array, and then writes the finished array to a file. And then read this array from the file during initialization in the Expert Advisor. The file can be used as many times as you need, with each run of the EA.
I think that this solution has already been suggested to you. It does not suit you?
 
forexman77:
Using third-party software to create an array?
Yes, by the same MQL5 with one separate pass before optimisation.
 
BlackTomcat:
For instance, write a script that will prepare and collect all data in an array and then write the completed array into a file. And then read this array from the file during initialization in the EA. The file can be used as many times as you need, with each run of the EA.
I think that this solution has already been suggested to you. It does not suit you?

Yeah, that's the thing, it doesn't fit. There are 15,000 passes in the optimization. And I need only once to calculate and at the subsequent passes only to address an array.

That is, I already have data in the file that are calculated ahead of time and level, and they are known to me in advance. And even reading the file each time in the init is very expensive (there are thousands of lines). I don't know about MQL5, but in MQL4 they wrote on the forum that the program passes the init on every pass.

 
forexman77:
Will it be necessary to read in the inite on every pass?
Yes. It's not difficult or costly. Use binary mode. You may not read the whole file, but start from the desired position.
 
forexman77: And even reading the file every time inite, on every pass is very costly (several thousand lines). I don't know about MQL5, but in MQL4 they wrote in the forum that the program takes an init on every pass.
You know, I think you are exaggerating about expenses related to reading the array from the file. Every time Windows wakes up from sleep mode, it restores from the hard drive the image of its state that it had at the moment of going to sleep, including the state of all applications. Do you think there are not enough objects and information there? And how long does it take to come out of sleep like that?
You are exaggerating, IMHO.
 
forexman77:

Yeah, that's the thing, it doesn't fit. There are 15,000 passes in the optimization. And I need only once to calculate and at the subsequent passes only to address an array.

That is, I already have data in the file that are calculated ahead of time and level, and they are known to me in advance. And even reading the file each time in the init is very expensive (there are thousands of lines). I don't know about MQL5, but in MQL4 they wrote on the forum that the program passes the init on every pass.

A classic trick from C/C++ world : you can make/convert a static array from your file (just text: double arr[100500]={1,2,3....} ) and just include it through #include.

 
BlackTomcat:
You know, I think you are exaggerating about the costs of reading an array from a file. Every time Windows wakes up from sleep mode, it restores from the hard drive an image of its state that it had at the moment of going to sleep, including the state of all applications. Do you think there are not enough objects and information there? And how long does it take to come out of sleep like that?
You are exaggerating, IMHO.

The costs are greater unambiguously. There are two variants with unchanged indicator settings and with the same values, but already written to a file, which are dumped into an array.

The variant with the file takes many times longer to be calculated than the variant with indicator calculation in the Expert Advisor.

I was just thinking that maybe there is a way to save the array once and use it for all passes of optimization, thus relieving the load on the algorithm.

 
Maxim Kuznetsov:

A classic trick from the C/C++ world: you can make/convert a static array from your file (just text: double arr[100500]={1,2,3....} ) and just include it via #include.

If you do that, will the array be saved when you switch to a new pass?
 
forexman77:

The costs are greater unambiguously. There are two variants with unchanged indicator settings and with the same values, but already written to a file, which are dumped into an array.

The variant with the file takes many times longer to be calculated than the variant with indicator calculation in the Expert Advisor.

I just thought that maybe there is a way to store the array once and use it for all passes of optimization, thus relieving the load on the algorithm.

Calculate ONE time and save the array with the results into a file. And then read the ready array from the file during initialization and use it immediately. No need to recalculate again. You have already calculated everything before and saved it. Why count again? :)
Reason: